Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CPS

305 OPERATING SYSTEM ASSIGNMENT



The following set of processes, with the length of the CPU-burst time given in
milliseconds as below:

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

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at
time 0ms.
(a) Draw four Gantt charts illustrating the execution of these processes using
a. FCFS
b. SJF
c. Priority Scheduling (a smaller priority number implies a higher
priority)
d. RR (quantum =2) scheduling
(b) What is the waiting time for each process of the scheduling algorithms in
(a)?
(c) Which of the schedules in (a) results in the average waiting time (overall
processes)?
2. Interprocess Communication (IPC)

SOLUTIONS

(a) Gantt Charts
(i)First Come First Served (FCFS). It is the simplest scheduling
algorithm. The process that requests the CPU first is the one that
the CPU

P1
P2
P3
P4
P5
0 10 11 13 14 19

(ii)Shortest Job First. This algorithm associates with each process
the length of the next process CPU burst time

P2
P4
P3
P5
P1
0 1 2 4 9 19


(ii)Priority scheduling is a special SJF, except that the additional of
a the priority condition associated with each process

P2
P5
P1
P3
P4
0 1 6 16 18 19

(iv)Round Robin is a scheduling algorithm designed specifically for


time sharing systems


P1
P2
P3
P4
P5
P1
P5
P1
P5
P1
P1 P1
0 2 3 5 7 9 11 13 14 16 18 19

(b) Waiting time for each of the scheduling algorithm
a. FCFS (0+10+11+13+14)/5 = 48/5 milliseconds
b. SJF (9+0+2+1+4)/5 =16/5 milliseconds
c. Priority (6+0+16+18=1)/5 =31/5 milliseconds
d. Round Robin (0+2+3+5+9+11+13+14+16+18)/5 =91/5 millisecs
(c) Average waiting time will be Shortest Job First (SJF) algorithm with an
average waiting time of 16/5 milliseconds





2. Interprocess Communication

In certain instances processes that run together may need to
communicate by exchanging code and data, they can also affect each other. For
processes that do not need to exchange code or data, and do not care to know
about the existence of each other, they are independent process. The processes
that needs to exchange code and data and can also be affected by the status of
each other are called cooperating process. For cooperating process, there are
two modes of cooperation which are message passing and shared memory. For
message passing, each process will have the capability to exchange messages
with one another, important and status messages. For shared memory, a shared
memory region is created which is known to all the cooperating process. They
can access and drop any important or status messages and can also request for
messages

You might also like