Classical synchronization problems Flashcards
Producer threads
create items of some kind and add them to DS
consumer threads
remove and process items
Example of producer consumer relationships
event driven programs
- when event occurs, the prod thread creates an event object and adds it to the event buffer
- consumer threads take events out of buffer and process them - concurrently
What is the producer consumer problem?
while being added or removed the buffer is in an inconsistent state. threads therefore need to have exclusive access to buffer
- consumer arrives while buffer is empty, it needs to block until a producer adds a new item
- bounded buffer variant, producer cannot produce if buffer is full
Synchronization constraints for readers-writers problem
any number of readers can be in the critical section simultaneously
writers need exclusive access to their critical section
Two types (variations) of how readers and writers are considered
- no reader is kept waiting unless writer has permission to use shared object - prioritizes readers
- once reader is ready it performs the write ASAP
Liveness
processes must make progress and not wait indefinitely
Starvation
indefinite blocking e.g. process never removed from semaphore queue
Deadlock
two or more processes are waiting infinitely long for an event that can never occur