This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on “Semaphores – 2”.
1. What will happen if a non-recursive mutex is locked more than once?
a) Starvation
b) Deadlock
c) Aging
d) Signaling
View Answer
Explanation: If a thread which had already locked a mutex, tries to lock the mutex again, it will enter into the waiting list of that mutex, which results in a deadlock. It is because no other thread can unlock the mutex.
2. What is a semaphore?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned
View Answer
Explanation: None.
3. What are the two kinds of semaphores?
a) mutex & counting
b) binary & counting
c) counting & decimal
d) decimal & binary
View Answer
Explanation: None.
4. What is a mutex?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned
View Answer
Explanation: None.
5. 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)
a) 42
b) 2
c) 7
d) 12
View Answer
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.
6. A binary semaphore is a semaphore with integer values ____________
a) 1
b) -1
c) 0.8
d) 0.5
View Answer
Explanation: None.
7. 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?
a) two
b) three
c) four
d) eight
View Answer
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.
8. 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?
a) one
b) two
c) three
d) four
View Answer
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.
9. Semaphores are mostly used to implement ____________
a) System calls
b) IPC mechanisms
c) System protection
d) None of the mentioned
View Answer
Explanation: None.
10. Spinlocks are intended to provide __________ only.
a) Mutual Exclusion
b) Bounded Waiting
c) Aging
d) Progress
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – Operating System.
To practice all areas of Operating System, here is complete set on 1000+ Multiple Choice Questions and Answers on Operating System.
- Check Computer Science Books
- Practice BCA MCQs
- Apply for Computer Science Internship
- Check Operating System Books
- Practice Computer Science MCQs