- More than one computation being carried out at the same time.
- Coordination among the concurrent computations - none is trivial
concurrency (although providing trivial concurrency is non-trivial).
- Process - the computation.
- Execution threads - the action.
- Shared resources - inter-computation; intra-computation; explicitly
shared resources.
- Real vs virtual concurrency - don't exploit concurrency features;
stick to the standards.
- Relations among computations - execution relations; sharing relations.
- Context switching - overhead particularly.
- Networking is a naturally concurrent environment - lots of hosts
attached.
- Client concurrency is effortless; server concurrency is not.
- Concurrency is supported by the operating system.
- Routines to manage computation state.
- Processes without threads.
- Routines to manage threads (intra-thread management).
- Routines to synchronize threads (inter-thread management).
- Generic management functions.
- Allocation and deallocation.
- Establishing relations among components.
- Controlling component properties.
- A Unix process combines computation state and a single thread.
- Process management.
-
fork() creates an (almost) exact copy of the calling process.
-
exec(p) replaces the calling process with program p.
-
exit() terminates the calling process.
- Inter-process synchronization.
- Parents and children can inherit semaphores.
-
signal() sends software interrupts to other processes.
- Synchronization outside the ancestor-descendent relation is possible
but not easy.
Posix threads are designed to run within Unix processes.
- Computation state management is inherited from Unix.
- Thread management.
-
pthread_create(f) executes f() in a new thread.
-
pthread_exit(), pthread_cancel(t).
-
- Synchronization.
-
pthread_mutex(), pthread_lock(m), pthread_unlock(m).
-
pthread_cond(), pthread_signal(c), pthread_wait(c, m).
-
pthread_join(t) blocks until thread t exits.
-
exec() and friends
- Gut and replace the calling computation - run a new computation
- The friends differ in the arguments passed and how they're passed
- A successful call doesn't return.
- Java is object-oriented, and so is concurrency management.
- Computation state is based on the Runnable class.
- Thread computations implement the
void run() method.
- Threads are based on the Thread class.
- Specialized threads can extend the Thread class.
- Synchronization is based on mutex locks and condition variables.
- One lock and condition variable is available in every class instance,
independent of concurrency.
-
synchronize blocks automatically manage the mutex.
-
signal() and wait() manipulate the condition variable.
- Most io operations are blocking - cuts down on concurrency.
- Asynchronous io operations - polling operations.
- Thread safe io operations.
- Multiplexing operations - virtual concurrency.
This page last modified on 20 February 2004.