1 / 18

Process Scheduling

Process Scheduling. Murali P. Dispatch. Admit. Exit. Terminate. New. Ready. Running. Time out. Event Occurs. Event Wait. Blocked. Processor Utilization. How to ensure that some process is always in running state? How are processes selected for execution?

clove
Download Presentation

Process Scheduling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Process Scheduling Murali P

  2. Dispatch Admit Exit Terminate New Ready Running Time out Event Occurs Event Wait Blocked Processor Utilization • How to ensure that some process is always in running state? • How are processes selected for execution? • What processes are coming for execution? • When processes enter states?

  3. Alternating Sequence of CPU And I/O Bursts

  4. Histogram of CPU-burst Times

  5. Behavior of processes • CPU bound processes • Having lots of computations • Determine the factorial of a 30-digit number • I/O bound processes • Having a lot of I/O operations • Copying a movie from CD to hard disk • Real world applications have a mix of CPU bursts and I/O operations

  6. Dispatch Admit Exit Terminate New Ready Running Time out Event Occurs Event Wait Blocked CPU Scheduler • Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them • CPU scheduling decisions : • Scheduling • Non-preemptive • Preemptive

  7. Required Features • CPU is busy full time • Ensure some process is running all time • Or, Squeeze as many processes as possible into CPU • User program gets to execute as soon as it is given • Overall, a process does not run more than what it should have taken • User gets response without too much delay • ???

  8. Scheduling Criteria • CPU utilization • keep the CPU as busy as possible • Throughput • # of processes that complete their execution per time unit • Turnaround time • time to execute a particular process • Waiting time • time that a process has been waiting in the ready queue • Response time • time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

  9. Optimization Criteria • Max CPU utilization • Max throughput • Min turnaround time • Min waiting time • Min response time

  10. Traditional classification of Schedulers • Long-term scheduler • Responsible for ensuring nice mix of CPU bound and I/O bound processes • Choosing New processes • New  Ready/Suspended • Medium-term scheduler • Tune degree of multi-programming • Swapping • Short-term scheduler • Improve response time, TAT, WT, …

  11. Dispatcher • Dispatcher module : • switching context • switching to user mode • jumping to the proper location in the user program to restart that program • Dispatch latency • time it takes for the dispatcher to stop one process and start another running • Must be very fast; with very efficient data structures

  12. P1 P2 P3 0 24 27 30 First-Come, First-Served (FCFS) Scheduling ProcessBurst Time Arrival Time P1 24 0 P2 3 1 P3 32 The Gantt Chart for the schedule is: • Waiting time for P1 = 0; P2 = 23; P3 = 25 • Average waiting time: (0 + 23 + 25)/3 = 16

  13. P2 P3 P1 0 3 6 30 FCFS Scheduling ProcessBurst Time Arrival Time P1 24 2 P2 3 0 P3 31 • Suppose the order of arrival : P2 , P3 ,P1The Gantt Chart for the schedule is: • Waiting time for P1 = 4; P2 = 0; P3 = 2 • Average waiting time: (4 + 0 + 2)/3 = 2 • Convoy Effect

  14. Shortest Job First (SJF) • Chooses the job with shortest next CPU burst • Some estimation mechanism used • Eg, tn+1= a bn + (1-a) tn (Exponential Average) • Types • Non-preemptive • Preemptive • Shortest Remaining Time First (SRTF)

  15. P1 P3 P2 P4 0 3 7 8 12 16 Example of Non-Preemptive SJF Process Arrival TimeBurst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (non-preemptive) • Average waiting time = (0 + 6 + 3 + 7)/4 = 4

  16. P1 P2 P3 P2 P4 P1 11 16 0 2 4 5 7 Example of Preemptive SJF Process Arrival TimeBurst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (preemptive) • Average waiting time = (9 + 1 + 0 +2)/4 = 3

  17. Prediction of the Length of the Next CPU Burst • Prediction not always correct • Better prediction algorithms  Slower Dispatcher • What if the big task preempted was important? • Quantify sense of importance

  18. Priority Scheduling • A priority number (integer) is associated with each process • The CPU is allocated to the process with the highest priority (smallest integer  highest priority) • Preemptive • nonpreemptive • SJF is a priority scheduling where priority is the predicted next CPU burst time • Problem  Starvation – low priority processes may never execute • Solution  Aging – as time progresses increase the priority of the process

More Related