Wednesday, April 11, 2012

Process Synchronization

Process Synchronization

Cooperating processes can

either directly share a logical address space (that is, both code and data)

or be allowed to share data only through files or messages.

Concurrent access to shared data may result in data inconsistency.




Race Condition
A potential problem; the order of instructions of cooperating processes



The Critical-Section Problem
How do we avoid race conditions? What we need is mutual exclusion

Various proposals for achieving mutual exclusion, so that while one process is busy updating shared memory in its CS, no other process will enter its CS and cause trouble.

Disabling Interrupts
Lock Variables
Strict Alternation
Peterson's Solution
The TSL instructions (Hardware approach)

Semaphores
A synchronization tool called semaphore.
Semaphores are variables that are used to signal the status of shared resources to processes.




Classic Problems of Synchronization
a number of synchronization problems as examples of a large class of concurrency-control problems.
The Bounded-Buffer Problem
The Readers-Writers Problem
The Dining-Philosophers Problem


6.7 Monitors
Semaphores can be very useful for solving concurrency problems, but only if programmers use them properly. If even one process fails to abide by the proper use of semaphores, either accidentally or deliberately, then the whole system breaks down. ( And since concurrency problems are by definition rare events, the problem code may easily go unnoticed and/or be heinous to debug. )


A monitor is essentially a class, in which all data is private, and with the special restriction that only one method within any given monitor object may be active at the same time. An additional restriction is that monitor methods may only access the shared data within the monitor and any data passed to them as parameters. I.e. they cannot access any data external to the monitor.


http://siber.cankaya.edu.tr/ozdogan/OperatingSystems/ceng328/node150.html

No comments:

Post a Comment