You are asked to draw a Gantt chart. If you cannot easily mimic the diagrams from the text, please feel free to report the same information in whatever way you choose. For example, Exercise 71 of the text is a practice problem with the answer in the back of the text. I might choose to typeset that same answer in a table form, such as:
From To CPU Runs
------------------------
0 50 p4
50 110 p2
110 230 p1
230 410 p3
410 710 p5
Page | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|
Frame | 64 | 22 | 8 | 71 | 55 |
Consider the following situation:
Job | Arrival Time | Service Time |
---|---|---|
p1 | 0 | 40 |
p2 | 0 | 20 |
p3 | 10 | 5 |
p4 | 11 | 1 |
As described in the book, the Shortest Job Next (SJN) CPU scheduling
algorithm is non-preemptive. Therefore, it produces the following Gantt
chart (for simplicity, I'm typesetting the "chart" as the following
table):
from | to | CPU runs |
---|---|---|
0 | 20 | p2 |
20 | 21 | p4 |
21 | 26 | p3 |
26 | 60 | p1 |
What is interesting to note is that SJN is non-preemptive. That is, at time 10, when job p3 arrives, p3 is even shorter than the job which is currently running. However, the SJN scheduling algorithm lets p2 complete. Similarly when p4 arrives.
A common preemptive variant of this is one which is called Shorest Remaining Processing Time (SRPT). With this scheme, if a new job arrives with a service time even less than the currently running job's remaining processing time, then the current job is preempted in favor of the new job. When any job completes, the scheduler will next give the CPU to the ready job with the smallest remaining processing time. So on the above example, the SRPT algorithm produces the following schedule:
from | to | CPU runs |
---|---|---|
0 | 10 | p2 |
10 | 11 | p3 |
11 | 12 | p4 |
12 | 16 | p3 |
16 | 26 | p2 |
26 | 60 | p1 |
Your extra credit task is the following.
Please give the Gantt chart which results from running the SRPT
scheduling
algorithm on the following set of jobs:
Job | Arrival Time | Service Time |
---|---|---|
p1 | 0 | 15 |
p2 | 0 | 20 |
p3 | 10 | 1 |
p4 | 12 | 13 |
p5 | 14 | 5 |
p6 | 24 | 4 |
Solution to the text's problem 35: Though the physical
machine has many users trading demands on it, users see what appear to
be their own individual machines, their virtual machines, with the real
sharing and interleaving of demands hidden.
Solution to the last practice problem:
logical address 85 = 0*1024 + 85. Physical address
5*1024 + 85 = 5205
logical address 2359 = 2*1024 + 311. Physical
address 7*1024 + 311 = 7479
logical address 6000 = 5*1024 + 880. Error:
out of bounds; no page number 5