Computer Science 111: Operating Systems
By Jeremy Cabrido
and Adrian Lee


Scheduling
Simple scheduler:
First Come First Server
assume 1 CPU
Jobs Arrival Run wait
  Time    
A 0 5 0+δ
B 1 2 4+2δ
C 2 9 5+3δ
D 3 4 13+4δ
AAAAABBCCCCCCCCCDDDD
utilization is almost 1: 20/20+48
avg wait time = 5.5 + 2.58
avg turnaround time = 10.5+2.58

Shortest Job First
AAAAA | BB | DDDD | CCCCCCCCC
  wait
A 0+ δ
B 4+2 δ
C 9+4 δ
D 4+3 δ
average wait time 4.25+2.58

Utilization = same as before

Let's add preemption
SJF + preemption
| A | BB | DDDD | AAAA | CCCCCCCCC
average wait = (δ + 2 δ + (9+5 δ) + 3 δ)/4 = 2.25 + 2.5 δ
average runtime = 2.25+2.5 δ + 5 + (6+3 δ) /4

standard deivation of wait
worst case of run
Fairness

FCFS + preemption = round robin (RR)
A | B | C | D |A | B | C | D |A | C | D | A | C | D | A | CCCCC
buggy!
average wait time = δ + 2 δ + 3 δ + 4 δ = 2.5 δ
average turnaround = (15 + 15 δ) + (5 + 5 δ) + (18 + 14 δ) + (11 + 11 δ) = 12.25 + 11.25 δ

Priorities set by user or by system
FCFS: priority = - arrival time
SJF: priority = - runtime

realtime scheduling
constraints that must be a hit, or else
hard realtime (brakes, nuclear reactors)
soft realtime (if you miss deadline, you drop that task)
earliest meetable deadline first
rate - monotonic scheduling

Mars Rover
3 priorities
low medium high
lock (&m)   lock(&m)
start run start up  
unlock(&m)    

Priority Invasion

More Scheduling
1 CPU
1 disk - many I/O requests, which to do 1st?
expensive to seek + rotational latency

Simple abstraction
cost to access = | i - h |
i: desired location
h: read head

simple disk scheduler
FCFS:
- lot of seeking
+ no starvation
average seek time (assume random I/O) = image for the integration

SSTF (Shortest Seek Time First)
+ minimize seek time
+ maximizes troughtput
- more CPU time
- starvation

FCFS (batches) + SSTF (within a batch)

Elevator scheduling
SSTF in a positive direction

Cyclic elevator scheduling

Anticipatory scheduling
TA 0,1,2,3
TB 1000000, 1000001, 1000002
DALLYING
minimize seeks by guessing future requests
-seek time increase with wrong guesses

Cloud Computing Intro
Advantages

Problems / Issues
- payment
(OS must meter activities in a way that both customer and the supplier trust)
- resource management
- Security
Data confidentiality
Standard techniques:
encrypted connections to cloud
encrypt all files in the cloud
TRUST
Reflections on trusting trust
- Software licensing
- Data transfer bottlenecks

login.c
if (user = "n" ) become root;

cc.c
if (compiliing login.c) insert login bug
if (comiling cc.c) insert another bug