Number of processes OS switches context from A to B main use fork, and the child process call execvp() Can compiler do something bad by adding privileged.

Slides:



Advertisements
Similar presentations
CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
Advertisements

CPU Scheduling CPU Scheduler Performance metrics for CPU scheduling
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Operating Systems Chapter 6
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling Algorithms
CPU Scheduling Section 2.5.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5-CPU Scheduling
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 8 Multi-Level Feedback Queue Chien-Chung Shen CIS, UD
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
CS252: Systems Programming Ninghui Li Based on Slides by Prof. Gustavo Rodriguez-Rivera and Chapters 7,8 of OSTEP Topic 20: Processes Scheduling.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Chapter 7 Scheduling Chien-Chung Shen CIS, UD
Scheduling Strategies Operating Systems Spring 2004 Class #10.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Lecture 5 Scheduling. Today CPSC Tyson Kendon Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms.
Chapter 7 Scheduling Chien-Chung Shen CIS/UD
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Andy Wang Operating Systems COP 4610 / CGS 5765.
Scheduling Policies.
CPU SCHEDULING.
Operating Systems CS 550 Spring 2017 Kenneth Chiu
Kernel Stack Desirable for security: e.g., illegal parameters might be supplied.
Chapter 8 Multi-Level Feedback Queue
Scheduling: The Multi-Level Feedback Queue
CPU Scheduling Algorithms
Scheduling (Priority Based)
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
Lecture 23: Process Scheduling for Interactive Systems
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Scheduling: The Multi-Level Feedback Queue
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

Number of processes OS switches context from A to B main use fork, and the child process call execvp() Can compiler do something bad by adding privileged instructions?

Lecture 3 Scheduling

How to develop scheduling policy What are the key assumptions? What metrics are important? What basic approaches have been used in the earliest of computer systems?

Workload Assumptions 1. Each job runs for the same amount of time. 2. All jobs arrive at the same time. 3. Once started, each job runs to completion. 4. All jobs only use the CPU (i.e., they perform no I/O). 5. The run-time of each job is known.

Scheduling Metrics Performance: turnaround time T turnaround = T completion − T arrival As T arrival is now 0, T turnaround = T completion

First In, First Out Work well under our assumption Relax “Each job runs for the same amount of time” Convoy effect

Shortest Job First SJF would be optimal Relax “All jobs arrive at the same time.” ABC B/C arrive

Shortest Time-to-Completion First STCF is preemptive, aka PSJF “Once started, each job runs to completion” relaxed ABC B/C arrive A

Scheduling Metrics Performance: turnaround time T turnaround = T completion − T arrival As T arrival is now 0, T turnaround = T completion Performance: response time T response = T firstrun − T arrival

Turnaround time or response time FIFO, SJF, or STCF Round robin

Conflicting criteria Minimizing response time requires more context switches for many processes incur more scheduling overhead decrease system throughput Increase turnaround time Scheduling algorithm depends on nature of system Batch vs. interactive Designing a generic AND efficient scheduler is difficult

Incorporating I/O Poor use of resources Overlap allows better use of resources CPU Disk A A A A A A A B CPU Disk A A A A A A A B BB B

Workload Assumptions 1. Each job runs for the same amount of time. 2. All jobs arrive at the same time. 3. Once started, each job runs to completion. 4. All jobs only use the CPU (i.e., they perform no I/O). 5. The run-time of each job is known.

Multi-level feedback queue Goal Optimize turnaround time without priori knowledge Optimize response time for interactive users Q6 Q5 Q4 Q3 Q2 Q1 A B C D Rule 1: If Priority(A) > Priority(B) A runs (B doesn’t). Rule 2: If Priority(A) = Priority(B) A & B run in RR.

How to Change Priority Rule 3: When a job enters the system, it is placed at the highest priority (the topmost queue). Rule 4a: If a job uses up an entire time slice while running, its priority is reduced (i.e., it moves down one queue). Rule 4b: If a job gives up the CPU before the time slice is up, it stays at the same priority level.

