710 likes | 848 Views
4330/6310 FIRST ASSIGNMENT Spring 2014. Jehan-François Pâris jfparis@uh.edu. C. C. C. C. D Q. R Q. I Q. TTYs. Disk. The model. We have one quad-core CPU one disk many TTYs A total of three queues CPU queue for RT processes CPU queue for interactive processes Disk queue.
E N D
4330/6310 FIRST ASSIGNMENTSpring 2014 Jehan-François Pârisjfparis@uh.edu
C C C C D Q RQ IQ TTYs Disk The model We have • one quad-core CPU • one disk • many TTYs A total of three queues • CPU queue for RT processes • CPU queue for interactive processes • Disk queue
Why two CPU queues? • To favor Real-Time (RT) processes • When all four cores are busy, there may be RT and interactive processes waiting for the CPU • When one or more cores become free, no interactive process will get CPU time until no real-time processes remain in the RT queue • Actual operating systems use much more sophisticated algorithms
Start: P0 arrives at t = 0 ms C C C C D Q RQ IQ TTYs Disk INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
Your program will display • Process 0 startsTime = 0msClass = INTERACTIVE or • INTERACTIVE process 0 starts at t = 0ms
Process 0 grabs a core C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy until t = 10ms INTERACTIVE 0RUN 10TTY 1000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy until t = 10ms INTERACTIVE 0RUN 10TTY 1000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P1 arrives at t = 5ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy until t = 10msSecond core busy until t = 25ms INTERACTIVE 0RUN 10TTY 1RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
Your program will display • Process 1 startsTime = 5msClass = REAL-TIME or • REAL-TIME process 1 starts at t = 5ms
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy until t = 10msSecond core busy until t = 25ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P0 releases core at t = 10ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk Second core busy until t = 25ms P0 waits until t = 10010ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk Second core busy until t = 25ms P0 waits until t = 10010ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P1 releases core at t = 25ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk P0 waits until t = 10010msDisk busy until t = 25 + 10 = 35 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First process waits until t = 10010 msDisk busy until t = 25 + 10 = 35 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P1 releases disk at t = 35ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First process waits until t = 10010 msFirst core busy until t = 35 + 40 = 75 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First process waits until t = 10010 msFirst core busy until t = 35 + 40 = 75 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P1 terminates at t = 75 ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First process waits until t = 10010 ms
Your program will display • Process 1 terminatesTime = 75msClass = REAL-TIME or • REAL-TIME process 1 terminates at t = 75ms
P1 terminates at t = 75 ms C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First process waits until t = 10010 ms
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First process waits until t = 10010 ms
P0 returns from TTY wait C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy untilt = 10010 + 30 = 10040 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C C C C C D Q D Q IQ RQ IQ RQ TTYs TTYs Disk Disk First core busy untilt = 10010 + 30 = 10040 ms INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P0 terminates at t =10040 ms C C C C C C C C D Q D Q RQ IQ IQ RQ TTYs TTYs Disk Disk INTERACTIVE 0RUN 10TTY 10000RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
Your program will display (I) • Process 0 terminatesTime = 10040msClass = INTERACTIVE or • INTERACTIVE process 0 terminates at t = 10040ms
Your program will display (II) • SUMMARY:Number of RT processes that completed: 1Percentage of RT processes that missed their deadline: 0%Number of interactive process that completed: 1Total number of disk accesses: 1Average disk access time: 10msTotal elapsed time: 10040msCPU utilization: 0.01Disk utilization: 0.001
How to compute CPU utilization • Keep track of total time for all RUN requests: • 10 + 30 + 20 + 40 =100ms • Divide by elapsed time: • 100/10040 = 0.01 (rounded) • Since there are four cores, maximum utilization is 4.0
How to compute disk utilization • Keep track of total time for all DISK requests: • 10ms • Divide by elapsed time: • 10/10040 = 0.001 (rounded) • Disk utilization is generally computed for each individual disk, so it will never exceed 1.0
Start: P0 arrives at t = 0 ms C C C C D Q RQ IQ TTYs Disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First core busy until t = 20 ms
What happens next? C C C C D Q RQ IQ TTYs Disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First core busy until t = 20 ms
P1 arrives at time t = 5ms C C C C D Q RQ IQ TTYs Disk First core busy until t = 20 msSecond core busy until t = 25 ms REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What happens next? C C C C D Q RQ IQ TTYs Disk First core busy until t = 20 msSecond core busy until t = 25 ms REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P0 releases core at t = 20ms C C C C D Q RQ IQ TTYs Disk Second core busy until t = 25 ms Disk busy until t = 20 + 10 = 30ms REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What is next? C C C C D Q RQ IQ TTYs Disk Second core busy until t = 25 ms Disk busy until t = 20 + 10 = 30ms REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P1 releases core at t = 25ms C C C C D Q RQ IQ TTYs Disk Disk busy until t = 20 + 10 = 30ms P1 waits for disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
What is next? C C C C D Q RQ IQ TTYs Disk Disk busy until t = 20 + 10 = 30ms P1 waits for disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
P0 releases disk at t = 30 ms C C C C D Q RQ IQ TTYs Disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First core busy until t = 30 + 30 = 60ms Disk busy until t = 30 + 10 =40ms
What is next? C C C C D Q RQ IQ TTYs Disk REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END First core busy until t = 30 + 30 = 60ms Disk busy until t = 30 + 10 = 40ms
P1 releases disk at t = 40ms C C C C D Q RQ IQ TTYs Disk First core busy until t = 30+30 = 60ms Second core busy until t = 40+40 = 80ms REAL-TIME 0DEADLINE 80RUN 20DISK 10RUN 30ENDREAL-TIME 5DEADLINE 100RUN 20DISK 10RUN 40END
To be continued • …
Disk average access time • Not as simple to compute as before when there is disk contention • Must compute difference between • Disk request time • Disk request completion time for each disk request
In our example • First disk request • Completed at t = 30ms • Duration is 10 ms • Initialized at t = 20ms • Second disk request • Initialized at t = 25ms • Completed at t = 40ms • Duration is 15 ms
The best way to implement it • Have two counters both initialized at zero • diskcount • disktimes • When a disk request is issued by a process • Add 1 to diskcount • Subtract current time from disktimes • When a disk request is issued by a process • Add current time to disktimes
In our example • diskcount = 1 + 1 = 2 • disktimes = – 20 – 25 + 30 + 40 = 70 – 45 = 25 • The average disk access time is 25/2 = 12.5 ms
Simulating time • Absolutely nothing happens to our model between two successive "events" • Events are • Arrival of a new process • Start of a computing step • Completion of a computing step • We associate an event routine with each event
Arrival event routine • Process first request of process • It will always be a CPU request
CPU request routine • current time is clockrequest time is crt • if a core is free : mark core busy until clock + crt else : enter process in appropriate CPU queue
CPU request completion routine (I) • if both CPU queues are empty : mark core idleelif real-time queue is empty : pick first process P' in interactive queue crt' is request time for P' mark core busy until clock + crt' proceed with next request