1.9. Processes

Before You Begin

It is assumed the reader knows what Unix is. If not, please read Section 1.2, “What is Unix?” before proceeding.

A process in Unix terminology is the execution of a program.

Unix is a multitasking system, which means that many processes can be running at any given moment, i.e. there can be many active processes.

When you log in, the system creates a new process to run your shell program.

When you run a program (a command) from the shell, the shell creates a new process to run the program. Hence, you now have two processes running: the shell process and the command's process.

The process created by the shell to run your command is a child of the shell process.

Naturally, the shell process is called the parent of the command process.

Each process is uniquely identified by an integer serial number called the process ID, or PID.

Unix systems also keep track of each process's status and resource usage, such as memory, CPU time, etc. Information about your currently running processes can be easily viewed using the ps (process status) command:

shell-prompt: ps
 PID TTY           TIME CMD
7147 ttys000    0:00.14 -tcsh
7438 ttys000    0:01.13 ape notes.dbk unix.dbk
7736 ttys001    0:00.13 -tcsh
	

Practice Break

Run the ps command. What processes do you have running?

shell-prompt: ps
shell-prompt: ps -ax
	    

Another useful tool is the top command, which monitors all processes in a system and displays system statistics and the top (most active) processes every few seconds. Note that since top is a full-terminal command, it will not function properly unless the TERM environment variable is set correctly.

Practice Break

Run the top command. What processes are using the most CPU time? Type 'q' to quit top.

shell-prompt: top
	    

1.9.1. Self-test

  1. What is a process?
  2. When are processes created?
  3. How does the Unix system distinguish between all the processes running at a given moment?
  4. What command(s) will show you the processes that are currently running?