HomeSubjectsUniversityBlogAbout

Concurrency & Synchronization

Topic in Operating Systems

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

Process synchronization is the coordination of concurrent processes or threads so that shared data stays consistent when several of them access it at once. Questions start with race conditions and the critical-section problem, whose solutions must satisfy mutual exclusion, progress and bounded waiting. You will be asked to trace Peterson's solution, explain hardware support such as test-and-set and compare-and-swap, and compare mutex locks, spinlocks and counting or binary semaphores with their wait() and signal() operations. Classic problems (bounded buffer, readers-writers, dining philosophers) are heavily used, along with monitors and condition variables, priority inversion, and the priority inheritance and ceiling protocols.

Below are 30 practice questions from a pool of 210 Concurrency & Synchronization MCQs, one of 12 topics in Operating Systems. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.

Practice Questions

Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.

Concurrency & SynchronizationEasy

Q1. A race condition occurs when:

  1. A.Two processes have the same scheduling priority level
  2. B.Outcome depends on execution order of shared data access✓ Correct
  3. C.A process runs too fast for the system to handle
  4. D.Two processes run on the CPU simultaneously

Explanation

A race condition occurs when multiple processes or threads access shared data concurrently and the final result depends on the particular order of execution, leading to unpredictable outcomes.

Report an error in this question

Concurrency & SynchronizationEasy

Q2. The critical section is:

  1. A.The most important section of a running program
  2. B.Code segment accessing shared resources exclusively✓ Correct
  3. C.The first section executed when a program starts
  4. D.A section within the operating system kernel code

Explanation

The critical section is the portion of code where a process accesses shared resources (variables, files, etc.). Only one process should be in its critical section at a time to prevent race conditions.

Report an error in this question

Concurrency & SynchronizationEasy

Q3. Mutual exclusion means:

  1. A.Processes must exclude each other from the system
  2. B.Two processes can be in critical sections at once
  3. C.No process is ever allowed to enter any section
  4. D.Only one process can be in its critical section✓ Correct

Explanation

Mutual exclusion ensures that when one process is executing in its critical section, no other process is allowed to execute in its critical section, preventing concurrent access to shared resources.

Report an error in this question

Concurrency & SynchronizationEasy

Q4. A mutex lock is:

  1. A.A hardware component on the motherboard
  2. B.A type of running process in the system
  3. C.A synchronization tool using acquire and release✓ Correct
  4. D.A type of physical memory module

Explanation

A mutex (mutual exclusion) lock is a synchronization tool with two operations: acquire (lock) and release (unlock). A process must acquire the lock before entering the critical section and release it when done.

Report an error in this question

Concurrency & SynchronizationEasy

Q5. A semaphore is:

  1. A.A type of hardware interrupt signal
  2. B.A CPU scheduling algorithm technique
  3. C.A type of boolean flag variable
  4. D.A variable accessed via wait and signal✓ Correct

Explanation

A semaphore is an integer variable accessed through two atomic operations: wait (P/down) decrements it, and signal (V/up) increments it. It is used for synchronization and mutual exclusion.

Report an error in this question

Concurrency & SynchronizationEasy

Q6. A binary semaphore can have values:

  1. A.Only negative value range
  2. B.Any positive integer value
  3. C.Only zero and one values✓ Correct
  4. D.Any integer value at all

Explanation

A binary semaphore can only have values 0 or 1, functioning similarly to a mutex lock. It is used to provide mutual exclusion for accessing a single shared resource.

Report an error in this question

Concurrency & SynchronizationEasy

Q7. A counting semaphore can have values:

  1. A.Any non-negative integer value
  2. B.Only negative value ranges
  3. C.Only zero and one values
  4. D.Unrestricted integer domain✓ Correct

Explanation

A counting semaphore can range over an unrestricted integer domain. It is used to control access to a resource with a finite number of instances, tracking available resources.

Report an error in this question

