Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum.

Similar presentations


Presentation on theme: "1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum."— Presentation transcript:

1 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 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 Control Block User Program User Data/Stack Kernel Stack Process Image

3 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 4 7-State Process Behavior Model 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. Ready, Suspended ReadyRunningTerminated Blocked activated Dispatched to a CPU interrupted I/O or event wait Event completion exit Blocked, Suspended Suspended New admitted activated

5 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 6 cpu j (i) –CPU utilization by process j through interval i. –Unit time for i: 10 msec. DR: decay rate –cpu j 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 7 An Example DR: 1/2 PUSER: 50 nice: 0 3 processes in the same priority band Time quantum/process: 1 sec Process 1 usrpri cpu Process 2 usrpri cpu Process 3 usrpri cpu Time 0 1 sec 2 sec 3 sec 4 sec 500 1 2 100 500 500 7550 500 1 2 100 500 6225 7550 500 1 2 100 7550 5612 13 112 6225 7856 6225 5612 13 112 10 ms 20 ms

8 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 CPU Run Queue 0 admitted dispatched Run Queue 1 Run Queue 31

9 9HW 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 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 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 12 cpu j (i) –CPU utilization by process j through interval i. –Unit time for i: 10 msec. gcpu j (i) –CPU utilization by group k through interval i. DR p DR g : decay rate –cpu j and cpu k are reduced by DR p and DR g, respectively. PUSER (baseline priority): –The default value: 50 W k : weight assigned to group k. –0 < W k < 1 and Every second, user mode priority (usrpri) is updated as follows:

13 13 An Example DR p, DR g : 1/2 PUSER: 50 W 1 and W 2 : 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 Time 0 1 sec 2 sec 3 sec 4 sec 10 ms 20 ms 5 sec Process 1 usrpri cpu gcpu 50 0 0 1 1 2 2 100 100 50 0 0 1 1 2 2 100 100 106 50 62 Process 2 usrpri cpu gcpu Process 3 usrpri cpu gcpu 50 0 0 50 0 0 100 50 50 Group 1Group 2 50 0 0 1 2 100 74 25 25 125 125 100 50 50 75 0 50 112 62 62 74 25 25 125 62 0 25 100 125 87 12 62 80 31 31 131 131

14 14 Process 1 Usrpri cpu Process 2 usrpri cpu Process 3 usrpri cpu Time 0 1 sec 2 sec 3 sec 4 sec 500 1 2 100 500 50 0 7550 50 0 1 100 50 0 6225 7550 500 1 100 7550 5612 13 112 6225 7856 6225 5612 13 112 10 ms 20 ms Process 1 usrpri cpu gcpu 50 0 0 1 1 2 2 100 100 50 0 0 1 1 2 2 100 100 106 50 62 Process 2 usrpri cpu gcpu Process 3 usrpri cpu gcpu 50 0 0 50 0 0 100 50 50 Group 1Group 2 50 0 0 1 2 100 74 25 25 125 125 100 50 50 75 0 50 112 62 62 74 25 25 125 62 0 25 100 125 87 12 62 80 31 31 131 131 Traditional Unix SchedulingFair Share Scheduling


Download ppt "1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum."

Similar presentations


Ads by Google