Time Left - 15:00 mins

# GATE 2022: Operating System Quiz-6

Attempt now to get your rank among 305 students!

Question 1

In message passing system, how many points of synchronization are possible?

Question 2

Match the following groups
List-I
A) Synchronization
B) Mutual Exclusion
C) Critical Section
List-II
1) Piece of code that only one thread can execute at once.
2) Ensuring that only one thread does a particular thing at a time.
3) Using atomic operations to ensure cooperation between threads.

Question 3

Three processes A, B, C uses binary semaphores x, y, z to
synchronize between them as shown below. All the semaphores are initialized to 1

Question 4

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 5

What is the main reason for RACE condition while synchronizing the process?

Question 6

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?

• 305 attempts
• 1 upvote