OPERATIONS ON PROCESSES

The Processes in the system can execute concurrently, and must be created and deleted dynamically. Thus, the operating system must provide a mechanism for process creation and termination.

Process Creation

Traditionally, only the operating system itself was permitted (and able) to create new processes. This view has changed in modern computer systems, which permits users to create their own subsystems consisting of many concurrent processes. Depending on the sophistication of the system, process creation may be done either statically or dynamically. In the first case, each process may contain the declaration of a fixed set of subprocesses, all of which will be activated when a process begins its execution. More flexibility is attained when processes may be spawned (and terminated) dynamically during execution.

In general, a process will need certain resources (CPU time, memory, files, I/O devices) to accomplish its task. When a process creates a subprocess, the 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 creates a new process, two possibilities exist in terms of execution:

� The parent continues to execute concurrently with its children.

� The parent waits until some or all of its children have terminated.

There are also two possibilities in terms of address space of the new process:

� The child process is a duplicate of the parent process.

� The child process has a program loaded into it.

As an illustration for implementation, let�s take UNIX operating system. In UNIX, each process is identified by its process identifier, which is a unique integer. A new procedure is created by the fork system call. The new procedure consist of a copy of the address space in memory of the original procedure. This mechanism allows the parent process to establish a smooth two way communication with its child procedure. Both parent and child procedure continue execution at the instruction after the fork with one difference: The return code for the fork is zero for the new (child) process, whereas the (nonzero) process identifier of the child is returned to the parent.

The parent also can create more children, or, if it has nothing else to do while the child runs, it can issue a wait system call to move itself off the ready queue until the termination of the child.

Process Termination

A process termination occurs when it finishes executing its last statement and asks the operating system to delete it by using the exit system call. Here is where the process may return data (output) to its parent process using the fork system call. All the resources of the process including virtual and physical, open files, and I/O buffers are deallocated by the operating system.

An additional way that a process can cause the termination of its process or another process is by the use of the system call abort, which can only be invoked by the parent of the process that needs to be terminated. This avoids that users could kill other�s jobs. But in order to avoid any confusion a parent must know its children identities very well. Thus when one process creates a new process, the identity of the newly created process is passed to the parent. Some of the reasons for which a parent may terminate the execution of one of its children may vary, a few are:

� The child has exceeded its usage of the resources that it has been allocated.

� The task assigned to the child is no longer required.

� The parent is exiting, and the operating system does not allow a child to continue if its parent terminates.

We can use UNIX system again to illustrate the process termination better. In UNIX a child process may be terminated by using the exit system call, and its parent process may wait for such event to occur by using the wait system call. Once the child has been terminated, the wait system call returns the process identifier of such terminated child, allowing the parent to know which of its many children has been terminated. In the case that the parent is terminated, all the children will also be terminated by the operating system, because without a parent UNIX will not be able to report the activities of a child.

LinkExchange
LinkExchange Member Free Home Pages at GeoCities

Hosted by www.Geocities.ws

1