Multi-threading: concurrent threads share an address space
Multi-programming: concurrent processes execute on a uniprocessor
Multi-processing: concurrent processes on a multiprocessor
Distributed processing: concurrent processes executing on multiple nodes connected by a network
Concurrent processes (threads) need special support:
Communication among processes
Allocation of processor time
Sharing of resources
Synchronization of multiple processes
In a multiprogramming environment, processes executing concurrently are either competing for the CPU and other global resources, or cooperating with each other for sharing some resources
An OS deals with competing processes by carefully allocating resources and properly isolating processes from each other. For cooperating processes, on the other hand, the OS provides mechanisms to share some resources in certain ways as well as allowing processes to properly interact with each other
Cooperation is either by implicit sharing or by explicit communication
Processes: competing Processes that do not exchange information cannot affect the execution of each other, but they can compete for devices and other resources. Such processes do not intend to work together, and so are unaware of one another
Properties: Deterministic, Reproducible,Can stop and restart without ``side'' effects, Can proceed at arbitrary rate
Processes: cooperating Processes that are aware of each other, and directly (by exchanging messages) or indirectly (by sharing a common object) work together, may affect the execution of each other
Properties: Share (or exchange) something: a common object (or a message), Non-deterministic (a problem!), May be irreproducible (a problem!), Subject to race conditions (a problem!)
Threads of a process usually do not compete, but cooperate
Why cooperation? We allow processes to cooperate with each other, because we want to:
share some resources.
do things faster
Read next block while processing current one.
Divide jobs into smaller pieces and execute them concurrently.