CSE 80 -- Lecture 2 -- Jan 9

This lecture covered the things that happen when a command interpreter read in commands.

I started with the basic process picture notation:

The large oval is the process, and the little bubbles are the I/O descriptors associated with that process. The arrows specify the direction of data flow, so in the above picture, descriptor 0 is an input-only descriptor, and descriptors 1 and 2 are output-only descriptors. When/if the process opens new files, new bubbles would be added.

I talked about the fork(2) and execve(2) system calls. These system calls are the method by which new processes are created and new programs run. The model is that fork clones the process making the request, so that the system ends up with two processes that are virtually identical -- both have the same memory (copies of the original), same registers, etc, and both are in the process of returning from the fork syscall. The only difference is that in one, named the parent, the process ID remains the same, and the return value of fork is the process ID of the other, new process. This process is called the parent process. The newly created process is called the child process and is distinguished from the parent by the return value of the fork, which will be zero.

I also covered the idea of inheritance: the state that is carried over from the parent process to the child. This state information include the current working directory, the signal status for ignored signals, the I/O descriptors (which are shared between the parent and child), the environment, etc.

The ideas of process creation and inheritance go together. In particular, when we look at I/O redirection, where the descriptors refer to files instead of a terminal, understanding how this works is important.

[ CSE 80 | ACS home | CSE home | CSE calendar | bsy's home page ]
picture of bsy

bsy@cse.ucsd.edu, last updated Tue Mar 18 15:49:23 PST 1997.

email bsy