• Networking
  • Programming
  • DBMS
  • Operating System
  • Internet
  • Hardware
  • Software

Tech Differences

Know the Technical Differences

Difference Between fork() and vfork()

fork_vs_vforkBoth fork() and vfork() are the system calls that creates a new process that is identical to the process that invoked fork() or vfork(). Using fork() allows the execution of parent and child process simultaneously. The other way, vfork() suspends the execution of parent process until child process completes its execution.

The primary difference between the fork() and vfork() system call is that the child process created using fork has separate address space as that of the parent process. On the other hand, child process created using vfork has to share the address space of its parent process.

Let us find some differences between fork() and vfork() with the help of comparison chart shown below.

Content: fork() Vs vfrok()

  1. Comparison Chart
  2. Definition
  3. Key Differences
  4. Conclusion

Comparison Chart

Basis for Comparisonfork()vfork()
BasicChild process and parent process has separate address spaces.Child process and parent process shares the same address space.
ExecutionParent and child process execute simultaneously.Parent process remains suspended till child process completes its execution.
ModificationIf the child process alters any page in the address space, it is invisible to the parent process as the address space are separate.If child process alters any page in the address space, it is visible to the parent process as they share the same address space.
Copy-on-writefork() uses copy-on-write as an alternative where the parent and child shares same pages until any one of them modifies the shared page.vfork() does not use copy-on-write.

Definition of fork()

The fork() is a system call use to create a new process. The new process created by the fork() call is the child process, of the process that invoked the fork() system call. The code of child process is identical to the code of its parent process. After the creation of child process, both process i.e. parent and child process start their execution from the next statement after fork() and both the processes get executed simultaneously.

The parent process and child process do have separate address space. Hence, when any of the processes modifies any statement or variable in the code. It would not be reflected in other process codes. Let’s suppose if child process modifies the code it would not affect the parent process.

Some child process after their creation immediately calls exec(). The exec() system call replaces the process with the program specified in its parameter. Then the separate address space of child process is of no use. The one alternative here is copy-on-write.

The copy-on-write let the parent and child process to share same address space. If the any of the processes writes on the pages in address space the copy of address space is created to let both the process work independently.

Definition of vfork()

The modified version of fork() is vfork(). The vfork() system call is also used to create a new process. Similar to the fork(), here also the new process created is the child process, of the process that invoked vfork().  The child process code is also identical to the parent process code. Here,the child process suspends the execution of parent process till it completes its execution as both the process share the same address space to use.

As the child and parent process shares the same address space. If any of the processes modifies the code, it is visible to the other process sharing the same pages. Let us suppose if the parent process alters the code; it will reflect in the code of child process.

As using vfork() does not create separate address spaces for child and parent processes. Hence, it must be implemented where the child process calls exec() immediately after its creation. So, there will be no wastage of address space, and it is the efficient way to create a process.  vfork does not use copy-on-write.

Key Differences Between fork() and vfork()

  1. The primary difference between fork and vfork is that the child process created by the fork has a separate memory space from the parent process. However, the child process created by the vfork system call shares the same address space of its parent process.
  2. The child process created using fork execute simultaneously with the parent process. On the other hand, child process created using vfork suspend the execution of parent process till its execution is completed.
  3. As the memory space of parent and child process is separate modification done by any of the processes does not affect other’s pages. However, as the parent and child process shares the same memory address modification done by any process reflects in the address space.
  4. The system call fork() uses copy-on-write as an alternative, which let child and parent process share the same address space until any one of them modifies the pages. On the other hand, the vfork does not use copy-on-write.

Conclusion

The vfork() system call has to be implemented when child process call exec() immediately after its creation using fork(). As separate address space for child and parent process will be of no use here.

Related Differences:

  1. Difference Between Copy Constructor and Assignment Operator in C++
  2. Difference Between Thread Class and Runnable Interface in Java
  3. Difference Between Call By Value and Call by Reference
  4. Difference Between Aggregation and Composition
  5. Difference Between Process and Thread

Comments

  1. Adithya says

    November 29, 2018 at 8:55 am

    A very concise explanation. It really helped me understand it better. Thank you.

    Reply
  2. Krishn says

    February 6, 2019 at 8:33 pm

    A very nice and detailed explanation!
    Thanks a lot!!

    Reply
  3. arun mane says

    April 11, 2019 at 7:02 pm

    What an explanation…! Really information is helpful. Thanks for posting.

    Reply
  4. Rajkanya Saha says

    April 25, 2019 at 3:48 pm

    Thank you for simplifying!

    Reply
  5. K says

    October 15, 2019 at 6:54 am

    Good explanation

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Top 10 Differences

  • Difference Between OLTP and OLAP
  • Difference Between while and do-while Loop
  • Difference Between Guided and Unguided Media
  • Difference Between Preemptive and Non-Preemptive Scheduling in OS
  • Difference Between LAN, MAN and WAN
  • Difference Between if-else and switch
  • Difference Between dispose() and finalize() in C#
  • Difference Between for and while loop
  • Difference Between View and Materialized View
  • Difference Between Server-side Scripting and Client-side Scripting

Recent Addition

  • Difference Between Java and Python
  • Difference Between PHP and HTML
  • Difference Between GPS and GNSS 
  • Difference Between Virtualization and Containerization
  • Difference Between Storage and Memory

Categories

  • Artificial Intelligence
  • DBMS
  • Hardware
  • Internet
  • Networking
  • Operating System
  • Programming
  • Software

Copyright © 2025 · Tech Differences · Contact Us · About Us · Privacy