In POSIX, the program executes in a process, the counterpart of the BS2000 task. POSIX processes are mapped to BS2000 tasks.
In POSIX, all processes are structured hierarchically. The process hierarchy results from an initiating process (init) and further processes which are subordinate to this initiating process. This is commonly known as a parent-child relationship. The initiating process is the parent of all the processes. Processes directly subordinate to it are the child processes, who in turn can also have child processes. This order of priority can be continued up to a configurable maximum number of processes (NPROC control parameter in the POSIX information file).
The individual POSIX mechanisms and processes are described in more detail below.
fork
A new child process is created by calling the fork function of a parent process. The fork function creates a new process environment and copies selected information of the parent process for the child process. A separate address space, isolated from the parent process, is available to the child process. The child process can access all POSIX resources opened by the parent process.
The two process work independently of each other immediately after the function call. They can be differentiated by their respective return codes: the child process receives the
value 0, and the parent process receives the process identification (PID) of the child process.
DMS files and other BS2000 resources are not inherited when the fork function is called.
exec
If the exec function is invoked in a program, the current process environment is overlapped completely by a new one. As a result, another program can run in a child process than that running in the parent process, for example. The processes remain linked, however, by the parent-child relationship.
Combining fork and exec
The fork and exec functions can also be combined. The advantage of such a combination lies in the fact that partial tasks can be exported to another process. Once all partial tasks are exited, the process can be exited.
An example is the POSIX shell. For some commands, the POSIX shell starts a new process which overlays itself and starts the command execution program. The process is terminated and the POSIX shell continues when this program is exited.
pipe
The pipe function is available with POSIX for interprocess communication (application programming). This function creates a pipe function, i.e. a data repository of the type “first in - first out”. A process can use a pipe in order to transmit information to another process.
“copy-on-write” mechanism
When the fork function is called, the complete process environment of the parent is inherited by the child. This means that copying the complete address space can take a relatively long time. The POSIX-specific copy-on-write mechanism considerably improves performance. For one fork call, the address space is not copied, but merely marked. Consequently, the memory space is available to both the parent and child processes together. If either process accesses a page for the first time, the flag establishes that an action is to be performed. In this case, the appropriate memory page is copied for the child process so that both processes have their own version. In this way, only the memory pages which are actually required are copied. The fork call can thus essentially operate more effectively.
A further advantage of the copy-on-write mechanism is that a fork call is often followed by an exec call. In this case, there would be no point in copying the storage area, since it is overlapped by the exec call. Without copy-on-write, the entire storage area would have been copied and immediately overwritten again.
Holder task
POSIX uses a holder task. Initialization and termination operate under the control of this holder task. The holder task is not available to the POSIX subsystem during the subsystem session, i.e. between initialization and closure.
Caller task
The caller task is linked to the POSIX subsystem during the first SVC call, and is separated from it when the program is terminated. The calling task receives a POSIX process environment during the first POSIX system call.
Subsystem-private servers
There are two types of subsystem-private servers in the POSIX subsystem: system processes and daemons. System processes are implemented as BS2000 system tasks, daemons as nonprivileged BS2000 tasks.
While the command /START-SUBSYSTEM SUBSYSTEM-NAME=POSIX is being processed, only system processes are initialized as servers. Only once this has been done are daemons created.