Ch 5 p 227 Flashcards
critical section problem
MUST ALLOW EXCLUSIVE ACCESS TO ONE PROCESS
when processes share a lot of variables it serialized the code.
Peterson’s solution
int turn; // ready condition
boolean flag[2]; // if process is ready to enter critical seciotn
problem with this solution is that you can only use 1 type of thread
use of locks (low level solution)
solution to peterson’s problem
test_and_set // one lock for implementaion
initialize lock to false
if true, set lock to true
if false, set to true (locks processes out)
compare_and_swap // each process has its own lock (new bool value) plus a shared lock (expected)
initialize lock to false
swap if new and expected bool value equal
problem with locks is busy waiting.
solution is sleepy threads ( wait( ) )
Mutex locks (high level solution) (spinlock)
acquire() and release() must be atomic
Deadlock
when two or more processes are waiting indefinitely for an event that can be cause only by one of the waiting processes
race condition
situation where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place.
priority inverison
inverting priority when starvation, or indefinite deadlocks, occur
binary semaphore is basically a mutex lock
binary semaphore is basically a mutex lock
critical-section solution requirements
mutual exclusion - only one process can execute its critical section progress - selection can't be postponed indefinitely – no deadlock bounded waiting (fairness) - a process requesting to enter its critical section only waits certain time