Mock Quiz Hub
Dark
Mock Quiz Hub
1
Recent Updates
Added: OS Mid 1 Quiz
Added: OS Mid 2 Quiz
Added: OS Lab 1 Quiz
Check back for more updates!
Time: 00:00
Quiz
Navigate through questions using the controls below
0%
Question 1 of 60
Quiz ID: q1
What is the primary purpose of a railway semaphore in the context of concurrent programming?
To control train speed and acceleration
To indicate whether the track ahead is clear or occupied
To communicate with the central train station
To measure the distance between trains
Question 2 of 60
Quiz ID: q2
Who first described the semaphore concept in concurrent programming?
Alan Turing in 1936
Edsger Dijkstra in 1968
Donald Knuth in 1973
Tony Hoare in 1978
Question 3 of 60
Quiz ID: q3
What type of variable is a semaphore?
A boolean variable that can be true or false
A floating-point variable with decimal values
An integer-valued variable that can take only non-negative values
A string variable that stores process names
Question 4 of 60
Quiz ID: q4
How many operations are exactly defined on a semaphore?
One operation
Two operations
Three operations
Four operations
Question 5 of 60
Quiz ID: q5
In the down(S) operation, what happens if S > 0?
The process is suspended
S is incremented by 1
S is decremented by 1
A waiting process is awakened
Question 6 of 60
Quiz ID: q6
What happens in the up(S) operation when there are processes suspended on S?
S is incremented by 1
All suspended processes are awakened
One of the suspended processes is awakened
The semaphore is reset to 0
Question 7 of 60
Quiz ID: q7
What is a critical property of down(S) and up(S) operations?
They can be interrupted by other processes
They are atomic instructions
They must be called in pairs
They can only be used once per process
Question 8 of 60
Quiz ID: q8
What is the requirement for a semaphore's initial value?
It must be exactly 1
It must be exactly 0
It must be non-negative
It can be any integer value
Question 9 of 60
Quiz ID: q9
What is a general semaphore?
A semaphore that can take only values 0 and 1
A semaphore that can take any non-negative value
A semaphore that can take negative values
A semaphore that can take only positive values
Question 10 of 60
Quiz ID: q10
What values can a binary semaphore take?
Any non-negative integer
Only 0 and 1
Only positive integers
Only negative integers
Question 11 of 60
Quiz ID: q11
Which invariant must a semaphore S always satisfy?
S < 0
S >= 0
S = 1
S <= 1
Question 12 of 60
Quiz ID: q12
What does the invariant S = S₀ + #Up(S) - #Down(S) represent?
The relationship between initial value and completed operations
The maximum value the semaphore can reach
The number of processes waiting on the semaphore
The time complexity of semaphore operations
Question 13 of 60
Quiz ID: q13
In the mutual exclusion solution using semaphores, what should be the initial value of semaphore S?
0
1
2
N (number of processes)
Question 14 of 60
Quiz ID: q14
How does the semaphore solution differ from busy-wait approaches?
It uses more memory
It's slower to execute
Suspended processes don't execute instructions in a loop
It can only handle two processes
Question 15 of 60
Quiz ID: q15
In the mutual exclusion proof, what does #CS represent?
Number of critical sections in the program
Number of processes in their critical sections
Number of semaphore operations completed
Number of processes waiting to enter critical sections
Question 16 of 60
Quiz ID: q16
What invariant proves mutual exclusion in the semaphore solution?
#CS + S = 0
#CS + S = 1
#CS - S = 1
#CS * S = 1
Question 17 of 60
Quiz ID: q17
Why cannot the semaphore mutual exclusion solution deadlock with two processes?
Because semaphores prevent all forms of deadlock
Because if both processes are suspended, it contradicts the invariant #CS + S = 1
Because the semaphore automatically resolves conflicts
Because processes alternate in using the critical section
Question 18 of 60
Quiz ID: q18
What ensures no individual starvation in the two-process semaphore solution?
The FIFO ordering of process execution
When one process is suspended and the other exits the critical section, it will wake the suspended process
The automatic process scheduling by the operating system
The alternating execution pattern enforced by semaphores
Question 19 of 60
Quiz ID: q19
What is a blocked-set semaphore?
A semaphore that blocks all processes indefinitely
A semaphore where suspended processes are kept in a set and one unspecified process is awakened
A semaphore that can only be used by a fixed set of processes
A semaphore that blocks after a certain number of operations
Question 20 of 60
Quiz ID: q20
How does a blocked-queue semaphore differ from a blocked-set semaphore?
It can handle more processes
It's faster in execution
Suspended processes are kept in a FIFO queue and awakened in order
It uses less memory
Question 21 of 60
Quiz ID: q21
In a busy-wait semaphore, what happens in the down(S) operation?
The process is immediately suspended
The process loops continuously testing S until it can decrement it
The process is added to a queue
The semaphore value is automatically decremented
Question 22 of 60
Quiz ID: q22
Which type of semaphore can lead to starvation?
Only blocked-queue semaphores
Only binary semaphores
Busy-wait and blocked-set semaphores (for N > 2)
All types of semaphores
Question 23 of 60
Quiz ID: q23
Why is starvation impossible with blocked-queue semaphores?
Because they use more memory
Because processes are awakened in FIFO order
Because they're faster than other types
Because they prevent deadlock
Question 24 of 60
Quiz ID: q24
In the Bill and Ben cafe problem, what is the synchronization requirement?
Bill and Ben must work at the same speed
Bill cannot serve until Ben has made soup, and Ben cannot serve until Bill has made sandwiches
Only one person can work in the kitchen at a time
They must serve customers in a specific order
Question 25 of 60
Quiz ID: q25
In the first solution to the Bill and Ben problem, what are the initial values of the semaphores?
first = 1, second = 1
first = 0, second = 0
first = 1, second = 0
first = 0, second = 1
Question 26 of 60
Quiz ID: q26
In the Bill and Ben problem, what does Bill do in SYNCH 1 in the first solution?
up(first); down(second);
down(first); up(second);
down(second); up(first);
up(second); down(first);
Question 27 of 60
Quiz ID: q27
What does Ben do in SYNCH 2 in the first solution to the Bill and Ben problem?
down(first); up(second);
up(first); down(second);
down(second); up(first);
up(second); down(first);
Question 28 of 60
Quiz ID: q28
What is the main characteristic of the Producer-Consumer problem?
Multiple processes compete for the same resource
One process creates data that another process consumes
Processes must execute in a specific order
All processes must access a shared variable
Question 29 of 60
Quiz ID: q29
What is synchronous communication in the context of the Producer-Consumer problem?
Using a buffer to store multiple data items
When producer and consumer are ready simultaneously, data is sent directly
When all processes run at the same speed
When data is sent at regular time intervals
Question 30 of 60
Quiz ID: q30
What is the purpose of a buffer in asynchronous communication?
To speed up the communication process
To allow flexibility by storing data when sender and receiver are not ready simultaneously
To reduce memory usage
To prevent data corruption
Question 31 of 60
Quiz ID: q31
In the infinite buffer Producer-Consumer solution, why is mutual exclusion not an issue initially?
Because there's only one producer and one consumer
Because the buffer is infinite
Because producer only writes to tail and consumer only reads from head
Because semaphores automatically handle mutual exclusion
Question 32 of 60
Quiz ID: q32
What does the invariant #E = 0 + tail - head represent in the buffer?
The total buffer capacity
The number of elements currently in the buffer
The number of empty slots in the buffer
The difference between production and consumption rates
Question 33 of 60
Quiz ID: q33
What is the initial value of the 'elements' semaphore in the infinite buffer solution?
1
0
infinity
N (buffer size)
Question 34 of 60
Quiz ID: q34
What does the consumer do before accessing the buffer in the infinite buffer solution?
up(elements)
down(elements)
Check if tail > head
Lock the buffer
Question 35 of 60
Quiz ID: q35
In the circular buffer solution, how many semaphores are used?
One semaphore
Two semaphores
Three semaphores
Four semaphores
Question 36 of 60
Quiz ID: q36
What is the initial value of the 'spaces' semaphore in the circular buffer solution?
0
1
2
N (buffer size)
Question 37 of 60
Quiz ID: q37
What does the producer do before adding an element to the circular buffer?
down(elements)
down(spaces)
up(elements)
up(spaces)
Question 38 of 60
Quiz ID: q38
In the Dining Philosophers problem, how many philosophers are there?
Three
Four
Five
Six
Question 39 of 60
Quiz ID: q39
How many forks does a philosopher need to eat?
One fork
Two forks
Three forks
All available forks
Question 40 of 60
Quiz ID: q40
What are the synchronization requirements for the Dining Philosophers problem?
Only prevent deadlock
Only ensure mutual exclusion of forks
Only prevent starvation
Mutual exclusion of forks, no deadlock, and no starvation
Question 41 of 60
Quiz ID: q41
Why is philosopher[4] implemented differently from the others in the dining philosophers solution?
Because there are only 4 philosophers
Because it needs to handle the wraparound from fork[4] to fork[0]
Because it's the last philosopher to start eating
Because it uses a different eating strategy
Question 42 of 60
Quiz ID: q42
In the Readers and Writers problem, what is the main constraint?
Only one reader can access the database at a time
Only one writer can access the database at a time
Readers can access simultaneously, but only one writer can write with no active readers
Writers have priority over readers
Question 43 of 60
Quiz ID: q43
What is wrong with the first Readers and Writers solution that uses only semaphore rw?
It allows multiple writers simultaneously
It doesn't allow multiple readers simultaneously
It causes deadlock
It's too complex
Question 44 of 60
Quiz ID: q44
What does the variable 'nr' represent in the improved Readers and Writers solution?
Number of writers currently writing
Number of readers currently reading
Number of readers waiting
Number of read operations completed
Question 45 of 60
Quiz ID: q45
When does the first reader execute down(rw) in the Readers and Writers solution?
Always before reading
Only when nr == 1 (it's the first reader)
Only when nr == 0
Never, only writers use down(rw)
Question 46 of 60
Quiz ID: q46
When does the last reader execute up(rw) in the Readers and Writers solution?
Always after reading
Only when nr == 1
Only when nr == 0 (it was the last reader)
Never, only writers use up(rw)
Question 47 of 60
Quiz ID: q47
Under what circumstances is the Readers and Writers solution unfair?
When there are more readers than writers
When writers can be starved by a continuous stream of readers
When readers have to wait for writers
It's always fair
Question 48 of 60
Quiz ID: q48
In the Sleeping Barber problem, what happens when a customer arrives and the waiting room is full?
The customer waits outside the barbershop
The customer comes back later
The customer wakes the barber immediately
The customer joins a queue outside
Question 49 of 60
Quiz ID: q49
What does the barber do when the waiting room is empty?
Closes the barbershop
Goes home
Daydreams (sleeps)
Cleans the shop
Question 50 of 60
Quiz ID: q50
What does the 'customers' semaphore represent in the Sleeping Barber solution?
Total number of customers served
Number of customers currently waiting
Maximum number of customers allowed
Number of customers that have arrived
Question 51 of 60
Quiz ID: q51
What is the purpose of the 'cutting' semaphore in the Sleeping Barber problem?
To control access to the scissors
To coordinate the customer-barber interaction during the haircut
To count the number of haircuts completed
To measure the time spent cutting hair
Question 52 of 60
Quiz ID: q52
What does the 'barber' semaphore signify in the Sleeping Barber solution?
Whether the barber is sleeping or awake
The barber's availability to start cutting hair
The number of barbers in the shop
The barber's skill level
Question 53 of 60
Quiz ID: q53
What type of relationship does the Sleeping Barber problem illustrate?
Producer-Consumer relationship
Reader-Writer relationship
Client-Server relationship
Master-Slave relationship
Question 54 of 60
Quiz ID: q54
What is a rendezvous in the context of the Sleeping Barber problem?
A scheduled appointment time
A point where customer and barber wait for each other to arrive
The physical meeting place in the barbershop
A payment transaction
Question 55 of 60
Quiz ID: q55
What is the main difference between blocked-set and blocked-queue semaphores in terms of fairness?
Blocked-set is always fair, blocked-queue can cause starvation
Both are equally fair
Blocked-queue guarantees FIFO fairness, blocked-set can cause starvation for N > 2
Neither provides any fairness guarantees
Question 56 of 60
Quiz ID: q56
In semaphore implementations, what does 'atomic' mean for the down(S) and up(S) operations?
They use atomic data types
They cannot be interrupted or interleaved with other instructions
They operate on single bits
They are the smallest possible operations
Question 57 of 60
Quiz ID: q57
What is the key advantage of using semaphores over busy-waiting solutions?
Semaphores are faster to execute
Semaphores use less memory
Suspended processes don't waste CPU cycles in busy-wait loops
Semaphores prevent all types of deadlock
Question 58 of 60
Quiz ID: q58
In the Producer-Consumer problem with circular buffer, what prevents the producer from overwriting unread data?
The 'elements' semaphore
The 'spaces' semaphore
The head and tail pointers
The buffer size limit
Question 59 of 60
Quiz ID: q59
What is the main purpose of the 'mutex' semaphore in concurrent programming?
To count resources
To provide mutual exclusion for critical sections
To signal between processes
To implement producer-consumer relationships
Question 60 of 60
Quiz ID: q60
Which semaphore definition provides the strongest guarantee against starvation?
Busy-wait semaphore
Blocked-set semaphore
Blocked-queue semaphore
Binary semaphore
Quiz Summary
Review your answers before submitting
60
Total Questions
0
Answered
60
Remaining
00:00
Time Spent
Submit Quiz
Back to Questions
Previous
Question 1 of 60
Next
!
Confirm Submission
Cancel
Submit Quiz