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.
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAB/CAYAAABVEP+YAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACsUlEQVR4Ae3QMQEAAADCoPVPbQZ/iEBhwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMnAMDU+0AAePul1EAAAAASUVORK5CYII=)
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 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