Process Synchronization Flashcards
Race Condition
Situation where several processes or threads manipulate shared data, and the outcome depends on the execution order
To prevent race conditions, concurrent processes must be
synchronized
Synchronized
Ensures that only one process at a time is manipulating the shared variable, operations must be performed atomically
Atomic Operation
An operation without interruption
Where are there significant race conditions?
I/O
Variable sharing
Critical Section
Segment of code in which the process may be changing shared data
Solution to critical section problem must satisfy 3 requirements
Mutual Exclusion
Progress
Bounded Waiting
Mutual Exclusion
If a process is in its critical section then no other processes can be executing in their critical sections
Progress
The decision of which process enters the critical section cannot be postponed indefinitely
Bounded Waiting
There must be a limit on how many times other processes can enter their critical section after a process requests access
We need _ from critical sections
Mutual Exclusion
Disabling hardware interrupts CS problem
Works but not reasonable, not feasible due to the risk of indefinitely blocking other processes
Simple lock variable CS problem
Suffers from race condition of setting the lock
Indivisible lock variable CS problem
Works, uses Test and Set Lock (TSL) instruction to prevent race condition. Finds lock at 0 and sets it in one shot
no-TSL toggle for two thread CS problem
Doesnt have progress, if B is faster than A, will lock itself out of CS. Tries to take turns but doesnt work if one process should enter multiple times before other