Example Q2 Q1 Q0 A A A B B A

Example with I/O Q2 Q1 Q0 B A B A B A B A B A B A B A B A B A B A B A B A Problems: Starvation Program can game the scheduler Program may change its behavior over time

Priority Boost Rule 5: After some time period S, move all the jobs in the system to the topmost queue Q2 Q1 Q0 A A A Q2 Q1 Q0 A A A A

Gaming the scheduler Q2 Q1 Q Q2 Q1 Q0 B A B A B A B A B A B A B A B A B A B A B A B AA B A AA BB AA BB AA BB AA BB AA BB

Better Accounting Rule 4a: If a job uses up an entire time slice while running, its priority is reduced (i.e., it moves down one queue). Rule 4b: If a job gives up the CPU before the time slice is up, it stays at the same priority level. Rule 4: Once a job uses up its time allotment at a given level (regardless of how many times it has given up the CPU), its priority is reduced (i.e., it moves down one queue).

Tuning MLFQ And Other Issues How to parameterize? The system administrator configures it Default values available: on Solaris, there are 60 queues time-slice 20 milliseconds (highest) to 100s milliseconds (lowest) priorities boosted around every 1 second or so. The users provides hints: command-line utility nice

Workload Assumptions 1. Each job runs for the same amount of time. 2. All jobs arrive at the same time. 3. Once started, each job runs to completion. 4. All jobs only use the CPU (i.e., they perform no I/O). 5. The run-time of each job is known.

MLFQ rules Rule 1: If Priority(A) > Priority(B), A runs (B doesn’t). Rule 2: If Priority(A) = Priority(B), A & B run in RR. Rule 3: When a job enters the system, it is placed at the highest priority (the topmost queue). Rule 4: Once a job uses up its time allotment at a given level (regardless of how many times it has given up the CPU), its priority is reduced (i.e., it moves down one queue). Rule 5: After some time period S, move all the jobs in the system to the topmost queue.

Scheduling Metrics Performance: turnaround time T turnaround = T completion − T arrival As T arrival is now 0, T turnaround = T completion Performance: response time T response = T firstrun − T arrival CPU utilization Throughput Fairness

A proportional-share or A fair-share scheduler Each job obtain a certain percentage of CPU time. Lottery scheduling tickets to represent the share of a resource that a process should receive If A 75 tickets, B 25 tickets, then 75% and 25% (probabilistically) A B A A B A A A A A A B A B A A A A A A higher priority => more tickets

Lottery Code int counter = 0; Int winner = getrandom(0, totaltickets); node_t *current = head; while(current) { counter += current->tickets; if (counter > winner) break; current = current->next; } // current is the winner

Lottery Fairness Study

Ticket currency User A 100 (global currency) -> 500 (A’s currency) to A1 -> 50 (global currency) -> 500 (A’s currency) to A2 -> 50 (global currency) User B 100 (global currency) -> 10 (B’s currency) to B1 -> 100 (global currency)

More on Lottery Scheduling Ticket transfer Ticket inflation Compensation ticket How to assign tickets? Why not Deterministic?

Stride Scheduling: a deterministic fair-share scheduler Deterministic but requires global state What if a new job enters in the middle

Scheduling Workload assumption Metrics MLFQ Lottery Scheduling and stride scheduling

Next Work on PA0 Reading: chapter 12-16

PA0

PA Step 2, `cs-status | head -1 | sed 's/://g'` Step 6, cs-console, OR (control-spacebar) 1..section.data.section.text.globl zfunction zfunction: pushl %ebp movl %esp, %ebp …. Leave ret Read In C, we count from 0http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax

PA0. 2,3, and 5 2.Try “man end” and see what you can get Use “kprintf” for output 3.Read “Print the address of the top of the run- time stack for whichever process you are currently in, right before and right after you get into the printos() function call.” carefully You can use in-line assembly Use ebp, esp 5.syscallsummary_start(): should clear all numbers syscallsummary_stop(): should keep all numbers

Others Know how to use VirtualBox? feel free to share