Time Left - 15:00 mins

GATE 2022: Operating System Quiz-5

Attempt now to get your rank among 200 students!

Question 1

Consider the following synchronization construct used by the processes P1, P2 and P3. The S1, S2 and S3 are counting semaphore variables:

S1 = 3, S2 = 2, S3 = 1;

P (S1);

P (S2);

P (S3);

Critical section

V (S3);

V (S2);

V (S1);

Which of the below statement is true?

Question 2

Consider the following statements w.r.t. deadlock,
1) An OS implements a policy that requires a process to release all resources before making a request for another resource can lead to starvation but not deadlock.
2) In deadlock prevention, the request for resource is always guaranteed if the resulting state is safe.
3) Deadlock can be prevented, if the resources are numbered uniquely, and processes are allowed to request for resources only in decreasing or increasing resource number.
4) Deadlock avoidance has less restriction than deadlock prevention.
Which of the above statement is/are false?

Question 3

Consider the following classical synchronization problem called the barbershop problem. A barbershop consists of a room with N chairs. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy, but chairs are available, then the customer sits in one of the free chairs and awaits his turn. The barber moves onto the next waiting seated customer after he finishes one hair-cut. If there are no customers to be served, the barber goes to sleep. If the barber is asleep when a customer arrives, the customer wakes up the barber to give him a hair-cut. A waiting customer vacates his chair after his hair cut completes.
This is the suggested pseudo code for the above problem.
semaphore mutex = 1, customers = 0, barber = 0;
int waiting_count = 0;
Customer:
down(mutex)
if(waiting_count == N) {
up(mutex)
leave()
}
waiting_count++
up(mutex)
up(customers)
down(barber)
getHairCut()
down(mutex)
waiting_count--
up(mutex)
Barber:
up(barber)
down(customers)
cutHair()
Which of the following is correct about the suggested solution?

Question 4

Consider the following synchronization construct used by two process P0 and P1 which need to access a critical section:

P0 :

while (true) {

turn_0 = true;

while (turn_l = = true)

turn_0 = false;

CRITICAL SECTION

}

/ * Remainder section*/

P1 :

while (true) {

turn_1 = true;

while (turn_0 = = true)

turn_1 = false;

CRITICAL SECTION

}

/*Remainder section*/

Here, turn_0 and turn_1 are shared variables, which are initialized to false. Which of the following statement is true about the above construct?

Question 5

An operating system uses the Banker’s Algorithm for deadlock avoidance when managing the allocation of three resources types X, Y and Z to five processes. Consider the following scenario:

Total possible safe sequences are _________.

Question 6Multiple Correct Options

In order to create a good solution for the mutual exclusion problem (critical section problem) for concurrent processes, which of the following conditions must hold?
  • 200 attempts
  • 0 upvotes
  • 0 comments
Sep 3GATE & PSU CS

Posted by:

Megha GhoshMegha GhoshMember since Jul 2021
Share this quiz   |