Process Synch Multiple Choice Questions
Process Synch Multiple Choice Questions
o C) To ensure that concurrent processes do not interfere with each other while
accessing shared resources.
Answer: C) To ensure that concurrent processes do not interfere with each other while accessing
shared resources.
o A) Dining Philosophers
o B) Memory Management
o C) Disk Scheduling
o D) Page Replacement
o A) Mutex
o B) Cache
o C) File System
o D) Buffer
Answer: A) Mutex
o A) It decrements the semaphore value and may block if the value is less than zero.
Answer: B) It increments the semaphore value and may wake up a blocked process.
True/False Questions
Answer: True
2. True or False: Deadlock can occur when two or more processes are each waiting for the
other to release resources.
Answer: True
3. True or False: In a producer-consumer problem, the producer generates items and places
them in a buffer while the consumer removes items from the buffer.
Answer: True
Answer: False
5. True or False: The 'P' (wait) operation on a semaphore decrements its value and may cause
the process to block if the value is zero or negative.
Answer: True
What is the difference between a binary semaphore and a counting semaphore?
Answer: A binary semaphore can only take the values 0 and 1, making it useful for mutual exclusion
(mutex). A counting semaphore can take any non-negative integer value and is used to control access
to a resource pool with a limited number of instances.
Answer: A race condition occurs when the outcome of a process depends on the sequence or timing
of uncontrollable events. For example, if two processes are incrementing a shared counter without
synchronization, they may both read the same value and increment it, leading to incorrect results.
Explain how the 'Test and Set' operation can be used to implement a lock.
Answer: The 'Test and Set' operation atomically tests a value and sets it to a new value if it is
currently a specific old value. It can be used to implement a lock by testing if a lock is free (typically
represented by 0) and setting it to 1 (locked) if it is free. This operation is atomic, preventing race
conditions.
What is a deadlock, and what are the four necessary conditions for it to occur?
Answer: A deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource held by another process. The four necessary
conditions are:
Mutual exclusion
No preemption
Circular wait
Answer: A mutex is a synchronization primitive that provides mutual exclusion by allowing only one
process to access a critical section at a time. A semaphore is a more general synchronization
primitive that can be used to manage access to a resource pool and can signal between processes.
Semaphores can be binary (similar to mutexes) or counting, which allows managing multiple
resources.