Operations on Process in OS - Process management System Calls

<<Previous

Next >>




In this page, we will learn about the several operations possible on a process using system calls - fork(), exec(), wait(), and exit(). These system calls are used in the operations like Process Creation, Process Execution, Process Blocking and Process Termination.

Process Cycle using System Calls

  • A parent process creates a sub process by making a fork() system call.
  • After the fork(), exec() system call is used to load the binary file of child process into memory and start its execution.
  • While the child process is executed, the parent process can create more children. If parent process has nothing to do, it just issues the wait() system call and waits until the child processes exit.
  • exit() system call terminates the process. When it is used on the child process, it exists and parent is notified to resume
Fig 2.Creation of Process
Fig 2.Creation of Process

Operation - Process Creation - fork() System Call

The process can create the new process by using the fork() system call. The creating process is known as parent process whereas the newly created process is known as child process.

Process ID

In general, each process has a unique process identification number called process id(i.e pid). Most of the operating system use this pid to identify the process.

Required Resources

Usually the process requires some resources (CPU time, file, memory, I/O device) to complete its task. When a process creates several new processes, that child processes may able to get its resources from operating system. That means, the parent process may assign some resources to its children or it may have to share some resources with its children.

Process Address Space

In terms of address space, There are also two possibilities:

  1. The child process is a duplicate of the parent process that means, the child has the same program and data as the parent.
  2. The child process has a new program loaded into it.

Operation - Process Execution - exec() System Call

When a process creates a new process, then there are two possibilities in terms of execution:

  1. The parent process continues to execute concurrently with its children.
  2. The parent process waits until some or all of its children have terminated.

exec() system call is used to load the binary file of child process into memory and start its execution.


Operation - Process Blocking - wait() System Call

wait() system call is called to make a process wait until something else happens.


Operation - Process Termination - exit() System call

The exit() system call is used to terminate the process. Once the process completes its execution of final statement, it asks the operating system to delete the process from memory and deallocates its all resources. After the termination, the child may return their status code to its parent.

Parent may terminate their children due to the following reasons:

  • The child has exceeded its usage of some of the resources that it has been allocated.
  • The work assigned to the child is no longer required
  • If the parent terminates, the operating system may not allow a child to continue its execution.

<<Previous

Next >>









Operations on Process in OS - Process management System Calls

<<Previous

Next >>




In this page, we will learn about the several operations possible on a process using system calls - fork(), exec(), wait(), and exit(). These system calls are used in the operations like Process Creation, Process Execution, Process Blocking and Process Termination.

Process Cycle using System Calls

  • A parent process creates a sub process by making a fork() system call.
  • After the fork(), exec() system call is used to load the binary file of child process into memory and start its execution.
  • While the child process is executed, the parent process can create more children. If parent process has nothing to do, it just issues the wait() system call and waits until the child processes exit.
  • exit() system call terminates the process. When it is used on the child process, it exists and parent is notified to resume
Fig 2.Creation of Process
Fig 2.Creation of Process

Operation - Process Creation - fork() System Call

The process can create the new process by using the fork() system call. The creating process is known as parent process whereas the newly created process is known as child process.

Process ID

In general, each process has a unique process identification number called process id(i.e pid). Most of the operating system use this pid to identify the process.

Required Resources

Usually the process requires some resources (CPU time, file, memory, I/O device) to complete its task. When a process creates several new processes, that child processes may able to get its resources from operating system. That means, the parent process may assign some resources to its children or it may have to share some resources with its children.

Process Address Space

In terms of address space, There are also two possibilities:

  1. The child process is a duplicate of the parent process that means, the child has the same program and data as the parent.
  2. The child process has a new program loaded into it.

Operation - Process Execution - exec() System Call

When a process creates a new process, then there are two possibilities in terms of execution:

  1. The parent process continues to execute concurrently with its children.
  2. The parent process waits until some or all of its children have terminated.

exec() system call is used to load the binary file of child process into memory and start its execution.


Operation - Process Blocking - wait() System Call

wait() system call is called to make a process wait until something else happens.


Operation - Process Termination - exit() System call

The exit() system call is used to terminate the process. Once the process completes its execution of final statement, it asks the operating system to delete the process from memory and deallocates its all resources. After the termination, the child may return their status code to its parent.

Parent may terminate their children due to the following reasons:

  • The child has exceeded its usage of some of the resources that it has been allocated.
  • The work assigned to the child is no longer required
  • If the parent terminates, the operating system may not allow a child to continue its execution.

<<Previous

Next >>















Learn about Stack Data Structure

Learn about Heap Data Structure

Learn about Operating System

Learn AVL Tree

Learn Djikstra's Algorithm