Elementary Operating System Call - Fork()

What is system call ?

Karnel is the heart of Computer System. In computer system, a request has to be made by operating system to the Karnel in order to get the service, and it is only done in programmatic way, which is known as system call.

Program is a collection of instructions that is made to complete a particular task. And a process is a particular program which is currently in running status.

Thread includes in process i.e process has some properties of thread - a single sequence stream within process is called thread.


Fork() 



  • In UNIX system, we use Fork() to create duplicate of a process by creating address space for duplicate one.
  • The process from which fork method is called, known as parent process. And child process is the new created process. Child and Parent, both processes return from the system call and execute the next instruction. 
  • Child process has all the features and ability of parent process i.e all memory segments of parent process are consumed by child process also. Parent and Child both processes execute independently whereas there is same code for both processes.
  • Parent and Child both process have different process IDs. They are executed at different memory address. 
  • As fork method executes, it returns twice - 0 and process ID to parent process if fork is successfully executed and it returns -1 if it is failed.
Synopsis
#include<unistd.h>
pid_t fork(void);

Post a Comment

0 Comments