Units 3 & 4 Flashcards
Shared resources
processes that are working together often need to access the same data or hardware resource
Producer-consumer model
2 or more processes working with a shared resource
producer - writes data to the shared resource
consumer - reads data from the shared resource
Condition synchronisation
mechanism to ensure that a process is blocked if some condition is not met
Mutual exclusion
control access to shared data
only one process at a time had exclusive access to a shared resource
What are race conditions?
when the final outcome of a process is dependent on the timing or sequence of other processes
Atomic action
either happens completely or it does not happen at all
fine-grained or course-grained
Critical region
a section of code in which a shared resource is being accessed
must be executed under mutual exclusion
Entry protocol
code that must be executed before entering a critical region
prevents a process entering the critical region if another process is already in a critical region that accesses the same data resource
Exit protocol
code that a process must execute immediately on completion of its critical region
signals the resource is now available to other processes
Semaphore
data structure for solving synchronisation problems
like a permit - only one process at a time can hold the permit + a process must get hold of the permit before it can enter the critical region
Binary semaphore
for mutual exclusive access to a single shared resource
several processes sharing a resource will share one semaphore
initial value of 1
Counting semaphore
to protect access to multiple instances of shared data
initial value set to the number of resource instances available
Blocking semaphore
to synchronise two processes
initialised to 0
Monitors
data structures to encapsulate the shared data
shared data is accessible only through special monitor operations which are atomic
facilitate mutual exclusion
support condition synchronisation
Monitor construct
well-defined interface
only operations defined in the interface can be used to access the monitor’s data
a monitor operation is equivalent to a critical region with entry + exit protocols
In what ways can semaphores be used?
ensuring mutual exclusion from critical code
controlling access to shared resources
synchronising cooperating processes