Difference between fork() and exec()The computer system has two modes: kernel mode and user mode. In kernel mode, a program may directly access memory and hardware resources. In user mode, programs may not directly access hardware and memory resources. As a result, kernel mode is more privileged than user mode. UNIX systems use a variety of system calls. Fork and exec are two of them. In this article, you will learn the difference between the fork() and exec(). But before discussing the differences, you must know about the fork and exec(). What is fork()?The fork () system calls aids in the creation of processes. When a process uses the fork() system call, it creates a replicate of itself. The parent process is the existing process, and the child process is the new process. Although, the child process is equivalent to the parent process. When creating the child process, the parent state like open files, address space, and variables are copied to the child process. In other words, the child and parent processes are located in separate physical address spaces. As a result, the modification in the parent process doesn't appear in the child process. What is exec()?The exec() system call is used to make the processes. When the exec() function is used, the currently running process is terminated and replaced with the newly formed process. In other words, only the new process persists after calling exec(). The parent process is shut down. This system call also substitutes the parent process's text segment, address space, and data segment with the child process. Main differences between the fork() and exec()Here, you will learn the main differences between the fork() and exec(). Various differences between the fork() and exec() are as follows:
Head-to-head comparison between the fork() and exec()Here, you will learn the head-to-head comparison between the fork() and exec(). Various head-to-head comparisons between the fork() and exec() are as follows:
Next TopicLatency vs Jitter |