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:
- A.Two processes have the same scheduling priority level
- B.Outcome depends on execution order of shared data access✓ Correct
- C.A process runs too fast for the system to handle
- 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:
- A.The most important section of a running program
- B.Code segment accessing shared resources exclusively✓ Correct
- C.The first section executed when a program starts
- 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:
- A.Processes must exclude each other from the system
- B.Two processes can be in critical sections at once
- C.No process is ever allowed to enter any section
- 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:
- A.A hardware component on the motherboard
- B.A type of running process in the system
- C.A synchronization tool using acquire and release✓ Correct
- 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:
- A.A type of hardware interrupt signal
- B.A CPU scheduling algorithm technique
- C.A type of boolean flag variable
- 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:
- A.Only negative value range
- B.Any positive integer value
- C.Only zero and one values✓ Correct
- 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:
- A.Any non-negative integer value
- B.Only negative value ranges
- C.Only zero and one values
- 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:
- A.A process is waiting for I/O completion
- B.A process is terminated by the operating system
- C.A process continuously loops testing a condition✓ Correct
- 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?
- A.Atomicity, consistency, and isolation
- B.Fairness, priority, and preemption
- C.Mutual exclusion, progress, bounded waiting✓ Correct
- 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:
- A.P operation (proberen)✓ Correct
- B.V operation (verhogen)
- C.Lock operation call
- 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?
- A.A solution implemented using monitors
- B.A hardware-based solution only
- C.A solution implemented using semaphores
- 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:
- A.A specific type of semaphore implementation
- B.An atomic hardware instruction to test and set✓ Correct
- C.A scheduling algorithm for critical sections
- 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:
- A.Compares two files and swaps their contents
- B.Compares the speeds of two different CPUs
- C.Atomically compares and swaps a memory value✓ Correct
- 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:
- A.A specific type of counting semaphore lock mechanism
- B.A construct encapsulating shared data with mutual exclusion✓ Correct
- C.A hardware lock on the system memory bus interface
- 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?
- A.push() and pop()
- B.acquire() and release()
- C.wait() and signal()✓ Correct
- 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?
- A.One counting semaphore for the buffer
- B.Only a single mutex lock for the buffer
- C.Mutex plus empty and full semaphores✓ Correct
- 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?
- A.Only one reader can read the data at a time
- B.Only one process can ever access the shared database
- C.Writers can write while readers are actively reading
- 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?
- A.Short critical sections on multiprocessor systems✓ Correct
- B.Any critical section on single processor only
- C.I/O-bound processes waiting for disk access
- 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?
- A.Changing process priorities dynamically at runtime
- B.Assigning priorities in reverse numerical order
- C.A scheduling bug in all operating system kernels
- 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:
- A.Raising low-priority to match highest waiting✓ Correct
- B.Blocking all medium-priority from running
- C.Terminating the low-priority resource holder
- 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?
- A.A problem about memory allocation fragmentation
- B.A problem about restaurant management logistics
- C.A concurrency problem illustrating deadlock and starvation✓ Correct
- 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?
- A.Add more chopsticks than the total number of diners
- B.Give each philosopher two dedicated chopsticks to use
- C.Limit sitting philosophers, use asymmetric or monitors✓ Correct
- 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?
- A.A lock used only for writing to shared data
- B.A lock only used for file read operations
- C.A lock that prevents all access to a resource
- 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)?
- A.A physical barrier inside memory chip hardware
- B.A limit on the total memory allocation size
- C.An instruction enforcing memory operation ordering✓ Correct
- 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?
- A.Algorithms that use no synchronization at all
- B.Algorithms that run without any operating system
- C.Algorithms using atomic ops like CAS, no locks✓ Correct
- 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?
- A.There is no difference between the two at all
- B.First is for single CPU; second for multiprocessor
- C.First uses semaphores; the second uses only monitors
- 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?
- A.Hoare signal transfers control; Mesa is just a hint✓ Correct
- B.They use different programming languages entirely
- C.Mesa-style monitors are older than Hoare-style
- 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?
- A.Memory transferred between running processes
- B.Atomic memory operations similar to databases✓ Correct
- C.A type of CPU cache for fast computations
- 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?
- A.A deadlock scenario involving two blocked threads
- B.A naming convention issue in the source code
- C.A problem with kernel memory allocation routines
- 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?
- A.User-space mutex with kernel support on contention✓ Correct
- B.A fast file transfer utility for networks
- C.A type of file lock for exclusive access
- 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