Shared-Variable Programming: Processes and Synchronization
- Sequential programs use shared variables for global
data structures, but they can be written without them.
- However, concurrent programs absolutely depend on
the use of shared components, because the only way
processes can work together is to communicate:
- and the only way to communicate is that one process writes
into something that the other process reads
- that something can be a shared
variable (in shared-variable programming) or it can be a
shared communication channel (in distributed programming)
- Mutual exclusion
occurs whenever two processes need to take turns accessing shared objects
(e.g., a shared client account record in database), condition
synchronization occurs whenever one process
needs to wait for another (e.g., a server waiting for a client)
- Shared-variable programs are most commonly
executed on shared-memory machines, because every variable can be accessed
directly by every processor, however they can be used on distributed-memory
machines too (as a distributed shared memory)