240 likes | 460 Views
CS 514 Operating Systems. Uniprocessor Process Management & Process Scheduling. Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu. Process_Management/000. Uniprocessor Process Management.
E N D
CS 514 Operating Systems Uniprocessor Process Management & Process Scheduling Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu Process_Management/000
Uniprocessor Process Management Process scheduling Because it has significant impact to the following performance factors: Throughput Response time Resource utilization Turnaround time Fairness CS 514 Operating Systems • Core of process management • Process scheduling = Decision-making for when to start (and stop) processes • Why is process scheduling important? (especially processor utilization) (we can measure this as “customer satisfaction”) Process_Management/001
Throughput Throughput = Number of jobs completed in unit time 25 25 9 9 9 9 9 9 9 9 9 9 P1 P1 P7 P7 P4 P4 P14 P11 P12 P14 P11 P12 4 4 4 4 4 4 4 4 4 4 15 15 15 15 15 15 P6 P9 P3 P2 P8 P3 P6 P8 P9 P2 P10 P13 P10 P5 P13 P5 If all tasks submitted here 135 126 25 29 111 33 102 42 93 61 57 74 70 78 6 jobs / Minute 5 jobs / Minute CS 514 Operating Systems Process_Management/002
Response Time Response Time =The time since submission until the first response appears 25 25 9 9 9 9 9 9 9 9 9 9 P1 P1 P4 P14 P7 P7 P11 P12 P14 P4 P11 P12 4 4 4 4 4 4 4 4 4 4 15 15 15 15 15 15 P9 P8 P2 P6 P8 P3 P9 P3 P6 P2 P5 P13 P13 P10 P5 P10 If all tasks submitted here 126 0 25 29 111 33 102 42 93 61 57 74 70 78 CS 514 Operating Systems Process_Management/003
Resource Utilization (processor utilization) 5 5 7 10 5 Processor is used for n seconds n 3 3 6 2 12 Process 2 Process 3 Process 3 Process 2 Process 1 Process 1 Processor is NOT used for m seconds m 3 2 10 3 3 6 2 12 5 5 7 10 5 73 51 3 2 10 Utilization = 51/73 = 69.9% CS 514 Operating Systems Process_Management/004
Turnaround Time 25 25 9 9 9 9 9 9 9 9 9 9 P1 P1 P7 P11 P14 P4 P14 P12 P7 P12 P4 P11 4 4 4 4 4 4 4 4 4 4 15 15 15 15 15 15 P3 P8 P6 P6 P2 P9 P3 P2 P8 P9 P10 P5 P13 P5 P10 P13 If all tasks submitted here 135 126 25 29 111 33 102 42 93 61 57 74 70 78 CS 514 Operating Systems Turnaround Time = The time since submission to completion for each process Process_Management/005
Fairness Will result in unfairness Will result in starvation for low-priority tasks CS 514 Operating Systems • Reasonable resource allocation to each task (or process) • Meaning of “fairness” depends on each system If some tasks are high-priority tasks Assigning exactly the same resource to all tasks If all the tasks have exactly the same priority Each task should be assigned the same amount of resource If some tasks have lower priority Assigning more resource to high-priority tasks Process_Management/006
Three Different Layers of Process Scheduling Long-term Scheduling Short-term Scheduling Medium-term Scheduling CS 514 Operating Systems • The scheduler invoked when a new process is started • by a human user or by another process already active • The scheduler that assigns a (the) processor to the processes • ready to run in the memory • The scheduler that is performed to the ready processes to temporarily • swap them out of the memory (to make them temporarily inactive) Process_Management/007
Long-Term Scheduling Your program must be in memory for the processor to execute it Computer System Multitasking requires multiple processes ready (waiting) in the memory User(s) CS 514 Operating Systems Processor Main Memory Two reasons your request to start a new process can be rejected: Your system does not have enough memory to hold more process Process_Management/008
Long-Term Scheduling GDI (Graphic Device Interface) USER (USER Resource) SYS (SYSTEM Resource) CS 514 Operating Systems
Long-Term Scheduling Your program must be in memory for the processor to execute it Computer System Multitasking requires multiple processes ready (waiting) in the memory Long-term Schedule Queue User(s) CS 514 Operating Systems Processor Main Memory Two reasons your request to start a new process can be rejected: Your system does not have enough memory to hold more process Process_Management/010
Long-Term Scheduling Computer System Process Completed User(s) CS 514 Operating Systems Processor Main Memory Two reasons your request to start a new process can be rejected: Your system does not have enough memory to hold more process Process_Management/010
Long-Term Scheduling Computer System User(s) CS 514 Operating Systems Processor Main Memory Two reasons your request to start a new process can be rejected: Degree of multitasking exceeds its limit and thrashing is happening Process_Management/012
Degree of Multitasking and Thrashing 5 4 3 3 2 5 5 7 10 5 Processor is used for n seconds n Process 3 Process 2 Process 4 Process 3 Process 2 Process 1 Process 1 This is “short-term scheduling” Processor is NOT used for m seconds m 3 2 10 5 5 7 10 5 1 3 1 2 5 3 2 3 2 5 3 Number of processes ready in the memory 2 = “Degree of multitasking” CS 514 Operating Systems Utilization = 17/32 = 53.1% Utilization = 29/34 = 85.2% Utilization = 42/44 = 95.5% Process_Management/013
A D C B Multiprogramming & Timesharing A user user user user B C D E CPU Program Loader CS 514 Operating Systems Multiprogramming and Timesharing OS User Programs Computer System Memory Process_Management/014
Degree of Multitasking and Thrashing Switching Processes Service time (Time Slice) • All registers in the • processor must be • saved user user user user user user CS 514 Operating Systems Process_Management/015
Degree of Multitasking and Thrashing Switching Processes If we try to keep the response time for each user same, the service time (time slice) for each user must shrink user user user user user user Response Time CS 514 Operating Systems Process_Management/016
Degree of Multitasking and Thrashing Thrashing = A situation where most of the processor cycles are used for just switching between processes but not for processing them Thrashing Throughput Long-term scheduling controls degree of multitasking so that thrashing will not happen Degree of Multitasking (High) CS 514 Operating Systems Process_Management/017
Long-Term Scheduling Long-term Scheduling Computer System User(s) CS 514 Operating Systems Processor Main Memory Process_Management/018
Short-term Scheduling Throughput Response time (especially processor utilization) Resource utilization Turnaround time (we can measure this as “customer satisfaction”) Fairness Usually each short-term scheduling algorithm has the highest priority performance factor to optimize, the algorithms can not ignore others CS 514 Operating Systems • The scheduler schedules assignments of the processor to each process to • optimize some performance factor(s) Process_Management/019
Response Time 25 25 9 9 9 9 9 9 9 9 9 9 P1 P1 P14 P4 P14 P12 P11 P12 P4 P11 P7 P7 126 0 25 29 111 33 102 42 93 61 57 74 70 78 4 4 4 4 4 4 4 4 4 4 15 15 15 15 15 15 P8 P3 P6 P9 P9 P2 P6 P3 P2 P8 P13 P10 P13 P5 P5 P10 If all tasks submitted here 29 12 47 110 16 20 38 56 80 95 65 4 8 Optimized Average Response Time Average Response Time CS 514 Operating Systems Response Time =The time since submission until the first response appears = 901/14 = 64.35 = 580/14 = 41.28 • Average Response Time • What did we loose ? Process_Management/020
Short-term Scheduling Preemptive FCFS (a.k.a. “FIFO”) Round-Robin SJF (a.k.a. “SPN”) Non-Preemptive SRTF (Shortest Remaining Time First) HRRN (Highest Response Rate Next) Priority-based (Highest Priority First) Feed-back CS 514 Operating Systems Major existing short-term scheduling algorithms: Process_Management/021
Another process is selected for execution Process is making I/O accesses Three Different Layers of Process Scheduling I/O access is completed System does not have enough resources Selected for execution System has enough resources System has enough resources user Processor Running New Blocked Ready Blocked Completed CS 514 Operating Systems Process_Management/020
Three Different Layers of Process Scheduling System does not have enough resources user Medium-term Scheduling Processor Running Short-term Scheduling New Blocked Ready Blocked Long-term Scheduling Completed CS 514 Operating Systems Process_Management/021