Open In App

Difference between fork() and vfork()

Last Updated : 18 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

1. fork() :
Fork() is system call which is used to create new process. New process created by fork() system call is called child process and process that invoked fork() system call is called parent process. Code of child process is same as code of its parent process. Once child process is created, both parent and child processes start their execution from next statement after fork() and both processes get executed simultaneously.

2. vfork() :
Vfork() is also system call which is used to create new process. New process created by vfork() system call is called child process and process that invoked vfork() system call is called parent process. Code of child process is same as code of its parent process. Child process suspends execution of parent process until child process completes its execution as both processes share the same address space.



Difference between fork() and vfork() :

S.No. FORK() VFORK()
1. In fork() system call, child and parent process have separate memory space. While in vfork() system call, child and parent process share same address space.
2. The child process and parent process gets executed simultaneously. Once child process is executed then parent process starts its execution.
3. The fork() system call uses copy-on-write as an alternative. While vfork() system call does not use copy-on-write.
4. Child process does not suspend parent process execution in fork() system call. Child process suspends parent process execution in vfork() system call.
5. Page of one process is not affected by page of other process. Page of one process is affected by page of other process.
6. fork() system call is more used. vfork() system call is less used.
7. There is wastage of address space. There is no wastage of address space.
8. If child process alters page in address space, it is invisible to parent process. If child process alters page in address space, it is visible to parent process.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads