Lab 1: Process Control Jan. 10/11, 2007 |
The fork() system call creates a new process that is a copy of
the calling process, except that it has its own copy of the memory, its
own process ID, and its own pointers to shared kernel entities. After
fork() has been called, two processes will execute the next statement
after the fork() in their own address spaces: the parent and the child.
If the call succeeds, then in the parent process, fork() returns the
process ID of the newly created child process and in the child process,
fork returns zero.
The exec() family of system calls changes the program that a process is currently executing. For example, execve() has the form
The path argument is the pathname of a file that contains the new program to be executed. The argv array is a list of parameter strings, and the envp array is a list of environment variable strings and values. When a process encounters the execve() system call, the next instruction it executes will be the one at the entry point of the new executable file. The wait() system call is used by a process to block itself until the kernel signals the process to execute again, for example because one of its child processes has terminated. |
|
|