Concurrent Processes Flashcards
(8 cards)
What are concurrent processes ?
Processes that can share physical or logical recourses.
What are the problems with concurrent processes ?
Race conditions: Two processes accessing/ modifying shared data simulatneously causes inconsistent or lost results.
Critical Region: Section of code where shared recources are accessed (only one process should execute this at time).
What is required to help prevent issues ?
Mutual exclusion (mutex).
What is the main Software-Based Mutex ?
Peterson’s Algorithm -
Uses flags and a turn a variable to ensure only one processes enters its critical region at a time,
Prevents race conditions but leads to busy waiting.
What is the main Hardware-Based Mutex ?
Test-and-set Instruction -
Performs test and assignement atomically (no intervention),
Solves the race condtition but still causes CPU time wastage due to busy waiting.
What is a Semaphore ?
A protected integer variable used to control access,
Binary semaphore (0 or 1)
Counting semaphore (> 0)
What are the two atomic operations of semaphores ?
wait() - decrements the semaphore; blocks if <= 0,
signal() - increments and potentially unblocks a waiting process.
How do we handle multiple producers and consumers ?
Scaling the semaphore logic to allow the multiple producers and consumers to access the buffer concurrently.