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
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
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
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