Chapter 13. Processes

A process is an instance of a running program. New processes are started by the fork() and execve( ) system calls, and normally run until they issue an exit() system call. The details of the fork( ) and execve( ) system calls are complex and not needed for this book. Consult their manual pages if you want to learn more.

Unix systems have always supported multiple processes. Although the computer seems to be doing several things at once, in reality, this is an illusion, unless there are multiple CPUs. What really happens is that each process is permitted to run for a short interval, called a time slice, and then the process is temporarily suspended while another waiting process is given a chance to run. Time slices are quite short, usually only a few milliseconds, so humans seldom notice these context switches as control is transferred from one process to the kernel and then to another process. Processes themselves are unaware of context switches, and programs need not be written to relinquish control periodically to the operating system.

A part of the operating-system kernel, called the scheduler, is responsible for managing process execution. When multiple CPUs are present, the scheduler tries to use them all to handle the workload; the human user should see no difference except improved response.

Processes are assigned priorities so that time-critical processes run before less important ones. The nice and renice commands can be used to adjust process ...

Get Classic Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.