OS Flashcards
(8 cards)
Define concurrency in the context of process/thread synchronization.
What is mutual exclusion in operating systems?
Concurrency: Multiple processes/threads simultaneously
Mutex: prevents multiple processes from entering in critical state at the same time
Utilized using sempahores and locks
Characteristics:
1 One process in CS at a time
2 Other processes wait
3 Used to prevent deadlocks and race condition
Conditions for deadlock. Break down the strategies used for deadlock prevention into their core principles.
1 Mutual Exclusion (shareable resources or multiple instances of one resource)
2 Hold and wait (requests all required resources before execution)
3 No pre-emption (allow pre-emption)
4 Circular Wait (ordering of resource types - allow according to enum number)
What is the Ostrich Algorithm in the context of deadlock?
List the necessary conditions for a deadlock to occur.
The Ostrich Algorithm is a non-preventive approach to handling deadlocks.
Used When: Deadlocks are extremely rare and the cost of prevention, detection, or recovery outweighs the impact of the deadlock itself.
Typical Use Case: UNIX or Windows, where deadlocks may occur very infrequently, and system reboot or manual intervention can resolve them.
Critical section problem prevention
Mutual Exc
Progress (no forcing each other)
Bounded Wait (No indefinite time)
H/W | S/W mutex
H/W
Adv: Faster execution, low overhead, reliability
Disadv: limited protability, h/w dependence
S/W
Adv: portability, felxibility, easy to implement
Disadv: higher overhead, more prone to error
Semaphore | Monitor
1 controls access to shared resources | high-level synch method for shared resources
2 low-level synch primitive | high-level synch primitive
3 complex to implement | easy due to encapsulation
4 manual resource management | automatic resource management
5 does not provide mutex inherently | provides through lock mech
6 can implemented in both h/w, s/w | implemented using lock and combination values
7 uses explicit signal and wait | uses implicit signal through condition variables
mutex | semaphore
1 allow only one process to access | allow access to shared resources
2 only one process can lock | counting lock multiple processes can
3 owned by process that locks it | no ownership
4 binary | can have counting value
5 protects critical section | manage shared resources
6 operations: lock and unlock | operations: signal and wait
7 can lead to starvation | less prone to starvation due to fifo
8 simple to implement | complex to implement