Operations on Process in Process Scheduling:
The operating system is responsible for providing a mechanism to create and
destroy processes dynamically.
Process Creation:
Parent process creates children processes. The children processes can also
create other processes forming a tree of processes.
A process may create zero or more new child processes. Process creation may be
limited by the amount of resources that a parent process has. If a parent
process creates a child process, child process may create child processes of its
own, creating a tree of processes.
When a child process is created, it may be able to obtain resources directly
from the parent. It may only be able to obtain a subset of the parent's
resources or it must acquire its own resources. It is usually a good idea to
limit the resources of child process as a single user process could create
hundreds of child processes. Each might be able to acquire resources of their
own, leaving no resources for other processes and effectively giving control of
the machine to a single user process.
When a process creates a new process, the parent may continue to execute
concurrently with its children or it must wait until some or all its children
have terminated execution.
In terms of address space, the child may be an exact duplicate of the parent.
This would allow the child and parent to communicate very easily as they share
the same address space. It should be possible to load a new program into the
address space of the child (typically we want the child to do something
different to its parent).
It is also possible to create an entirely new process and place a new program
into it. This makes it more difficult for the child and parent to communicate
since they have nothing in common.
Process Termination:
A process normally terminates when it has finished executing its last statement.
It typically tells the operating system by issuing some form of the exit()
system call. At this point, if the process is a child it may output some data to
its parent. Eventually the process has all its resources removed from it and is
no longer part of the job pool.
A child process may be terminated by its parent using the abort () system call.
This may occur because the child has asked for too many resources, the child is
no longer wanted, or possibly if the parent is terminating. The operating system
may or may not allow a child process to continue executing after its parent
terminates.
In some instances it does not make sense for the child to keep going, especially
if its job was to compute something and to return a result. In other instance, a
child process may continue after the parent has finished e.g. a web browser may
allow you to download files in the background after the web browser has been
closed.
|