Operating System: Question Set – 32
What is concurrency in operating systems?
The ability of the operating system to run several threads or processes at once is known as concurrency. This may entail coordinating several separate jobs concurrently or overlapping activities.
Why is concurrency control important in operating systems?
Concurrency control is crucial to:
- Prevent data inconsistencies caused by simultaneous access.
- Ensure fairness among processes.
- Avoid deadlocks, race conditions, and starvation.
- Maintain system stability and reliability.
What are race conditions?
When several threads or processes access shared data at the same time and the result is dependent on the order of execution, this is known as a race condition. It frequently results in erratic actions or mistakes.
What is mutual exclusion?
Mutual exclusion ensures that only one process can access a critical section (shared resource or code segment) at a time. It prevents race conditions and maintains data consistency.
What are the methods to achieve mutual exclusion?
Mutual exclusion can be achieved using:
- Locks: Simple mechanisms to restrict access.
- Semaphores: Counting variables used to control access.
- Monitors: High-level abstractions with built-in mutual exclusion.
- Mutexes: Specialized locks for mutual exclusion.
What are the conditions for a solution to the critical section problem?
The solution must satisfy:
- Mutual Exclusion: Only one process accesses the critical section at a time.
- Progress: No process outside the critical section should block others.
- Bounded Waiting: Every process gets a chance to execute the critical section within a finite time.
What is a semaphore in concurrency control?
A semaphore is a synchronization tool that uses a counter to control access to shared resources. Types of semaphores:
- Binary Semaphore: Takes values 0 or 1; equivalent to a lock.
- Counting Semaphore: Allows a specified number of processes to access the resource concurrently.
What are the operations on semaphores?
- Wait (P operation): Decrements the semaphore value. If the value is negative, the process is blocked.
- Signal (V operation): Increments the semaphore value. If there are blocked processes, one is unblocked.
What is a monitor in concurrency?
A monitor is a high-level synchronization construct that combines synchronization primitives, shared resources, and methods. It guarantees that a monitor procedure is only carried out by one process at a time.
What is a deadlock in concurrency?
A deadlock occurs when a group of processes is waiting for resources held by each other, and none can proceed. It is a state of indefinite blocking.
What are the types of locks used in concurrency control?
- Spinlocks: Busy-wait locks that continuously check until the lock is available.
- Read-Write Locks: Allow multiple readers or one writer at a time.
- Reentrant Locks: Allow a thread to acquire the same lock multiple times.
- Distributed Locks: Used in distributed systems for synchronization.
What is two-phase locking (2PL)?
Two-phase locking is a protocol for achieving serializability:
- Growing Phase: Processes acquire all locks they need.
- Shrinking Phase: Processes release locks and cannot acquire new ones.