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 cause of data inconsistency in concurrent processes?
Slow processor speed
Concurrent access to shared data
Lack of sufficient memory
Inefficient algorithms
Question 2 of 60
Quiz ID: q2
What is a race condition?
A condition where processes run at different speeds
A situation where the outcome depends on the order of execution of instructions
A type of memory error
A hardware failure
Question 3 of 60
Quiz ID: q3
In the critical-section problem, what is the entry section?
The code segment where the process exits the critical section
The code segment where the process requests permission to enter the critical section
The critical section itself
The remainder section
Question 4 of 60
Quiz ID: q4
Which of the following is NOT a requirement for a solution to the critical-section problem?
Mutual Exclusion
Progress
Bounded Waiting
Starvation Freedom
Question 5 of 60
Quiz ID: q5
What does the Progress requirement ensure?
Only one process can be in its critical section at a time
Processes will not wait indefinitely to enter their critical sections
A process will enter its critical section within a bounded number of requests
If no process is in its critical section, a process wishing to enter will be able to do so
Question 6 of 60
Quiz ID: q6
What is the main drawback of the interrupt-based solution to critical sections?
It does not work on uniprocessors
It can lead to starvation
It is inefficient on multiprocessor systems
It violates mutual exclusion
Question 7 of 60
Quiz ID: q7
In the first software solution for two processes, what does the variable 'turn' indicate?
Which process has priority
Which process is currently in its critical section
Which process's turn it is to enter the critical section
How many times each process has entered the critical section
Question 8 of 60
Quiz ID: q8
Why does the first software solution violate the progress requirement?
It allows both processes in the critical section simultaneously
It requires processes to wait even when the critical section is free
It uses a single shared variable
It does not work on modern architectures
Question 9 of 60
Quiz ID: q9
Peterson's solution for two processes uses which shared variables?
turn and flag[2]
lock and key
mutex and condition
semaphore and counter
Question 10 of 60
Quiz ID: q10
What does flag[i] = true indicate in Peterson's solution?
Process i is in its critical section
Process i has exited its critical section
Process i is ready to enter its critical section
Process i is terminated
Question 11 of 60
Quiz ID: q11
Why is Peterson's solution not guaranteed to work on modern architectures?
It uses too many variables
Compilers and processors may reorder instructions
It only works for two processes
It requires atomic load and store instructions
Question 12 of 60
Quiz ID: q12
What is a memory barrier?
A hardware cache
An instruction that forces memory operations to be completed before proceeding
A type of semaphore
A boundary between user and kernel memory
Question 13 of 60
Quiz ID: q13
In a weakly ordered memory model, what is guaranteed?
All memory operations are immediately visible to all processors
Memory operations may not be immediately visible to all processors
Processes execute in a strict sequence
No memory reordering occurs
Question 14 of 60
Quiz ID: q14
Which hardware instruction atomically sets a variable to true and returns its previous value?
Compare-and-Swap
Test-and-Set
Fetch-and-Add
Load-Linked
Question 15 of 60
Quiz ID: q15
What is the main disadvantage of the test-and-set solution for critical sections?
It does not ensure mutual exclusion
It requires busy waiting
It only works for two processes
It uses too many variables
Question 16 of 60
Quiz ID: q16
What does the compare-and-swap instruction do?
Swaps two variables atomically
Compares two variables and swaps them if they are equal
Sets a variable to a new value only if it matches an expected value
Increments a variable atomically
Question 17 of 60
Quiz ID: q17
What is an atomic variable?
A variable that can only be accessed by one process
A variable that is updated without interruption
A variable stored in atomic memory
A variable that is always consistent
Question 18 of 60
Quiz ID: q18
What is a mutex lock?
A hardware instruction
A software tool that protects a critical section using acquire and release operations
A type of semaphore
A memory barrier
Question 19 of 60
Quiz ID: q19
What is busy waiting?
A process waiting in a queue
A process repeatedly checking a condition while waiting
A process that is blocked
A process that is terminated
Question 20 of 60
Quiz ID: q20
What is another name for a mutex lock that uses busy waiting?
Semaphore
Spinlock
Monitor
Condition variable
Question 21 of 60
Quiz ID: q21
What is a semaphore?
A hardware device
An integer variable accessed only through atomic wait and signal operations
A type of mutex lock
A memory barrier
Question 22 of 60
Quiz ID: q22
What is the difference between a counting semaphore and a binary semaphore?
A counting semaphore can have any integer value, while a binary semaphore is only 0 or 1
A binary semaphore is used for mutual exclusion, while a counting semaphore is not
A counting semaphore is implemented in hardware, while a binary semaphore is software
There is no difference
Question 23 of 60
Quiz ID: q23
How can a binary semaphore be used to implement mutual exclusion?
Initialize to 0 and call wait() before the critical section
Initialize to 1 and call wait() before the critical section and signal() after
Initialize to 0 and call signal() before the critical section
Initialize to 1 and call signal() before the critical section and wait() after
Question 24 of 60
Quiz ID: q24
What is the purpose of the block() operation in semaphore implementation?
To busy wait
To place a process on the waiting queue
To remove a process from the waiting queue
To execute the critical section
Question 25 of 60
Quiz ID: q25
What is the purpose of the wakeup() operation in semaphore implementation?
To start a new process
To remove a process from the waiting queue and place it in the ready queue
To terminate a process
To signal a condition variable
Question 26 of 60
Quiz ID: q26
What is a monitor?
A hardware synchronization tool
A high-level abstraction that provides convenient process synchronization
A type of semaphore
A memory barrier
Question 27 of 60
Quiz ID: q27
How is mutual exclusion achieved within a monitor?
By using semaphores
By the monitor's implementation ensuring only one process can be active inside at a time
By using condition variables
By disabling interrupts
Question 28 of 60
Quiz ID: q28
What are condition variables used for in a monitor?
To protect the monitor's entry
To allow processes to wait for certain conditions within the monitor
To signal the end of the critical section
To implement busy waiting
Question 29 of 60
Quiz ID: q29
What does x.wait() do on a condition variable?
Increments a counter
Suspends the process until x.signal() is called
Signals all waiting processes
Exits the monitor
Question 30 of 60
Quiz ID: q30
What does x.signal() do on a condition variable?
Resumes one process waiting on x
Resumes all processes waiting on x
Suspends the current process
Exits the monitor
Question 31 of 60
Quiz ID: q31
How can monitors be implemented using semaphores?
Use a binary semaphore to protect the monitor entry
Use a counting semaphore for each condition variable
Use a semaphore for mutual exclusion and semaphores for condition variables
Monitors cannot be implemented with semaphores
Question 32 of 60
Quiz ID: q32
What is the purpose of the 'next' semaphore in the monitor implementation?
To signal the next process to enter the monitor
To manage processes waiting on condition variables
To provide mutual exclusion
To indicate the monitor is free
Question 33 of 60
Quiz ID: q33
What is the conditional-wait construct x.wait(c) used for?
To wait for a specific time
To wait with a priority number
To wait for a condition variable
To wait for a semaphore
Question 34 of 60
Quiz ID: q34
In the resource allocator monitor, what does the acquire(int time) operation do?
Allocates the resource immediately
Waits for the resource with a priority based on time
Releases the resource
Signals all waiting processes
Question 35 of 60
Quiz ID: q35
What is liveness?
The speed of process execution
A set of properties ensuring processes make progress
The ability to create new processes
The opposite of deadlock
Question 36 of 60
Quiz ID: q36
What is deadlock?
A process terminating unexpectedly
Two or more processes waiting indefinitely for an event that can only be caused by one of them
A process that is starved
A type of memory error
Question 37 of 60
Quiz ID: q37
How can deadlock occur with semaphores?
If a process forgets to call signal()
If two processes acquire semaphores in opposite orders
If semaphores are initialized to 0
If semaphores are binary
Question 38 of 60
Quiz ID: q38
What is starvation?
A process that is terminated
A process that is indefinitely blocked from accessing a resource
A type of deadlock
A memory allocation error
Question 39 of 60
Quiz ID: q39
What is priority inversion?
When a high-priority process waits for a low-priority process
When priorities are assigned incorrectly
When all processes have the same priority
When a process changes its own priority
Question 40 of 60
Quiz ID: q40
How can priority inversion be solved?
By disabling interrupts
By using a priority-inheritance protocol
By increasing the priority of all processes
By using a spinlock
Question 41 of 60
Quiz ID: q41
Which of the following is a hardware instruction for synchronization?
wait()
signal()
compare-and-swap()
block()
Question 42 of 60
Quiz ID: q42
What is the initial value of a binary semaphore used for mutual exclusion?
0
1
2
N
Question 43 of 60
Quiz ID: q43
In the semaphore implementation without busy waiting, what does the value of the semaphore represent?
The number of processes in the critical section
The number of available resources
The number of processes waiting on the semaphore
The priority of the next process
Question 44 of 60
Quiz ID: q44
What is the main advantage of using monitors over semaphores?
Monitors are faster
Monitors are easier to use correctly
Monitors are implemented in hardware
Monitors do not require condition variables
Question 45 of 60
Quiz ID: q45
What is the key difference between a mutex lock and a binary semaphore?
A mutex lock has ownership, a semaphore does not
A binary semaphore can be used for counting
A mutex lock can be signaled by any process, a semaphore cannot
There is no difference
Question 46 of 60
Quiz ID: q46
What is the purpose of the initialization code in a monitor?
To initialize the monitor's local variables
To initialize the condition variables
To initialize the shared data
To start the monitor process
Question 47 of 60
Quiz ID: q47
In the bounded-waiting solution using compare-and-swap, what is the purpose of the waiting array?
To indicate which processes are in the critical section
To indicate which processes are waiting to enter the critical section
To store the turn values
To implement condition variables
Question 48 of 60
Quiz ID: q48
What is the effect of instruction reordering on Peterson's solution?
It makes it faster
It can break mutual exclusion
It prevents deadlock
It ensures progress
Question 49 of 60
Quiz ID: q49
What is the key takeaway from the modern architecture example with Thread 1 and Thread 2?
Threads always execute in order
Instruction reordering can lead to unexpected results
Memory barriers are unnecessary
Variables are always immediately visible
Question 50 of 60
Quiz ID: q50
Which synchronization tool is specifically designed to avoid busy waiting?
Spinlock
Mutex lock with test-and-set
Semaphore with block() and wakeup()
Peterson's solution
Question 51 of 60
Quiz ID: q51
What is the primary use of a counting semaphore?
Mutual exclusion
Synchronizing multiple instances of a resource
Implementing condition variables
Priority scheduling
Question 52 of 60
Quiz ID: q52
In the monitor implementation, what is the purpose of the next_count variable?
To count the number of processes in the monitor
To count the number of processes waiting on the 'next' semaphore
To count the number of condition variables
To count the number of signals
Question 53 of 60
Quiz ID: q53
What is the significance of the value returned by compare-and-swap?
It indicates whether the swap was successful
It is the new value of the variable
It is the old value of the variable
It is the expected value
Question 54 of 60
Quiz ID: q54
How does the test-and-set instruction work?
It sets a variable to true and returns its previous value
It sets a variable to false and returns its previous value
It compares two variables and sets a third
It swaps two variables
Question 55 of 60
Quiz ID: q55
What is a common use of atomic variables?
To implement counters without locking
To replace semaphores
To create mutex locks
To implement monitors
Question 56 of 60
Quiz ID: q56
What is the main problem with the incorrect use of semaphores?
It can lead to deadlock or starvation
It makes programs run slower
It requires more memory
It is not portable
Question 57 of 60
Quiz ID: q57
What is the role of the mutex semaphore in the monitor implementation?
To protect the condition variables
To ensure mutual exclusion for entry into the monitor
To manage the waiting queue
To signal processes
Question 58 of 60
Quiz ID: q58
In the resource allocator monitor, what is the purpose of the 'busy' variable?
To indicate if the resource is currently allocated
To count the number of waiting processes
To store the priority of the next process
To implement the condition variable
Question 59 of 60
Quiz ID: q59
What is the key characteristic of a strongly ordered memory model?
Memory operations may be reordered
Memory operations are immediately visible to all processors
It is slower than weakly ordered
It requires memory barriers
Question 60 of 60
Quiz ID: q60
What is the final step in the monitor's procedure execution?
Signal the mutex semaphore
Check if next_count > 0 and signal the 'next' semaphore, else signal mutex
Signal all condition variables
Block the process
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