Question 1 |
Consider the two functions incr and decr shown below.
Suppose there are two implementations of the semaphore s, as follows:
I-1: s is a binary semaphore initialized to 1.
I-2: s is a counting semaphore initialized to 2.
Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?
incr(){
wait(s);
X = X+1;
signal(s);
}
decr(){
wait(s);
X = X-1;
signal(s);
}
There are 5 threads each invoking incr once, and 3 threads each invoking decr
once, on the same shared variable X. The initial value of X is 10.Suppose there are two implementations of the semaphore s, as follows:
I-1: s is a binary semaphore initialized to 1.
I-2: s is a counting semaphore initialized to 2.
Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?
15, 7 | |
7, 7 | |
12, 7 | |
12, 8 |
Question 1 Explanation:
Question 2 |
Consider the following threads, T_1, T_2, \text{ and }T_3 executing on a single processor, synchronized using three binary semaphore variables, S_1, S_2, \text{ 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 2 Explanation:
Question 3 |
Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance:
[MSQ]
function OWNRESOURCE(Resource R)
Acquire lock L // a global lock
if R is available then
Acquire R
Release lock L
else
if R is owned by another process P then
Terminate P, after releasing all resources owned by P
Acquire R
Restart P
Release lock L
end if
end if
end function
Which of the following choice(s) about the above scheme is/are correct?[MSQ]
The scheme ensures that deadlocks will not occur | |
The scheme may lead to live-lock | |
The scheme may lead to starvation | |
The scheme violates the mutual exclusion property |
Question 3 Explanation:
Question 4 |
Consider the following pseudocode, where Sis a semaphore initialized to 5 in line #2 and counter is a shared variable initialized to 0 in line #1. Assume that the increment operation in line #7 is not atomic.
[MSQ]
1. int counter =0;
2. Semaphore S= init(5);
3. void parop(void)
4. {
5. wait(S);
6. wait(S);
7. counter++;
8. signal(S);
9. signal(S);
10. }
If five threads execute the function parop concurrently, which of the following program behavior(s) is/are possible?[MSQ]
The value of countercounter is 5 after all the threads successfully complete the execution of parop. | |
The value of countercounter is 1 after all the threads successfully complete the execution of parop. | |
The value of countercounter is 0 after all the threads successfully complete the execution of parop. | |
There is a deadlock involving all the threads. |
Question 4 Explanation:
Question 5 |
Remote Procedure Calls are used for
communication between two processes remotely different from each other on the same system | |
communication between two processes on the same system | |
communication between two processes on the separate systems | |
none of the above |
Question 5 Explanation:
NOTE: Question is excluded from the evaluation due to ambiguity.
Click here for detail solution by gateoverflow
Click here for detail solution by gateoverflow
There are 5 questions to complete.
Sir, Please update the option i and ii of question number 52, both option are same written here.
Thank You Ashutosh Gupta,
We have updated the answer.
Sir, please update the question 45. The question has to be never contains a substring of the form, it was written as always leads to the substring.
Thank you mounika dasa,
We have updated the question.
Hello,
Q.37 (d) P(xsem),V(xsem) should be correct!
We have updated the answer as D.