Beruflich Dokumente
Kultur Dokumente
Computer Science,
CS 519: Operating
Assumptions
Pool of jobs contending for the CPU
CPU is a scarce resource
Computer Science,
CS 519: Operating
Types of Scheduling
Were mostly
concerned with
short-term
scheduling
Computer Science,
CS 519: Operating
What Do We Optimize?
System-oriented metrics:
Processor utilization: percentage of time the processor is busy
Throughput: number of processes completed per unit of time
User-oriented metrics:
Turnaround time: interval of time between submission and
termination (including any waiting time). Appropriate for batch
jobs
Response time: for interactive jobs, time from the submission
of a request until the response begins to be received
Deadlines: when process completion deadlines are specified,
the percentage of deadlines met must be promoted
Computer Science,
CS 519: Operating
Design Space
Two dimensions
Selection function
Which of the ready jobs should be run next?
Preemption
Preemptive: currently running job may be
interrupted and moved to Ready state
Non-preemptive: once a process is in Running
state, it continues to execute until it terminates or it
blocks for I/O or system service
Computer Science,
CS 519: Operating
Job Behavior
Computer Science,
CS 519: Operating
Job Behavior
CPU
I/O-bound jobs
Jobs that perform lots of I/O
Tend to have short CPU bursts
CPU-bound jobs
Jobs that perform very little
I/O
Tend to have very long CPU
bursts
Disk
Computer Science,
CS 519: Operating
Computer Science,
CS 519: Operating
Process
Arrival
Time
Service
Time
Computer Science,
10
CS 519: Operating
Computer Science,
11
CS 519: Operating
Computer Science,
12
CS 519: Operating
Multilevel Queue
Ready queue is partitioned into separate queues:
foreground (interactive)
background (batch)
Computer Science,
13
CS 519: Operating
Computer Science,
14
CS 519: Operating
Computer Science,
15
CS 519: Operating
Computer Science,
16
CS 519: Operating
Scheduling
A new job enters queue Q0 which is served FCFS. When it gains
CPU, job receives 8 milliseconds. If it does not finish in 8
milliseconds, job is moved to queue Q1.
At Q1 job is again served FCFS and receives 16 additional
milliseconds. If it still does not complete, it is preempted and
moved to queue Q2.
Computer Science,
17
CS 519: Operating
Computer Science,
18
CS 519: Operating
20
35
user-mode execution
50
19
CS 519: Operating
20
CS 519: Operating
2load
ut
u ( t 1) niceFactor
(2load 1)
The system-wide load is the average number of runnable jobs
during last 1 second
Computer Science,
21
CS 519: Operating
+2 seconds
+N seconds
2
U1 U 0
3
2
2
2
2
2
U 2 U 1 U 0 U 1 U 0
3
3
3
3
2
2
2
Un Un 1 U n 2 ...
3
3
Computer Science,
22
CS 519: Operating
Scheduling Algorithms
FIFO is simple but leads to poor average response times. Short
processes are delayed by long processes that arrive before them
RR eliminate this problem, but favors CPU-bound jobs, which have
longer CPU bursts than I/O-bound jobs
SJN, SRT, and HRRN alleviate the problem with FIFO, but require
information on the length of each process. This information is not
always available (although it can sometimes be approximated based
on past history or user input)
Feedback is a way of alleviating the problem with FIFO without
information on process length
Computer Science,
23
CS 519: Operating
Computer Science,
24
CS 519: Operating
Lottery Scheduling
Randomized resource allocation mechanism
Resource rights are represented by lottery tickets
Have rounds of lottery
In each round, the winning ticket (and therefore the
winner) is chosen at random
The chances of you winning directly depends on the
number of tickets that you have
P[wining] = t/T, t = your number of tickets, T = total number of
tickets
Computer Science,
25
CS 519: Operating
Lottery Scheduling
After n rounds, your expected number of wins is
E[win] = nP[wining]
Computer Science,
26
CS 519: Operating
Implementation
Computer Science,
27
CS 519: Operating
Performance
Computer Science,
28
CS 519: Operating
Computer Science,
29
CS 519: Operating
Isolation
Five tasks running the Dhrystone
benchmark. Let amount.currency
denote a ticket allocation of amount
denominated in currency. Tasks
A1 and A2 have allocations 100.A and
200.A, respectively. Tasks B1 and B2
have allocations 100.B and 200.B,
respectively. Halfway thru experiment
B3 is started with allocation 300.B.
This inflates the number of tickets in B
from 300 to 600. Theres no effect on
tasks in currency A or on the aggregate
iteration ratio of A tasks to B tasks.
Tasks B1 and B2 slow to half their
original rates, corresponding to the
factor of 2 inflation caused by B3.
Computer Science,
30
CS 519: Operating
Computer Science,
31
CS 519: Operating
E A ( warpBack ?W : 0)
Threads accumulate virtual time as they run
Thread with earliest EVT is scheduled next
Computer Science,
32
CS 519: Operating
Computer Science,
33
CS 519: Operating
Computer Science,
34
CS 519: Operating
Computer Science,
35
CS 519: Operating
Computer Science,
36
CS 519: Operating
Computer Science,
37
CS 519: Operating
Computer Science,
38
CS 519: Operating
Computer Science,
40
CS 519: Operating
m1m2
Computer Science,
r2
41
CS 519: Operating
Spatial Domain
Quad-tree
Computer Science,
42
CS 519: Operating
3D Scene
Projection Plane
Dynamically
generated ray
Ray from
viewpoint to
upper right corner
pixel
Computer Science,
43
Viewpoint
CS 519: Operating
Partitioning
Need dynamic assignment
Use contiguous blocks to exploit spatial coherence among
neighboring rays, plus tiles for task stealing
A tile,
the unit of decomposition
and stealing
A block,
the unit of
assignment
Computer Science,
44
CS 519: Operating
Sample Speedups
Computer Science,
45
CS 519: Operating
Coscheduling (Gang)
Cooperating processes may interact frequently
What problem does this lead to?
46
CS 519: Operating
Coscheduling
What is coscheduling?
Coordinating across nodes to make sure that processes
belonging to the same process working set are
scheduled simultaneously
How might we do this?
Computer Science,
47
CS 519: Operating
Computer Science,
48
CS 519: Operating
Applications
Computer Science,
49
CS 519: Operating
Computer Science,
50
CS 519: Operating
Computer Science,
51
CS 519: Operating
Gang Scheduling
Computer Science,
52
CS 519: Operating
Computer Science,
53
CS 519: Operating
Multiprocessor Scheduling
Load sharing: poor locality; poor synchronization
behavior; simple; good processor utilization. Affinity
or per processor queues can improve locality.
Gang scheduling: central control; fragmentation
--unnecessary processor idle times (e.g., two
applications with P/2+1 threads); good
synchronization behavior; if careful, good locality
Hardware partitions: poor utilization for I/O-intensive
applications; fragmentation unnecessary processor
idle times when partitions left are small; good locality
and synchronization behavior
Computer Science,
54
CS 519: Operating