Concurrency Control Flashcards
what is the bounded-buffer problem (producer-consumer)
a process produces data, another consumes it, and their rates may vary. they share a buffer. to solve this we synchronise when the buffer is empty or full
what is a race condition?
a situation in which two processes or threads are trying to acquire the same resource, and the order of access is relevant
what is a critical section?
a process is in a critical section when it is accessing shared data. we need to ensure that only one process can be executing in a critical section at a given time, to avoid race conditions. the entry and exit from the section must be atomic
what is a spin lock/busy wait?
a while loop that loops while the lock is on, and then breaks when the lock is unlocked
what are the semaphore operations?
wait
delays until the sem is > 0 then decrements it
and signal
increments the sem
what is a monitor?
a high level tool that provides syncronised operations
a process takes a monitor and then other processes cant run with that monitor
contains a queue of suspended processes
can contain condition variables that support variable-level exclusivity, x.wait() e.g.
what are the conditions for a deadlock?
- mutual exclusion (at least 1 resource is not shareable)
- hold and wait (process holds a resource and is waiting for another)
- no resource preemption
- circular wait (processes are waiting in a loop)
what are some deadlock strategies?
prevention - make sure they’re impossible. processes can declare their maximum needs and we can schedule accordingly.
recovery - detect it and correct it
ignore it - most common