In UNIX, each process is identified by its process identifier, which is a unique integer. A new process is created by the fork system call. The new process consists of a copy of the address space of the original process.
This mechanism allows the parent process to communicate easily with its child process. Both processes continue execution at the instruction after the fork system call, with one difference ——-
The return code for the fork system call is zero for the new (child) process, whereas the (nonzero) process identifier of the child is returned to the parent.
Typically the exec system call is used after a fork system call by one of the two processes to replace the process memory space with a new program.
In the multithreaded program, the semantics of the fork and exec system call change. If one thread in a program calls fork, does the new process duplicate all threads or is the new process single-threaded?
Some Unix system has chosen to have two versions of the fork, one that duplicates all threads and another that duplicates only the thread that invoked the fork system call.
If a thread invokes the system call, the program specified in the parameter to exec will replace the entire process- including all threads and LWPs.
The usage of the two versions of fork depends upon the application. If exec is called immediately after forking, then duplicating all threads is unnecessary, as the program specified in the parameters to exec will replace the process.
In this instance, duplicating only the calling thread is appropriate. if, however, the separate process does not call exec after forking, the separate process should duplicate all threads.
In the case of any queries, you can write to us at firstname.lastname@example.org we will get back to you ASAP.
Hope! you would have enjoyed this post about the Fork() and Exec() system call.
Please feel free to give your important feedbacks in the comment section below.
Have a great time! Sayonara!
- ICMP – Internet Control Message Protocol
- खजुराहो से छतरपुर, टीकमगढ़ होकर दिल्ली के लिए चलेगी ट्रेन, Train from Khajuraho to Delhi via Chhatarpur and Tikamgarh.
- What Is The Internet And Its Applications?
- Internet vs Extranet
- What is Intranet and extranet in a computer network 2020?
- ATM vs Frame Relay
- Telecommunication Network & Corporate Network
- What are the various Network Topologies?
- Online Fraud: Data Entry and Part-Time Job.
- Pepper and Jones Is a Scam or legit?