GATE 2017 [Set-1]
October 3, 2023Algorithms
October 3, 2023Operating-Systems
Question 5 |
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.
Which initialization of the semaphores would print the sequence BCABCABCA….?
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 5 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 5 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