This beginner-friendly quiz examines fundamental concepts of process synchronization, including mutual exclusion, race conditions, semaphores, and deadlocks. Designed to help learners reinforce their understanding of key synchronization principles and techniques used in operating systems.
Which concept ensures that only one process at a time can access a shared resource to prevent data inconsistency?
Explanation: Mutual exclusion ensures that a shared resource is accessed by only one process at a time, which prevents race conditions and data inconsistency. Deadlock refers to processes waiting indefinitely for resources, not to exclusive access. Livelock means processes continuously change states without progress, which doesn’t guarantee exclusive access. Throughput measures the number of tasks completed in a given time and is unrelated to resource access control.
What is the term for the situation where the system’s behavior depends on the sequence or timing of uncontrollable events, such as two processes updating a shared variable at the same time?
Explanation: A race condition occurs when different threads or processes access shared data concurrently and the final outcome depends on the order of access. Semaphore is a synchronization tool, not a problem itself. The critical section is the part of the code accessing shared resources, not the condition. Starvation refers to processes not getting the resources they need, but not due to access order.
Which of the following synchronization primitives can be used to control access to a common resource by multiple processes in a concurrent system?
Explanation: Semaphores are widely used as synchronization tools to control access to shared resources by multiple processes in concurrent systems. Algorithm is a general term and not a specific synchronization primitive. Pipeline refers to a data processing sequence, not an access control mechanism. Loop controls repetitive execution, not synchronization.
When several threads increment the same counter variable, which part of the code needs to be protected to avoid incorrect results?
Explanation: The code segment that accesses and modifies the shared counter variable is known as the critical section and must be protected to avoid race conditions. Stack and heap refer to memory areas, not specific code segments to be protected. Index is simply a variable or value, not a code section needing synchronization.
Which term describes a situation where two or more processes are blocked forever, each waiting for the other to release a resource?
Explanation: Deadlock occurs when two or more processes are waiting indefinitely for resources held by each other, preventing progress. Lockout is an incorrect term for this phenomenon. Overflow refers to exceeding storage capacity, not process blocking. Liveblock is not a recognized process synchronization term.
What is the name of a lock where a process repeatedly checks if a resource is available instead of sleeping while waiting?
Explanation: A spinlock is a type of lock in which a process repeatedly checks if the lock is available, using CPU cycles while waiting. Twistlock and bypasslock are invalid terms in process synchronization. Waitlock may suggest waiting, but does not describe the behavior of actively checking like a spinlock.
When a process waits for a resource by continuously checking its status without relinquishing the CPU, what is this practice called?
Explanation: Busy waiting occurs when a process actively checks for a resource, consuming CPU time during the wait. Silent waiting is not a standard term. Passive blocking means the process waits without using CPU, which contrasts with busy waiting. Sleep mode denotes a low-power state, not a process synchronization activity.
What is it called when a process never gets the required resources because other processes are continuously prioritized over it?
Explanation: Starvation refers to a situation where a process is perpetually denied necessary resources because other processes receive priority. Mutiny, breakage, and frame skipping are unrelated to process synchronization and do not describe this concept.
In process synchronization, what is the main function of a monitor construct?
Explanation: Monitors are a high-level synchronization construct designed to ensure that only one process can execute a critical section at a time and to manage condition synchronization efficiently. Monitoring hardware errors is not relevant here. Logging user activities is unrelated to process synchronization. Scheduling processes is a different aspect managed by the operating system's scheduler.
Which scenario best demonstrates the use of a counting semaphore in process synchronization?
Explanation: A counting semaphore is used when a system must limit the number of processes that can access a particular resource, like a printer queue, to a fixed number. Controlling access to a single-user resource requires a binary semaphore, not a counting one. Sorting arrays and compiling programs do not relate to process synchronization through semaphores.