Operations on Process in OS

One can perform two operations on a process in OS:
1. Process creation
2. Process Termination

1. Process Creation

A process during its execution can create many new processes via system call(depending upon the OS). The creating process is called the parent while the created process is called the child. Each child process may in turn create new child process. Every process in the system is identified with a process identifier(PID) which is unique for each process.

1.1 Why to create a child process?

Watch the video to understand what is the need to create a child process?

1.2 How to create a process?

A process uses a System call to create a child process. The system call will differ from OS to OS. For Unix/Linux the system call is fork().

1.3 How the child process gets its resources?

There are two ways to allocate resources to a child process:

  1. The operating system allocates the resources to the child from the set of resources available in the system. But this can cause problems if a process creates to many child process.
  2. The child process gets the resources from the set of resources available with its parent.

1.4 Execution Possibilities for parent process

  1. The parent process Continues to execute concurrently with its children
  2. The parent process Waits until some or all the children terminate. This refers to situations where the parent needs some result or value from the child. For example, suppose the parent is to execute c=a+b; while the child has to execute a=e+f; Now, the parent can not proceed until the value of ‘a’ is calculated by the child.

1.5 Address Space of child process

  • Is a duplicate of the parent process – which means that the child process will also have the same code as the parent process. Thus, the code in the parent should clearly define the task for itself and the child process. (Refer the code below)
  • Has a new program loaded into it

2. Process Termination

There are two methods a process can terminate:

  1. Normal termination – A process finishes executing its final statement. All the resources allocated to it are freed by the operating system.
  2. Forced Termination – a parent process can terminate its child process by invoking the appropriate system call. The parent can terminate the child due to the following reasons:
    1. Child exceeds its usage of resources
    2. Task assigned to the child is no longer required
    3. Parent exits and OS does not allow child to run if parent terminates

The user can also forcefully terminate a process if it is not required anymore. For example, suppose you are listening to a song on a media player and suddenly you no more want to listen to the song and want to watch a movie on television. So you close the player thus forcibly killing the process before it could complete the song.

Certain operating systems do not allow a process to exist without its parent. Now, suppose a process terminates either normally or forcibly. Then all its child process will also be killed, which may in turn kill their child process. This is called cascading termination.

PPT on Operations on Process in OS

Note: Clicking on the “next” slide button will not display any animation. Hence, Click within the slide area for animations.

Previous                                     Next
Schedulers in OS                   CPU Scheduling

Leave a Reply

Your email address will not be published. Required fields are marked *