operating system

Question One

5 Marks

Learning Outcome(s):

Describe the OS mechanism for process management, timing, memory, I/O, file and concurrency management.

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.

[2 Marks]

 

 

 

 

 

b) Calculate the average waiting time? [2 Marks]

 

 

 

 

 

 

 

c) Which process has the longest waiting time? [1 Marks]

Question Two

5 Marks

Learning Outcome(s):

Describe the OS mechanism for process management, timing, memory, I/O, file and concurrency management.

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. [2 Marks]

 

 

 

 

b. Calculate the average waiting time? [2 Marks]

 

 

 

 

 

 

c. Which process has the longest waiting time? [1 Marks]

Question Three

5 Marks

Learning Outcome(s):

Describe the OS mechanism for process management, timing, memory, I/O, file and concurrency management.

a. What is a race condition? Explain with example. [3 Marks]

 

 

 

 

 

 

 

 

 

b. What do you mean by counting semaphore? [2 Marks]

 

Question Four

5 Marks

Learning Outcome(s):

Describe the OS mechanism for process management, timing, memory, I/O, file and concurrency management.

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.

 

College of Computing and Informatics