4.3 Operations on Processes
The processes in the system can execute concurrently, and they must be
created and deleted dynamically. Thus, the operating system must provide a
mechanism (or facility) for process creation and termination.
4.3.1 Process Creation
A process may create several new processes, via a create-process system
call, during the course of execution. The creating process is called a parent
process, whereas the new processes are called the children of that process. Each
of these new processes may in turn create other processes.
In general, a process will need certain resources (such as CPU time, memory, files,
I/O devices) to accomplish its task. When a process creates a subprocess, that
subprocess may be able to obtain its resources directly from the operating system,
or it may be constrained to a subset of the resources of the parent process. The
parent may have to partition its resources among its children, or it may be able to
share some resources (such as memory or files) among several of its children.
Restricting a child process to a subset of the parent's resources prevents any
process from overloading the system by creating too many subprocesses.
When a process is created it obtains, in addition to the various physical and logical
resources, initialization data (or input) that may be passed along from the parent
process to the child process. For example, consider a process whose function is to
display the status of a file, say F1, on the screen of a terminal.
When it is created, it will get, as an input from its parent process, the name of the
file F1, and it will execute using that datum to obtain the desired information.
Operating system Dr. Shroouq J.
2
It may also get the name of the output device. Some operating systems pass
resources to child processes. On such a system, the new process may get two open
files, F1 and the terminal device, and may just need to transfer the datum between
the two.
When a process creates a new process, two possibilities exist in terms of execution:
1. The parent continues to execute concurrently with its children.
2. The parent waits until some or all of its children have terminated.
4.3.2 Process Termination
A process terminates when it finishes executing its final statement and asks the
operating system to delete it by using the exit system call. At that point, the
process may return data (output) to its parent process (via the wait system call).
All the resources of the process-including physical and virtual memory, open files,
and I/O buffers-are deallocated by the operating system.
Termination occurs under additional circumstances. A process can cause the
termination of another process via an appropriate system call (for example, abort).
Usually, only the parent of the process that is to be terminated can invoke such a
system call. Otherwise, users could arbitrarily kill each other's jobs. A parent
therefore needs to know the identities of its children. Thus, when one process
creates a new process, the identity of the newly created process is passed to the
parent. A parent may terminate the execution of one of its children for a variety of
reasons, such as these:
The child has exceeded its usage of some of the resources that it has been
allocated. This requires the parent to have a mechanism to inspect the state of its
children.