GATE 2017 [Set-1]
October 3, 2023Algorithms
October 3, 2023Operating-Systems
Question 21
|
Consider the following threads, T 1 , T 2 , and T 3 executing on a single processor, synchronized using three binary semaphore variables, S 1 , S 2 , and S 3 , operated upon using standard wait() and signal(). The threads can be context switched in any order and at any time.
![](https://solutionsadda.in/wp-content/uploads/2022/03/22-300x127.png)
Which initialization of the semaphores would print the sequence BCABCABCA….?
![](https://solutionsadda.in/wp-content/uploads/2022/03/22-300x127.png)
Which initialization of the semaphores would print the sequence BCABCABCA….?
S 1 = 1; S 2 = 1; S 3 = 1
|
|
S 1 = 1; S 2 = 1; S 3 = 0
|
|
S 1 = 1; S 2 = 0; S 3 = 0
|
|
S 1 = 0; S 2 = 1; S 3 = 1
|
Question 21 Explanation:
Explanation: Since B is to be printed first semaphore S1 has to be set to 1, so that the thread enters its critical section and prints B. Then C needs to be printed, this happens when Thread 1 is blocked on semaphore s3 (blocked, s3=0). Then Thread1 invokes Thread 3 to print A.
Correct Answer: C
Question 21 Explanation:
Explanation: Since B is to be printed first semaphore S1 has to be set to 1, so that the thread enters its critical section and prints B. Then C needs to be printed, this happens when Thread 1 is blocked on semaphore s3 (blocked, s3=0). Then Thread1 invokes Thread 3 to print A.
Subscribe
Login
0 Comments