Section 4: Synchronization and Concurrency - bmitch26/Operating-Systems GitHub Wiki
Section 4. Synchronization and Concurrency
Critical Section
Segment of code that accesses shared resources and is executed by multiple threads/processes at the same time.
Source
Mutual Exclusion
Property of Process Synchronization coined by Dijkstra that states "no two processes can exist in the critical
section at any given point of time". Usually meant to avoid simultaneous use of a common resource.
Source
Race Conditions
Situation in which the the result of multiple thread execution in a critical section changes according to the order the threads
execute. Source
Semaphores
Variables used to coordinate multiple processes in a system, and are utilized to enforce mutual exclusion, avoid race conditions,
and implement synchronization between processes. Works by using Wait (P) and Signal (V) operations to block or permit a process.
Source
Mutexes
Mainly used to provide mutual exclusion to a specific part of the code and enforces strict ownership.
Source
Monitors
Implemented as programming language constructs meant to simplify process synchronization by providing high-level abstraction for
data access. Also provides mutual exclusion, condition variables, and data encapsulation within one construct.
Source
Deadlock
Situation where multiple processes are stuck waiting for another to stop using a required resource.
Source
Starvation
Situation where a process keeps getting pushed down as a low-priority and is left blocked from any CPU utilization indefinitely.
Source
Busy Waiting
Process synchronization technique where the process waits for a condition to be satisfied before continuing with its execution.
Source
Condition Variables
Synchronization method to make one thread wait until another has notified it that the shared resource is available to access.
Source
Spinlocks
Synchronization method to protect shared resources being accessed by multiple threads/processes at the same time. Uses
busy-wait method to have a thread select a lock until it becomes available.
Source
Atomic Operations
Operations that execute without interruption from any other process and can't be broken down any further.
Source
Problem: Both the producers and the consumers share a fixed-size buffer. In this case, the produces shouldn't be able to add
data to a full buffer, and the consumers shouldn't pull data from an empty buffer.
Solution: The options for the producer are to sleep or discard data from the full buffer, with the consumer notifying the
producer when they've pulled data. For the consumer, they should sleep and be notified by the producer when the buffer isn't
empty.
Readers-Writers Problem
Problem: Multiple readers can access shared data simultaneously without issue, but only one writer can access shared data at
a time.
Solution: Readers preference where writers have to wait until no readers are accessing data before a writer can. Writers
preference where writer can still do what they need to, but there may still be someone reading the data.
Dining Philosophers Problem
Problem: Multiple processes (philosphers) share limited resources (chopsticks) they need to perform a task (eat noodles)
Solution: Manage the allocation of limited resources in a deadlock-free and starvation free way, letting "philosphers" eat if
they have access to both "chopsticks"
Sleeping Barber Problem
Problem: Barber is sleeping when there are no customers and has to be woken up by a customer when they arrive, but the
customers have to wait if there are seats open or leave if there are none.
Solution: Coordinated access so there is only one customer in the chair at a time and the barber is always working on a single
customer in the chair