Concepts:
the “response time” (the time a job spends waiting after arrival before first running);
the “turnaround time” (the time it took to complete the job since first arrival);
the total “wait time” (any time spent ready but not running).
1&2:
I will simply combine both of 2 questions and draw some conclusion:
root@C202511211157657:~\# ./scheduler.py -p FIFO -j 3 -s 1
ARG policy FIFO
ARG jobs 3
ARG maxlen 10
ARG seed 1
Here is the job list, with the run time of each job:
Job 0 ( length = 2 )
Job 1 ( length = 9 )
Job 2 ( length = 8 )
Compute the turnaround time, response time, and wait time for each job.
When you are done, run this program again, with the same arguments,
but with -c, which will thus provide you with the answers. You can use
-s <somenumber> or your own job list (-l 10,15,20 for example)
to generate different problems for yourself.
Its policy is FIFO, so we could add up the execution times:
| Job | Response Time | Turnaround Time | Wait Time |
|---|---|---|---|
| 0 | 0 | 2 | 0 |
| 1 | 2 | 11 | 2 |
| 2 | 11 | 19 | 11 |
| Average | 4.3 | 10.6 | 4.3 |
Actually: Correct.
Notice that the wait time and the response time is always the same as job won’t be interrupted since started.
root@C202511211157657:~# ./scheduler.py -p SJF -j 3 -s 1
ARG policy SJF
ARG jobs 3
ARG maxlen 10
ARG seed 1
Here is the job list, with the run time of each job:
Job 0 ( length = 2 )
Job 1 ( length = 9 )
Job 2 ( length = 8 )
Compute the turnaround time, response time, and wait time for each job.
When you are done, run this program again, with the same arguments,
but with -c, which will thus provide you with the answers. You can use
-s <somenumber> or your own job list (-l 10,15,20 for example)
to generate different problems for yourself.
SJF need us to do some extra sorting, but the calculation is almost the same:
| Job | Response Time | Turnaround Time | Wait Time |
|---|---|---|---|
| 0 | 0 | 2 | 0 |
| 1 | 10 | 19 | 10 |
| 2 | 2 | 10 | 2 |
| Average | 4 | 10.3 | 4 |
Actually: Correct.
Slightly improved.
root@C202511211157657:~# ./scheduler.py -p RR -l 100,200,300 -q 1
ARG policy RR
ARG jlist 100,200,300
Here is the job list, with the run time of each job:
Job 0 ( length = 100.0 )
Job 1 ( length = 200.0 )
Job 2 ( length = 300.0 )
Compute the turnaround time, response time, and wait time for each job.
When you are done, run this program again, with the same arguments,
but with -c, which will thus provide you with the answers. You can use
-s <somenumber> or your own job list (-l 10,15,20 for example)
to generate different problems for yourself.
Turnaround time is pretty difficult to calculate… The other two are simple.
| Job | Response Time | Turnaround Time | Wait Time |
|---|---|---|---|
| 0 | 0 | 298 | 198 |
| 1 | 1 | 499 | 299 |
| 2 | 2 | 600 | 300 |
| Average | 1 | 465.6 | 265.6 |
Actually: Correct.
-
When FIFO Queue is ordered.
-
When there is only one (or less) task of which length is more than the quantum length.
-
Grows longer.
-
Grows longer, and decade to FIFO.
Worst response time = (max_length + total_length) * N / 2.
So it would be affcted linearly by the job length and the numbr of jobs.