Q1. What is Address Space of Process?
Ans. There are also two possibilities in terms of the address space of the new process:
1. The child process is a duplicate of the parent process (it has the same program and data as the parent).
2. The child process has a new program loaded into it.
To illustrate these differences, let’s consider the UNIX operating system. 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 (the parent and the child) continue execution at the instruction after the fork(), with one difference: The return code for the fork() 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’s memory space with a new program. The exec () system call loads a binary file into memory starts its execution.
In this manner, the two processes are able to communicate and then go their separate ways. The parent can then create more children; or, if it has nothing else to do while the child runs, it can issue a wait () system call to move itself off the ready queue until the termination of the child.
The parent waits for the child process to complete with the wait () system call. When the child process completes (by either implicitly or explicitly invoking exit()) the parent process resumes from the call to wait (), where it completes using the exit () system call.
Figure: Process Creation