Transcript oct28

CS 101 – Oct. 28
• Operating Systems (continued)
–
–
–
–
Process states √
Scheduling processes on the CPU
System load
Types of OS
Process scheduling
• Extensively studied in CS !
• Look carefully at examples pp. 340-342.
• 3 common techniques
– Round robin (we saw this one already)
– First-come, first-served
– Shortest Job Next
Scheduling
• Round-robin
– Fair: give each process an equal time quantum.
– Usually not long enough to finish, so pre-empt. Preemption incurs some overhead, so there are alternative
strategies:
• First-come first served
– Do the tasks in the order in which they are requested
• Shortest job next
– Try to minimize the average completion time. Do the
easy/short tasks first.
Measuring a schedule
• To tell how good a schedule is, we can compute
the average turnaround time.
– People are usually interested in how long it takes for
their jobs to get done.
– Turnaround time = (time @ finish – time @ request)
Example
Process number
Time of request (ms)
Execution time needed
1
0
20
2
5
30
3
10
40
4
20
10
First-come, first-served:
Process 1 can execute from t=0 to t=20
Process 2, t=20 to t=50
Process 3, t=50 to t=90
Process 4, t=90 to t=100
What is the average turnaround time?
Examples
Process number
Time of request (ms)
Execution time needed
1
0
20
2
5
30
3
10
40
4
20
10
Process number
Time of request (ms)
Execution time needed
1
0
10
2
30
30
3
40
20
4
50
5
System load
• A measure to show how “busy” the CPU is
• At an instant: how many tasks are currently
running or ready
– If load > 1, we have “overloaded” system, and work is
starting to back up. Should stop requesting more jobs.

• Typically reported as an average over the last 1, 5
or 15 minutes.
Cutting Edge
• Real-time OS
– Assumes all jobs have deadlines
• High Performance Computing
– Using multiple CPUs at once
– Technique is called “parallel processing”
• Distributed OS
– Your running program and/or files may be on a
different machine