Understanding Programs, Processes, and OS Management
A program is not static; it is a set of instructions that, once executed, solves a problem. It represents something that does not change.
A process is dynamic; it is a piece of a program that is running, along with everything this implies: values of registers, variables, the contents of the program counter, etc.
The operating system is responsible for the following activities related to the management of processes:
- Creating processes (both system and user)
- Planning processes
- Providing mechanisms for synchronization, communication, and deadlock management between processes
All modern computers can do several things at once. While running a user program, a computer can read from a disk and print to a terminal or printer. In a multiprogramming system, the CPU also alternates between programs, each running for dozens or hundreds of milliseconds. This rapid alternation is known as multiprogramming or multitasking.
Process Definition and Components
A process is a running program with all its associated environment (files, registers, variables, commands that form the running program, data, stack, etc.).
A process is represented internally by the operating system as a data structure called the Process Control Block (PCB), which includes its current state, resources used, registers, etc.
Process Control Blocks are stored in queues. Each queue represents a particular process state. There are many types of queues, corresponding to the different states a process can adopt. For example, there will be a queue of blocked processes, another for ready processes, etc.
The states of processes are handled by the operating system, making this transparent to the user, who believes their process is always running.