download

Matakuliah
Tahun
Versi/Revisi
: T0316/sistem Operasi
: 2005
:5
Pertemuan 8
Penjadwalan (lanjutan)
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• mendemonstrasikan penjadwalan proses pada
sistem interactive, real-time, dan thread (C3)
2
Outline Materi
• Interactive Scheduling:
–
–
–
–
–
–
–
Round Robin Scheduling
Penjadwalan dengan prioritas
Multiple Queues
Shortest process next
Guaranteed Scheduling
Lottery Scheduling
Fair-share Scheduling
• Penjadwalan pada sistem Real-time
• Policy versus Mechanism
• Penjadwalan Thread
3
Scheduling in Interactive Systems (1)
• Round Robin Scheduling
– list of runnable processes
– list of runnable processes after B uses up its quantum
• Each process is assigned a time interval, called quantum
• Process switch or context switch  times to do switching
4
Scheduling in Interactive Systems (2)
Priority scheduling
• Each process is assigned a priority, and the runnable process with the
highest priority is allowed to run
• The scheduler may decrease the priority of currently running process
• Priority scheduling is used among classes and round-robin scheduling
within each class
5
Scheduling in Interactive Systems (3)
Multiple Queues
• Priority class of queuing processes
• Quantum given: 1, 2, 4, 8, 16 …
Why?
To reduce swapping
i.e. long CPU-bound process eventually get large quantum
short, interactive process get small quantum
Example:
Process with quantum 100
Quantum given: 1, 2, 4, 8, 16, 32, 64 (used 37)  only 7 swap
6
Scheduling in Interactive Systems (4)
Shortest process next
• Need to estimate the time of the next processes
i.e. aT0 + (1a)T1
where T0 is the estimated time of the first command
T1 is that of the next command
…
• With a = ½, add the new value to the current estimate and divide
the sum by 2
Estimates:
T0 , T0/2+ T1/2 , T0/4+ T1/4+ T2/2, T0/8+ T1/8+ T2/4+ T3/2
7
Scheduling in Interactive Systems (5)
Guaranteed Scheduling
• On a single user system with n processes running, each one
should get 1/n of the CPU cycles
• Ratio of 0.5 means that process only had half of what it should
have had
• Ratio of 2.0 means that process has had twice as much as it was
entitled to
8
Scheduling in Interactive Systems (6)
Lottery Scheduling
Simpler implementation
Give process lottery tickets for various system resources,
such as CPU time
A lottery ticket is chosen at random, but the process
holding more tickets gets better chance to be chosen
Can be used to solve problems that are difficult to handle
with other methods
Eg. Video server with several process at different frame rates
9
Scheduling in Interactive Systems (7)
Fair Share Scheduling
Take into account who owns a process
Each user is allocated some fraction of the CPU
Thus, if 2 users have been promised 50% of the CPU, they will
each get that, no matter how many processes they have
Example:
User 1 has 4 processes: A, B, C, D
User 2 has 1 process: E
If both users are promised 50% of CPU time, the possible scheduling
sequence would be
AEBECEDEAE…
if user 1 entitled twice as much CPU time as user 2, we might get:
ABECDEABECDE…
10
Scheduling in Real-Time Systems
Schedulable real-time system
• Given
– m periodic events
– event i occurs within period Pi and requires Ci seconds
• Then the load can only be handled if
m
• Example:
Ci
1

i 1 Pi
– A soft real time system with three periodic event, with periods of 100,
200, and 500 ms. If these events require 50, 30, and 100 ms of CPU
time per event  the system is schedulable because
0.5 + 0.15 + 0.2 < 1
11
Policy versus Mechanism
• Separate what is allowed to be done with how
it is done
– a process knows which of its children threads are
important and need priority
• Scheduling algorithm parameterized
– mechanism in the kernel
• Parameters filled in by user processes
– policy set by user process
12
Thread Scheduling (1)
Possible scheduling of user-level threads
• 50-msec process quantum
• threads run 5 msec/CPU burst
13
Thread Scheduling (2)
Possible scheduling of
kernel-level threads
• 50-msec process quantum
• threads run 5 msec/CPU burst
14