The fork() system call is defined as follows
When the fork system call is executed, a new procedure is created. The original process is called the parent process whereas the process is known as the child process. The new process comprises of a copy of the address space of their parent. This mechanism permits the parent process to communicate easily with their child process. On success, both processes carry on execution at the instruction after the fork call, with one difference, the return the code for the fork system call is zero for child process, while the process identifier of the child is returned back to the parent process. On failure, a -1 will be returned back in the parent's context, no child process will be produced, and an error number will be set appropriately.
The synopsis of the fork system call is given below:
#include <sys/types.h>
#include <unistd.h>
pid_t fork(void);
Figure of the Sample code showing use of the fork() system call
Figure drawn above shows sample code, showing the use of the fork() system call and Figure drawn below shows the semantics of the fork system call. As shown in Figure, fork() creates the exact memory image of the parent process and returns 0 to child process and the process ID of the child process to the parent process.
Figure Semantics of fork system call
After the fork() system call the parent and the child share as follows:
1) Environment
2) Open file descriptor table
3) Signal handling settings
4) Nice value
5) Current working directory
6) Root directory
7) File mode creation mask (umask)
The following things are different in the parent and the child:
8) Different process ID (PID)
9) Different parent process ID (PPID)
10) Child has its own copy of parent's file descriptors
The fork() system may fail due to the number of reasons. One reason can be that the maximum number of processes permitted to execute under one user has exceeded, another could be that the maximum number of the processes permitted on the system has exceeded. Yet another reason could be that there is not sufficient swap space.
Email based Operating System assignment help - homework help at Expertsmind
Are you searching Operating System expert for help with Fork System Call questions? Fork System Call topic is not easier to learn without external help? We at www.expertsmind.com offer finest service of operating system assignment help and operating system homework help. Live experts are available for 24x7 hours helping students in their Fork System Call related problems. We provide step by step Fork System Call question's answers with 100% plagiarism free content. We prepare quality content and notes for Fork System Call topic under operating system theory and study material. These are avail for subscribed users and they can get advantages anytime.
Why Expertsmind for assignment help
- Higher degree holder and experienced tutors network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving operating system questions in excels and word format.
- Best tutoring assistance 24x7 hours