Operating system mcqs semaphores
Click on any option to know the CORRECT ANSWERS
What are the two kinds of semaphores?
mutex & counting
binary & counting
counting & decimal
decimal & binary
The program follows to use a shared binary semaphore T. Process A int Y; A1: Y = X*2; A2: X = Y; signal(T); Process B int Z; B1: wait(T); B2: Z = X+1; X = Z; T is set to 0 before either process begins execution and, as before, X is set to 5. Now, how many different values of X are possible after both processes finish executing?
Question 2 Explanation:
The semaphore T ensures that all the statements from A finish execution before B begins. So now there is only one way in which statements from A and B can be interleaved: A1 A2 B1 B2: X = 11.
At a particular time of computation the value of a counting semaphore is 7.Then 20 P operations and 15 V operations were completed on this semaphore. The resulting value of the semaphore is? (GATE 1987)
Question 3 Explanation:
P represents Wait and V represents Signal. P operation will decrease the value by 1 every time and V operation will increase the value by 1 every time.
The following pair of processes share a common variable X. Process A int Y; A1: Y = X*2; A2: X = Y; Process B int Z; B1: Z = X+1; B2: X = Z; X is set to 5 before either process begins execution. As usual, statements within a process are executed sequentially, but statements in process A may execute in any order with respect to statements in process B. How many different values of X are possible after both processes finish executing?
Question 4 Explanation:
Here are the possible ways in which statements from A and B can be interleaved. A1 A2 B1 B2: X = 11 A1 B1 A2 B2: X = 6 A1 B1 B2 A2: X = 10 B1 A1 B2 A2: X = 10 B1 A1 A2 B2: X = 6 B1 B2 A1 A2: X = 12.
Spinlocks are intended to provide ..... only.
There are 5 questions to complete.