Given the following set of processes and the length of the


Assignment

Question 1

1. Given the following set of processes and the length of the CPU burst given in milliseconds, show how these processes are scheduled according to Round Robin scheduling. Use a time quantum of 2 milliseconds.

Process

Burst Time (ms)

P1

5

P2

4

P3

2

P4

3

a) Draw the Gantt-chart for the scheduling algorithm. Inside each box, write the name of the process and specify the start and end of each scheduled time below.

b) Calculate the average waiting time?

c) Which process has the longest waiting time?

Question 2

Given the following set of processes and the length of the CPU burst given in milliseconds:

Process

Burst Time (ms)

P1

5

P2

4

P3

2

P4

3

P5

7

 

a. Draw the Gantt-chart for the above processes using Shortest Job First Scheduling algorithm.

b. Calculate the average waiting time?

c. Which process has the longest waiting time?

Question 3

a. What is a race condition? Explain with example.

b. What do you mean by counting semaphore?

Question 4

What are the disadvantages of Peterson's solution for critical-section problem? Code below shows the solution to two process mutual exclusion problem.

Process Pi
do {
flag[i] = true;
turn = j;
while (flag[j] && turn == j);
critical section
flag[i] = false;
remainder section
} while (true);
Process Pj
do {
flag[j] = true;
turn = i;
while (flag[i] && turn == i);
critical section
flag[j] = false;
remainder section
} while (true);

Answer True or False to the following questions:

(i) This algorithm satisfies the "mutual exclusion", "progress" and "bounded waiting" condition.

ii) This algorithm has a flaw as the variable "turn" can be modified by both processes at the same time.

iii) This algorithm may cause "deadlock" if both processes set their flags to True at the same time.

iv) This algorithm satisfies only the "mutual exclusion" and "progress" condition.

Solution Preview :

Prepared by a verified Expert
Operating System: Given the following set of processes and the length of the
Reference No:- TGS02682894

Now Priced at $40 (50% Discount)

Recommended (92%)

Rated (4.4/5)