Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Explain the actions perfomec by fork 2. Explain the return values from the fo

ID: 3743989 • Letter: 1

Question

1. Explain the actions perfomec by fork 2. Explain the return values from the fork) function from from the point of view of the parent and child process 3. What attributes from the child and parent process are different? 4. What function is used to get the ID of a process? 5. What function is used to get the ID of the parent process? 6. What is a process image? 7. What happens to the original process image when exec() is called? 8. What are the differences among the family of exec() functions? 9. Explain the exec() family functions 10. Explain the id t waitpid (pid t pid, int *status-ptr int options) function 11. Explain the parameters of previous function 12. Explain the pid t wait (int *status-ptr) function 3. Explain its difference with waitpid)

Explanation / Answer

Answer :

1. System call fork() is used to generate processes. It obtains no arguments and returns a procedure ID. The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call.

2. Fork system call use for creates a new process, which is called child process, which runs concurrently with process (which process called system call fork) which is called parent process. After a new child process created, both processes will execute the next instruction following the fork() system call. A child process utilize similar program counter, similar CPU registers, similar open files which uses in parent process.

It obtains no parameters and return integer value. The various values returned by fork().

Negative Value: formation of child process was unsuccessful.

Zero: Returned to the newly created child process.

Positive value: Returned to parent or caller. The value contains process ID of newly created child process.

3.

4. We can obtain the process ID of a process known as getpid . The process ID of the parent of the current process (this is also known as the parent process ID) will be returned by the function getpid. The program needs to comprise the header files unistd.h and sys/types.h to use these functions.