ch5 Process Synchronisation
Motivation:
1.Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes.
2.Suppose that we want to provide a solution to the consumer-producer problem that fills all buffer slots.
A Race Condition:
We need to enclose these operations in a critical section which will guarantee that only one processes can access these variables at any one time: mutual exclusion
Semaphore Implementation with almost no Busy Waiting:
Each entry in a waiting queue has two data item:
1.int count
2.pointer to next entry in the queue
Two operations:
–block: place the process invoking the operation on the appropriate waiting queue.
–wakeup: remove one of processes in the waiting queue and place in the ready queue
PV操作:
Deadlock:
two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes
Starvation:
indefinite blocking.A process may never be removed from the semaphore queue in which it is suspended.
Preemptive Priority Scheduling algorithm