Concurrency & SynchronizationEasy

Q8. Busy waiting (spinlock) means:

  1. A.A process is waiting for I/O completion
  2. B.A process is terminated by the operating system
  3. C.A process continuously loops testing a condition✓ Correct
  4. D.A process is sleeping and waiting for a signal

Explanation

Busy waiting (spinning) occurs when a process repeatedly checks a condition in a loop while waiting, consuming CPU cycles. A spinlock is a lock that uses busy waiting.

Report an error in this question

Concurrency & SynchronizationEasy

Q9. What are the three requirements for a solution to the critical section problem?

  1. A.Atomicity, consistency, and isolation
  2. B.Fairness, priority, and preemption
  3. C.Mutual exclusion, progress, bounded waiting✓ Correct
  4. D.Speed, efficiency, and simplicity

Explanation

A correct solution must satisfy: (1) Mutual exclusion - only one process in CS at a time, (2) Progress - selection of next process cannot be postponed indefinitely, (3) Bounded waiting - a limit on how long a process waits.

Report an error in this question

Concurrency & SynchronizationEasy

Q10. The wait() operation on a semaphore is also known as:

  1. A.P operation (proberen)✓ Correct
  2. B.V operation (verhogen)
  3. C.Lock operation call
  4. D.Signal operation call

Explanation

The wait() operation is also known as P (from Dutch 'proberen' meaning 'to test'). It decrements the semaphore value and blocks the process if the value becomes negative.

Report an error in this question

Concurrency & SynchronizationMedium

Q11. What is Peterson's solution for the critical section problem?

  1. A.A solution implemented using monitors
  2. B.A hardware-based solution only
  3. C.A solution implemented using semaphores
  4. D.A software solution using turn and flag✓ Correct

Explanation

Peterson's solution is a classic software-based solution for two processes. It uses a 'turn' variable and a 'flag' array to ensure mutual exclusion, progress, and bounded waiting without hardware support.

Report an error in this question

Concurrency & SynchronizationMedium

Q12. The test-and-set instruction is:

  1. A.A specific type of semaphore implementation
  2. B.An atomic hardware instruction to test and set✓ Correct
  3. C.A scheduling algorithm for critical sections
  4. D.A software-only algorithm for locking

Explanation

Test-and-set is an atomic hardware instruction that reads a value, sets it to true, and returns the old value - all in a single uninterruptible operation, useful for implementing locks.

Report an error in this question

Concurrency & SynchronizationMedium

Q13. The compare-and-swap (CAS) instruction:

  1. A.Compares two files and swaps their contents
  2. B.Compares the speeds of two different CPUs
  3. C.Atomically compares and swaps a memory value✓ Correct
  4. D.Swaps two processes in the scheduling queue

Explanation

CAS atomically compares the content of a memory location with an expected value and, only if they match, modifies it to a new value. It is the foundation for many lock-free data structures.

Report an error in this question

Concurrency & SynchronizationMedium

Q14. A monitor is:

  1. A.A specific type of counting semaphore lock mechanism
  2. B.A construct encapsulating shared data with mutual exclusion✓ Correct
  3. C.A hardware lock on the system memory bus interface
  4. D.A display device or screen monitor unit

Explanation

A monitor is a high-level synchronization construct where shared data variables are encapsulated with the procedures that operate on them. Only one process can be active within a monitor at a time.

Report an error in this question

Concurrency & SynchronizationMedium

Q15. Condition variables in monitors are used with which operations?

  1. A.push() and pop()
  2. B.acquire() and release()
  3. C.wait() and signal()✓ Correct
  4. D.lock() and unlock()

Explanation

Condition variables in monitors use wait() (process suspends itself) and signal() (resumes one suspended process). Unlike semaphores, signal() on a condition variable has no effect if no process is waiting.

Report an error in this question

Concurrency & SynchronizationMedium

