Saturday, July 4, 2020

System Calls in Linux : fork() and exec()

Hi,

In this post I am going to discuss about the system call that the process makes to the Kernel.

There are two system calls available in Linux namely...

1. fork()
2. exec()

System Call fork()
When ever the user wants to execute a program, the kernel of Linux does the operation in the following way...

Consider a user wants to list the contents of a directory, normally 'ls' is the program which lists the contents of the directory but the process that does execute the process 'ls' is shell, which can be either a simple sh 'sh' or bourne again shell 'bash'... here the shell is forked first and then the process 'ls' is given to the shell process.

Normally, in Linux when ever a child process is executed by the parent process, the parent process should be forked first and the child process would be supplied to it.

Forking is a process to make a exact copy of a process

System Call exec()
When the exec() system call is made, the kernel would just execute the program, normally the syntax of this system call would be exec() or exec(<program in action>)

The below diagram would help you to understand the system call discussed in a simplified way...


Well that is it, hope you had good time.

Thanks.



No comments:

Post a Comment

Addressing Modes of 8080 / 8085 MicroProcessor

Hi,   In this post I am going to talk about different addressing modes of 8080/8085...without much talking let us get into the topic.   Ther...