6.2 Multiprocessing Mechanisms

I l @ ve RuBoard

All modern, general-purpose operating systems provide mechanisms to create and manage the execution of multiple processes. A process is a unit of resource management and protection. Some embedded operating systems, such as many versions of VxWorks and pSoS, support only a single address space, which is akin to a single process. This limitation is often reasonable; for example, your cell phone's computer may not need to run multiple processes. Most of these embedded-type systems do facilitate multithreading, however, which we'll examine in Section 6.3.

The process control functionality offered by different operating systems varies greatly. On multiprocessing operating systems, however, the following areas of capability are common:

Process lifetime operations. Processes come into existence when either the OS or application programs call process creation and execution functions, such as fork() and the exec *() family of functions (POSIX) or CreateProcess() (Win32). These functions create a new address space to run a particular program. The initiating process can also set the new program's command-line arguments and environment variables to pass information, such as commands, parameters, and file or directory locations, to a new process. A process runs until it terminates either

  • Voluntarily, for example, by reaching the end of its main() function or by calling a process exit API, such as ExitProcess() (Win32) or exit() (POSIX), which allows a process to set its exit status to a specified value, or

  • Involuntarily, for example, by being killed via a signal (POSIX) or by an external cancelation operation, such as TerminateProcess() (Win32).

Process synchronization operations. Most operating systems retain the identity and exit status of a process when it exits, which allows its parent process to synchronize with it and obtain its exit status. Common examples of process synchronization functions include:

  • The POSIX wait() and waitpid() functions and

  • The Win32 functions WaitForSingleObject() and WaitForMultipleObjects()

Many operating systems also maintain the inherent parent/child relationship between creator and created processes. This relationship is used by some operating systems to help notify a possibly-interested parent process that one of its child processes has exited. On POSIX systems, for instance, the OS sends a SIGCHLD signal to a parent process when one of its child processes exits.

Process property operations. Most operating systems provide functions to get and set various process properties. Properties that can be set at the process level include default file access permissions, user identification, resource limits, scheduling priority, and the current working directory. Some operating systems also allow a process to lock down regions of its virtual memory to avoid page faulting or to enable memory-based exchanges with I/O devices.

I l @ ve RuBoard


C++ Network Programming
C++ Network Programming, Volume I: Mastering Complexity with ACE and Patterns
ISBN: 0201604647
EAN: 2147483647
Year: 2001
Pages: 101

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net