You are on page 1of 13

Name ID

Mohamed Abdelrahman Anwar 20011634

Operating Systems
Sheet 10
Process Scheduling

1.
• Small quantum: favors short processes and more
overhead due to frequent context switching.
• Large quantum: favors long processes and poor
performance for short interactive requests.
2. An I/O‐bound process getting serviced as it reaches the head
of the first queue typically is allocated enough processor time
to generate its next I/O request and leave the queuing network,
so I/O‐bound processes receive the kind of immediate (yet
brief) service they require to keep I/O device utilization high.
Processor‐bound processes rapidly sink to the lower‐priority
queues, where they “get out of the way” of I/O‐bound
processes requiring fast service.
3. Setting longer time quantum sizes at lower priority levels in a
multilevel scheduling system helps prevent starvation of long
processes by allowing them to execute for extended periods
without being preempted by higher-priority tasks. This ensures
that lower-priority processes have a fair chance to make
progress and complete their execution.
4.
a. It uses the technique of aging; a process’s priority increases
the longer it waits for service.
b. Again, a process’s priority increases as it waits, so a long
process that has been waiting for some time may eventually get
a higher priority than even newly arriving short processes.
c. Only if their anticipated service times are identical. If not,
then the process with the shorter service time will have higher
priority.
5.
a. A process that runs for some time falls to lower‐priority
queues as it continues executing.
Shorter processes remain in the higher‐priority queues until
they are complete, then they leave the queuing network. A
process in a lower‐priority queue executes only if no processes
are waiting in higher priority queues.
b. I/O‐bound processes use only a small amount of processor
time before generating an I/O request and leaving the queuing
network, so they receive priority similar to shorter processes.
c. The primary distinction is between I/O‐bound and processor‐
bound processes. An I/O‐bound process getting serviced as it
reaches the head of the first queue typically is allocated enough
processor time to generate its next I/O request and leave the
queuing network, so I/O‐bound processes receive the kind of
immediate (yet brief) service they require to keep I/O device
utilization high. Processor‐bound processes rapidly sink to the
lower‐priority queues, where they “get out of the way” of I/O‐
bound processes requiring fast service.
6.
a.
• Shortest Remaining Time:

• Non-preemptive Priority:

• Round Robin with quantum of 30 ms:

b.
• Shortest Remaining Time (20+0+70+10)/4 = 25ms)
• Non-preemptive Priority (0+30+10+70)/4 = 27.5ms)
• Round Robin with quantum of 30 ms (20+10+70+70)/4 =
42.5ms)
7.
a. Optimal: when there is high variance in processes execution
times. So when short processes come first. Pessimal: when
there is high variance in processes execution times. So when
long processes come first.
b. Optimal: it always provides good response times for short
processes. Pessimal: none.
c. Optimal: it always provides good response times for short
processes. Pessimal: it may cause starvation to long processes
and will result in bad response times.
d. Optimal: it provides good response times for short processes.
Pessimal: none.
8.
a.

Turnaround = [(5-0) + (14-1) + (17-3) + (24-10) + (30-12)] / 5 =


64 / 5 = 12.8
Normalized turnaround:
P1: 5 / 4 = 1.25
P2: 13 / 8 = 1.625
P3: 14 / 2 = 7 <--- FCFS can be unfair to short processes
P4: 14 / 6 = 2.333
P5: 18 / 5 = 3.6
Processor efficiency = 25 / 30 = 83.33%
b.

Turnaround = [(5-0) + (17-1) + (8-3) + (30-10) + (23-12)] / 5 = 57


/ 5 = 11.4
NOTE: SPN has the smallest turnaround, compared to other
algorithms
Normalized turnaround:
P1: 5 / 4 = 1.25
P2: 16 / 8 = 2
P3: 5 / 2 = 2.5 <--- SPN much more fair to short processes
(compared to FCFS)
P4: 20 / 6 = 3.333
P5: 11 / 5 = 2.2
Processor efficiency = 25 / 30 = 83.33%
c.
Turnaround = [(5-0) + (31-1) + (8-3) + (17-10) + (23-12)] / 5 = 58
/ 5 = 11.6
Normalized turnaround:
P1: 5 / 4 = 1.25
P2: 30 / 8 = 3.75 <--- largest normalized turnaround; also largest
process
P3: 5 / 2 = 2.5
P4: 7 / 6 = 1.166
P5: 11 / 5 = 2.2
Processor efficiency = 25 / 31 = 80.6%
d.

Turnaround = [(13-0) + (28-1) + (11-3) + (32-10) + (35-12)] / 5 =


93 / 5 = 18.6
Normalized turnaround:
P1: 13/ 4 = 3.25
P2: 27 / 8 = 3.375
P3: 8 / 2 = 4.0
P4: 22 / 6 = 3.666
P5: 23 / 5 = 4.6
In RR, all processes are considered equally important
Processor efficiency = 25 / 35 = 71.4%
e.

Turnaround = [(12-0) + (35-1) + (9-3) + (28-10) + (32-12)] / 5 =


90 / 5 = 18
Normalized turnaround:
P1: 12/ 4 = 3.0
P2: 34 / 8 = 4.25 <--- largest job
P3: 6 / 2 = 3.0 <--- smallest job
P4: 18 / 6 = 3.0
P5: 20 / 5 = 4.0
Processor efficiency = 25 / 35 = 71.4%
9.
a. Round robin with time quantum = 1 minute (Assume they are
ordered according to their priorities)
P21, P51, P11, P31, P41
P22, P52, P12, P32, P42
P23, P53, P13, P33, P43
P24, P54, P14, P44
P25, P55, P15, P45
P26, P56, P16, P46
P27, P57, P17
P28, P58, P18
P29, P59, P19
P510, P110
P511, P111
P512, P112
P113
P114
P115
Turnaround times:
P1: 45
P2: 36
P3: 15
P4: 27
P5: 42
Average = 33
b. Priority scheduling
P2, P5, P1, P3, P4
Turnaround times:
P1: 36
P2: 9
P3: 39
P4: 45
P5: 21
Average = 30
c. FCFS
P1, P2, P3, P4, P5
Turnaround times:
P1: 15
P2: 24
P3: 27
P4: 33
P5: 45
Average = 28.8
d. Shortest job first
P3, P4, P2, P5, P1
Turnaround times:
P1: 45
P2: 18
P3: 3
P4: 9
P5: 30
Average = 21
10.
a.

• Waiting time (black periods):


P1: 2
P2: 3
P3: 9
Average = 14/3
• Response time:
P1: 0
P2: 1
P3: 3
Average = 4/3
• Turnaround:
P1: 14
P2: 14
P3: 15
Average = 14.333
b.

• Waiting time (black periods):


P1: 4
P2: 5
P3: 2
Average = 11/3
• Response time:
P1: 0
P2: 0
P3: 1
Average = 1/3
• Turnaround:
P1: 16
P2: 16
P3: 8
Average = 13.3333
c.

• Waiting time (black periods):


P1: 1
P2: 6
P3: 8
Average = 3
• Response time:
P1: 0
P2: 1
P3: 3
Average = 4/3
• Turnaround:
P1: 13
P2: 17
P3: 14
Average = 14.666

You might also like