Question 61
HardA counting semaphore is initialised to 5. Eight processes each call wait() once and none has called signal() yet. How many of them are blocked?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Operating Systems
A counting semaphore is initialised to 5. Eight processes each call wait() once and none has called signal() yet. How many of them are blocked?
3
5
0
8
Sign up free to see the answer and a step-by-step explanation.
A semaphore S = 10. Then 6 wait() and 4 signal() operations are performed. What is S now?
8
12
6
10
Sign up free to see the answer and a step-by-step explanation.
What three conditions must a correct solution to the critical-section problem satisfy?
Atomicity, durability and isolation
Mutual exclusion, progress and bounded waiting
Deadlock, starvation and progress
Speed, fairness and simplicity
Sign up free to see the answer and a step-by-step explanation.
Peterson's algorithm solves the critical-section problem for how many processes?
Two
Three
Any number
One
Sign up free to see the answer and a step-by-step explanation.
Why can Peterson's algorithm fail on modern multi-core processors without memory barriers?
The CPU or compiler may reorder memory operations on the flags and turn
It uses semaphores
It needs too much memory
It works only on single-core machines with interrupts off
Sign up free to see the answer and a step-by-step explanation.
What does a test-and-set instruction do?
Adds two numbers
Atomically reads a memory word and sets it to true, returning the old value
Tests a file's permissions
Disables interrupts permanently
Sign up free to see the answer and a step-by-step explanation.
In the bounded-buffer problem with semaphores empty, full and mutex, what are their initial values for a buffer of size N?
empty = N, full = N, mutex = 1
empty = 1, full = 1, mutex = N
empty = N, full = 0, mutex = 1
empty = 0, full = N, mutex = 0
Sign up free to see the answer and a step-by-step explanation.
In the bounded-buffer solution, why must a producer call wait(empty) before wait(mutex)?
Otherwise it could hold the mutex while waiting for an empty slot, deadlocking the consumer
The order does not matter
Because mutex is a counting semaphore
To save time
Sign up free to see the answer and a step-by-step explanation.
What is the difference between a mutex and a binary semaphore?
They are identical in every way
A semaphore can only be 0
A mutex can count above 1
A mutex has an owner and must be released by the thread that locked it; a semaphore can be signalled by any thread
Sign up free to see the answer and a step-by-step explanation.
What does a monitor provide?
A hardware timer
A construct in which only one thread at a time can be active inside its procedures, with condition variables for waiting
A kind of file lock only
A display device
Sign up free to see the answer and a step-by-step explanation.