1 / 14

Traditional Unix Scheduling

Traditional Unix Scheduling. “Traditional” means No consideration on realtime processes. Typically 4.3BSD and SVR3 MFQ-based Preemptive (time quantum based) Round robin in the same priority queue Same time quantum to different priority queues Dynamic priority assignment Priority

duncan-day
Download Presentation

Traditional Unix 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. Traditional Unix Scheduling • “Traditional” means • No consideration on realtime processes. • Typically 4.3BSD and SVR3 • MFQ-based • Preemptive (time quantum based) • Round robin in the same priority queue • Same time quantum to different priority queues • Dynamic priority assignment • Priority • Integer value between 0 and 127 • Numerically lower values correspond to higher priorities. • Priorities between 0 and 49 are reserved for the kernel • Priorities between 50 and 127 are for user-level programs

  2. PCB: the most important data structure in an OS • Process identification • PID • CPU state information • The contents of CPU registers • Program counter • Indicates the address of the next instruction to be executed. • Process control information • Event that a process is waiting on. • I/O status (e.g., open files) • Scheduling info Process Image Process Control Block User Program User Data/Stack Kernel Stack

  3. PCB contains, as process scheduling info, Current scheduling priority (pri) User mode priority (usrpri) Measure of recent CPU utilization (cpu) Nice value (user-controllable adjustment factor; nice) Current scheduling priority (pri) Used to decide which process to schedule. Same as user mode priority (usrpri), when a process is in user mode. Goes down to place higher priority to kernel mode processing upon I/O completion. Down to a predefined priority (0 =< sleep priority =< 49). 10 for file access 20 for disk I/O This enables a prompt I/O completion (a prompt completion of system call). Replaced with the current user mode priority (usrpri) when it is back in use mode.

  4. 7-State Process Behavior Model New • Ready: The process is in main memory and available for execution. • Blocked: The process is in main memory and blocked on an event. • Blocked, suspended: The process is in virtual memory and blocked on an event. • Ready, suspended: The process is in virtual memory but is available for execution as soon as it is loaded to main memory. admitted Dispatched to a CPU activated Ready,Suspended Ready Running exit Terminated Suspended interrupted Event completion I/O or event wait Blocked Blocked,Suspended activated Suspended

  5. User mode priority (usrpri) Depends two factors: Recent CPU utilization (cpu) Nice value (nice) CPU utilization Initialized to 0 when a process is created. Incremented (for the currently-running process) at every clock interrupt. 10 msec Nice value An integer value between 0 and 39 The default value is 20. Increasing this value decreases the priority. Only OS administrators can decrease it. The nice command is used to change the nice value for each process. Accepts -20 to 19 as an increment to the current value.

  6. cpuj(i) • CPU utilization by process j through interval i. • Unit time for i: 10 msec. • DR: decay rate • cpuj is reduced by a decay rate. • 1/2 in SVR3. • PUSER (baseline priority): 50 • used to divide processes into fixed bands of priority levels. • Every second, user mode priority (usrpri) is updated as follows:

  7. An Example Process 1 usrpri cpu Process 2 usrpri cpu Process 3 usrpri cpu Time 0 50 0 1 2 100 50 0 50 0 10 ms 20 ms 1 sec 75 50 50 0 1 2 100 50 0 2 sec 62 25 75 50 50 0 1 2 100 3 sec 56 12 13 112 75 50 62 25 4 sec 78 56 56 12 13 112 62 25 DR: 1/2 PUSER: 50 nice: 0 3 processes in the same priority band Time quantum/process: 1 sec

  8. 4.3BSD Scheduler 32 run (ready) queue A queue for 4 adjacent priorities RQ0 for priorities 0 to 3 RQ1 for priorities 4 to 7 RR in each RQ RR time quantum: 100 msec The highest-priority process is always scheduled first in each RQ. MFQ across RQs If all other ready processes are on lower RQs, the current process continues to run even if its quantum has expired. Priority update Once every second Process promotion and demotion across RQs Timing of context switches The current process blocks on a resource or exits. Voluntary context switch RR-based preemption Priority-based preemption I/O (event) completion dispatched Run Queue 0 CPU admitted Run Queue 1 Run Queue 31

  9. HW • The decay factor used in 4.3BSD is: • LoadAverage • The average number of ready processes over the last second. • Discuss how this decay factor impacts process scheduling. • Compare the scheduling algorithms in SVR3 and 4.3BSD.

  10. Considering Process Groups • In traditional Unix scheduling, • A priority is assigned per process. • Processes compete for CPU time. • What about a group of processes? • Processes created by each application • Processes created by each user • Processes in the same session (or job) • ps -j • ps -Aj

  11. Fair Share Scheduling (FSS) Group-aware priority assignment Group: application, user or session Assigns the same/similar priority (share of the CPU) to the processes in the same group Give fewer CPU time to processes that have had more than their fair share Give more CPU time to processes that have had less than their fair share. Considers the CPU utilization history of a group of processes along with the CPU utilization history of individual processes. e.g., 25% share of the total CPU time, when there are 4 groups. Can assign different priorities to different groups Foreground and background processes OS administrators, normal users and guests An extension to the traditional Unix scheduler.

  12. Every second, user mode priority (usrpri) is updated as follows: • cpuj(i) • CPU utilization by process j through interval i. • Unit time for i: 10 msec. • gcpuj(i) • CPU utilization by group k through interval i. • DRp DRg: decay rate • cpuj and cpuk are reduced by DRp and DRg, respectively. • PUSER (baseline priority): • The default value: 50 • Wk: weight assigned to group k. • 0 < Wk < 1 and

  13. An Example Group 1 Group 2 Process 1 usrpri cpu gcpu Process 2 usrpri cpu gcpu Process 3 usrpri cpu gcpu Time 0 50 0 0 1 1 2 2 100 100 50 0 0 50 0 0 10 ms 20 ms 1 sec 100 50 50 50 0 0 1 1 2 2 100 100 50 0 0 1 2 100 DRp, DRg: 1/2 PUSER: 50 W1 and W2: 1/2 3 processes in the same priority band P1 is in Group 1 P2 and P3 in Group 2 Time quantum/process: 1 sec 2 sec 74 25 25 125 125 100 50 50 75 0 50 3 sec 112 62 62 74 25 25 125 62 0 25 100 125 4 sec 80 31 31 131 131 87 12 62 106 50 62 5 sec

  14. Group 1 Group 2 Process 1 usrpri cpu gcpu Process 2 usrpri cpu gcpu Process 3 usrpri cpu gcpu 50 0 0 1 1 2 2 100 100 50 0 0 50 0 0 100 50 50 50 0 0 1 2 100 50 0 0 1 1 2 2 100 100 74 25 25 125 125 100 50 50 75 0 50 112 62 62 74 25 25 125 62 0 25 100 125 80 31 31 131 131 87 12 62 106 50 62 Traditional Unix Scheduling Fair Share Scheduling Process 1 Usrpri cpu Process 2 usrpri cpu Process 3 usrpri cpu Time 0 50 0 1 2 100 50 0 50 0 10 ms 20 ms 1 sec 75 50 50 0 1 100 50 0 2 sec 62 25 75 50 50 0 1 100 3 sec 56 12 13 112 75 50 62 25 4 sec 78 56 56 12 13 112 62 25

More Related