Shared-Variable Programming: Implementations
- At a minimum, modern multiprocessors (i.e., concurrent architectures with a shared memory) provide machine instructions
that the systems programmer can use to implement locks and barriers (e.g., test and set, fetch and add).
- Some multiprocessors provide hardware support for processes, context switching, locks, and the spinning aspect of semaphores.
- However, in general concurrent programming mechanisms are implemented in software
as a part of the OS and/or concurrent programing environment (e.g., Pthreads library, Java JVM, OS kernel of Unix, Windows NT)
- The basis for the implementation is software kernel(or nucleus)
of OS, shared by all processes. Such a kernel is a small set of data structures and subroutines that provide a virtual processor to each
process so that the process has the illusion that it is executing on its own processor, where:
- The data structures represent the states of processes, semaphores, and condition variables.
- The subroutines implement primitive (i.e., executed atomically) operations on the data structures.
- OS kernel can support processes on a single processor or on multiprocessors, starting and killing processes,
providing priority scheduling, dynamic memory and processor allocation, implementing semaphores and monitors.