Q16. In the bounded buffer problem, what are the semaphores typically used?

  1. A.One counting semaphore for the buffer
  2. B.Only a single mutex lock for the buffer
  3. C.Mutex plus empty and full semaphores✓ Correct
  4. D.Two binary semaphores for the buffer

Explanation

The bounded buffer uses three semaphores: mutex (binary, for mutual exclusion of buffer access), empty (counting, initialized to buffer size for empty slots), and full (counting, initialized to 0 for filled slots).

Report an error in this question

Concurrency & SynchronizationMedium

Q17. In the readers-writers problem, what is the key synchronization challenge?

  1. A.Only one reader can read the data at a time
  2. B.Only one process can ever access the shared database
  3. C.Writers can write while readers are actively reading
  4. D.Multiple readers can read; writers need exclusive access✓ Correct

Explanation

Multiple readers can read simultaneously without issues, but a writer needs exclusive access to the shared data. The challenge is allowing concurrent reads while ensuring exclusive write access.

Report an error in this question

Concurrency & SynchronizationMedium

Q18. What is a spinlock most useful for?

  1. A.Short critical sections on multiprocessor systems✓ Correct
  2. B.Any critical section on single processor only
  3. C.I/O-bound processes waiting for disk access
  4. D.Long critical sections on single processors

Explanation

Spinlocks are most useful for short critical sections on multiprocessors because busy waiting on one CPU while another CPU executes the critical section avoids the overhead of a context switch.

Report an error in this question

Concurrency & SynchronizationMedium

Q19. What is priority inversion?

  1. A.Changing process priorities dynamically at runtime
  2. B.Assigning priorities in reverse numerical order
  3. C.A scheduling bug in all operating system kernels
  4. D.High-priority blocked by low-priority holding resource✓ Correct

Explanation

Priority inversion occurs when a high-priority process is blocked waiting for a resource held by a low-priority process, and a medium-priority process preempts the low-priority process, effectively blocking the high-priority process.

Report an error in this question

Concurrency & SynchronizationMedium

Q20. Priority inheritance protocol solves priority inversion by:

  1. A.Raising low-priority to match highest waiting✓ Correct
  2. B.Blocking all medium-priority from running
  3. C.Terminating the low-priority resource holder
  4. D.Removing all priorities from every process

Explanation

Priority inheritance temporarily elevates the priority of the process holding a resource to the priority of the highest-priority process waiting for that resource, preventing medium-priority processes from causing inversion.

Report an error in this question

Concurrency & SynchronizationHard

Q21. What is the dining philosophers problem and why is it significant?

  1. A.A problem about memory allocation fragmentation
  2. B.A problem about restaurant management logistics
  3. C.A concurrency problem illustrating deadlock and starvation✓ Correct
  4. D.A problem about network packet routing efficiency

Explanation

The dining philosophers problem has 5 philosophers sharing 5 chopsticks. It illustrates how concurrent processes competing for limited resources can lead to deadlock and starvation if not properly synchronized.

Report an error in this question

Concurrency & SynchronizationHard

Q22. How can the dining philosophers problem be solved to prevent deadlock?

  1. A.Add more chopsticks than the total number of diners
  2. B.Give each philosopher two dedicated chopsticks to use
  3. C.Limit sitting philosophers, use asymmetric or monitors✓ Correct
  4. D.Remove one philosopher from the dining table entirely

Explanation

Solutions include: allowing at most n-1 philosophers to sit, picking up both chopsticks atomically, using asymmetric ordering (odd picks left first, even picks right first), or using monitor-based solutions.

Report an error in this question

Concurrency & SynchronizationHard

Q23. What is a read-write lock and when is it preferred over a mutex?

  1. A.A lock used only for writing to shared data
  2. B.A lock only used for file read operations
  3. C.A lock that prevents all access to a resource
  4. D.Allows concurrent reads but requires exclusive writes✓ Correct

Explanation

