## Creation of New Processes

The sequence of operations required to create a new process and initially allocate its resources (especially memory) are automatically performed by OS-9's “fork” function. If for any reason any part of the sequence cannot be performed the fork is aborted and the prospective parent is passed an appropriate error code. The most frequent reason for failure is unavailablity of required resources (especially memory) or when the program specified to be run cannot be found. A process can create many new processes, subject only to the limitation of the amount of unassigned memory available.

When a process creates a new process, the creator is called the “parent process”, and the newly created process is called the “child process”. The new child can itself become a parent by creating yet another process. If a parent process creates more than one child process, the children are called “siblings” with respect to each other. If the parent/child relationship of all processes in the system is examined, a hierarchical lineage becomes evident. In fact, this hierarchy is a tree structure that resembles a family tree. The “family” concept makes it easy to describe relationships between processes, and so it is used extensively in descriptions of OS-9's multiprogramming operations.

When the parent issues a fork request to OS-9, it must specify the following required information:

- A PRIMARY MODULE, which is the name of the program to be executed by the new process. The program can already be present in memory, or OS-9 may load it from a mass storage file having the same name.

- PARAMETERS, which is data specified by the parent to be passed to and used by the new process. This data is copied to part of the child process' memory area. Parameters are frequently used to pass file names, initialization values, etc. The shell, passes command line parameters this way.

The new process also “inherits” copies of certain of its parent's properties. These are:

- A USER NUMBER which is used by the file security system and is used to identify all processes belonging to a specific user (this is not the same as the “process ID”, which identifies a specific process) . This number is usually obtained from the system password file when a user logs on. The system manager always is user number zero.

- STANDARD INPUT AND OUTPUT PATHS: the three paths (input, output, and error/status) used for routine input and output. Note that most paths (files) may be shared simultaneously by two or more processes. The two current working directories are also inherited.

- PROCESS PRIORITY which determines what proportion of CPU time the process receives with respect to others.

As part of the fork operation, OS-9 automatically assigns:

- A PROCESS ID: a number from 1 to 255, which is used to identify specific processes. Each process has a unique process ID number.

- MEMORY: enough memory required for the new process to run. Level Two systems give each process a unique “address space”. In Level One systems, all processes share the single address space. A “data area”, used for the program's parameters, variables, and stack is allocated for the process' exclusive use. A second memory area may also be required to load the program (primary module) if it is not resident in memory.

To summarize, the following items are given to or associated with new processes:

- Primary Module (program module to be run)

- Parameter(s) passed from parent to child

- User Number

- Standard I/O paths and working directories

- Process Priority

- Process ID

- Memory