Fork used to create new process which is called child process. Child process runs concurrently with its Parent process. After a new child process created, both processes will execute the next instruction following the fork() system call. A child process use same pc(program counter), same CPU registers, same open files which use in parent process.
Below is Example:
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main() {
// make two process which run same
// program after this instruction
fork();
printf("Hello world!\n");
return 0;
}
Output :
Hello world!
Hello world!
Please see below link for more :
No comments:
Post a Comment