A read-write lock allows multiple threads to hold it for reading simultaneously but requires exclusive access for writing. It is preferred when reads are much more frequent than writes.

Report an error in this question

Concurrency & SynchronizationHard

Q24. What is a memory barrier (memory fence)?

  1. A.A physical barrier inside memory chip hardware
  2. B.A limit on the total memory allocation size
  3. C.An instruction enforcing memory operation ordering✓ Correct
  4. D.A type of virtual memory address translation

Explanation

A memory barrier is an instruction that forces all memory operations before it to complete before any memory operations after it begin, preventing CPU and compiler reorderings that could cause synchronization bugs.

Report an error in this question

Concurrency & SynchronizationHard

Q25. What are lock-free algorithms and why are they important?

  1. A.Algorithms that use no synchronization at all
  2. B.Algorithms that run without any operating system
  3. C.Algorithms using atomic ops like CAS, no locks✓ Correct
  4. D.Algorithms that are never blocked by anything

Explanation

Lock-free algorithms use atomic operations (CAS, fetch-and-add) instead of traditional locks. They guarantee system-wide progress, avoid deadlock, and often provide better performance and scalability under contention.

Report an error in this question

Concurrency & SynchronizationHard

Q26. In the readers-writers problem, what is the difference between the first and second variants?

  1. A.There is no difference between the two at all
  2. B.First is for single CPU; second for multiprocessor
  3. C.First uses semaphores; the second uses only monitors
  4. D.First favors readers no wait; second favors writers✓ Correct

Explanation

In the first variant, readers have priority (may cause writer starvation). In the second variant, writers have priority (once a writer is waiting, no new readers are admitted, which may cause reader starvation).

Report an error in this question

Concurrency & SynchronizationHard

Q27. What is the difference between Hoare-style and Mesa-style monitors?

  1. A.Hoare signal transfers control; Mesa is just a hint✓ Correct
  2. B.They use different programming languages entirely
  3. C.Mesa-style monitors are older than Hoare-style
  4. D.Hoare-style monitors are faster than Mesa-style

Explanation

In Hoare-style monitors, signal() immediately switches to the waiting process. In Mesa-style (used by Java, Pthreads), signal() is a hint, so the awakened process must recheck the condition (use while, not if).

Report an error in this question

Concurrency & SynchronizationHard

Q28. What is transactional memory?

  1. A.Memory transferred between running processes
  2. B.Atomic memory operations similar to databases✓ Correct
  3. C.A type of CPU cache for fast computations
  4. D.Memory used for financial transactions only

Explanation

Transactional memory allows a sequence of read/write operations to execute atomically. If a conflict is detected, the transaction is aborted and retried. It can be implemented in hardware (HTM) or software (STM).

Report an error in this question

Concurrency & SynchronizationHard

Q29. What is the ABA problem in lock-free programming?

  1. A.A deadlock scenario involving two blocked threads
  2. B.A naming convention issue in the source code
  3. C.A problem with kernel memory allocation routines
  4. D.CAS succeeds incorrectly due to A-to-B-to-A change✓ Correct

Explanation

The ABA problem occurs when a memory location is read as A, another thread changes it to B then back to A, and the original thread's CAS succeeds thinking nothing changed. Solutions include version counters or hazard pointers.

Report an error in this question

Concurrency & SynchronizationHard

Q30. What is a futex (fast userspace mutex) in Linux?

  1. A.User-space mutex with kernel support on contention✓ Correct
  2. B.A fast file transfer utility for networks
  3. C.A type of file lock for exclusive access
  4. D.A network protocol for data synchronization

Explanation

A futex combines user-space atomic operations for the fast (uncontended) path with kernel-based waiting for the slow (contended) path, providing efficient synchronization by avoiding system calls in the common case.

Report an error in this question

Ready to test yourself on Concurrency & Synchronization?

Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.

Start Concurrency & Synchronization Quiz