Traditional Unix Scheduling - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Traditional Unix Scheduling

Description:

Round robin in the same priority queue. Same time quantum to different priority queues ... Current scheduling priority (pri) Used to decide which process to schedule. ... – PowerPoint PPT presentation

Number of Views:1046
Avg rating:3.0/5.0
Slides: 15
Provided by: Informatio358
Category:

less

Transcript and Presenter's Notes

Title: Traditional Unix Scheduling


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 lt sleep
    priority lt 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
admitted
Dispatched to a CPU
activated
Ready,Suspended
Ready
Running
Terminated
exit
Suspended
interrupted
Event completion
I/O or event wait
Blocked
Blocked,Suspended
activated
Suspended
  • 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.

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
  • 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.
  • 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.

7
An Example
DR 1/2 PUSER 50 nice 0 3 processes in
the same priority band Time quantum/process 1
sec
8
4.3BSD Scheduler
dispatched
  • 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
Run Queue 1
Run Queue 31
  • 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.

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 lt Wk lt 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
50 0 0 1 1
2 2 100 100
100 50 50
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
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
75 50
56 12 13 112
62 25
4 sec
78 56
56 12 13 112
62 25
Write a Comment
User Comments (0)
About PowerShow.com