# A3

Topics: AirTrain Newark, Computer, Algorithm Pages: 5 (849 words) Published: April 15, 2015
﻿6.11 – Why is it important for the scheduler to distinguish I/O-bound programs from CPU-bound programs? I/O-bound programs use very little computation while being performed and so do not use up their entire CPU quantum. CPU programs use their entire quantum without blocking the I/O operations. 6.16 – Consider the following set of processes, with the length of the CPU burst given milliseconds: Process

P1
P2
P3
P4
P5
Burst Time
2
1
8
4
5
Priority
2
1
4
2
3

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0. (a) Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, non-preemptive priority (a larger priority number implies a higher priority), and RR (quantum = 2). FCFS

------------------------------------------------------------------------------------ | P1 | P2 | P3 | P4 | P5 | ------------------------------------------------------------------------------------ 0 2 3 11 15 20 SJF

------------------------------------------------------------------------------------ | P2 | P1 | P4 | P5 | P3 | ------------------------------------------------------------------------------------ 0 1 3 7 12 20 Non-preemptive priority

------------------------------------------------------------------------------------ | P2 | P1 | P4 | P5 | P3 | ------------------------------------------------------------------------------------ 0 1 3 7 12 20 Round-Robin

------------------------------------------------------------------------------------ | P1 | P2 | P3 | P4 | P5 | P3 | P4 | P5 | P3 | P5 | P3 | ------------------------------------------------------------------------------------ 0 2 3 5 7 9 11 13 15 17 18 20

(b) What is the turnaround time of each process for each of the scheduling algorithms in part a?

FCFS
Process
P1
P2
P3
P4
P5
Turnaround Time
2
3
11
15
20
SJF
Process
P1
P2
P3
P4
P5
Turnaround Time
3
1
20
7
12
Non-preemptive priority
Process
P1
P2
P3
P4
P5
Turnaround Time
3
1
20
7
12
Round-Robin
Process
P1
P2
P3
P4
P5
Turnaround Time
2
3
20
13
18

(c) What is the waiting time of each process for each of these scheduling algorithms? FCFS
Process
P1
P2
P3
P4
P5
Waiting Time
0
2
3
11
15
SJF
Process
P1
P2
P3
P4
P5
Waiting Time
1
0
12
3
7
Non-preemptive priority
Process
P1
P2
P3
P4
P5
Waiting Time
1
0
12
3
7
Round-Robin
Process
P1
P2
P3
P4
P5
Waiting Time
0
2
12
9
13

(d) Which of the algorithms results in the minimum average waiting time (over all processes)? SJF and non-preemptive priority resulted in the lowest average waiting time. (In this case)

6.19 – Which of the following scheduling algorithms could result in starvation? (a) First-come, first-served
(b) Shortest job first
(c) Round robin
(d) Priority
Shortest job first and Priority scheduling could result in starvation.

6.21 – Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context-switching overhead is 0.1 millisecond and that all processes are long-running tasks. Describe the CPU utilization for a round-robin scheduler when: (a) The time quantum is 1...