Suppose a process ie parent forks a child process using reso

Suppose a process (i.e., parent) forks a child process using resource sharing such that the parent and child share all resources. Does this include the Process Control Block and memory space or does the child get its own copy? Explain your answer (why the child would or would not get its own PCB and memory space).

Solution

When the main program executes fork(), an identical copy of its address space, including the program and all data, is created.System call fork() returns the child process ID to the parent and returns 0 to the child process. The fork operation creates a separate address space for the child.The child process has an exact copy of all the memory segments of the parent process.

The child may be an exact duplicate of the parent, sharing the same program and data segments in memory. Each will have their own PCB, including program counter, registers, and PID. This is done to remove the choas in the execution of a process.The child process performs only a small set of actions before it ceases execution of its program in favour of the program to be started, and it requires very few, of its parent\'s data structures.After the fork, both processes not only run the same program, but they resume execution as though both had called the system call. They can then inspect the call\'s return value to determine their status, child or parent, and act accordingly. The child gets its own PCB or memory space as it starts off with a copy of its parent\'s file descriptors.For interprocess communication, the parent process will often create a pipe or several pipes, and then after forking the processes will close the ends of the pipes that they don\'t need.

 Suppose a process (i.e., parent) forks a child process using resource sharing such that the parent and child share all resources. Does this include the Process

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site