A process is program in execution in a modern time-sharing computer. A process needs resources such as CPU, memory, and input-output devices. OS is responsible for creating, deleting, and maintaining process information.
Therefore, we can safely say the following things about the process:
- A process is an instance of a program in execution in a time-sharing computer.
- All processes are executed sequentially.
- A process may or may not call another process.
- A process is an ongoing activity of computer, defined by the program counter and data contents of processor registers.
Each process gets address space (virtual) which consists following:
- Stack address space
- Data address space
- Space for source code
See the figure below.
Stack Address space
The stack space is used for functions and system calls. The system calls are functions that belong to OS.
Data Address Space
A process will not execute unless all the required information is available. The process keeps both static and dynamic allocated variables in its data space.
Source Code Space
The source code section contains read-only code so that the process does not modify it. This address space contains only text information.
Many instances of a program mean multiple addresses will be created, one for each instance.
The operation on the process is:
- creating a new process
- terminating a process
Every time a new process is created it gets an ID. The getpid
() and getppid
() allows a process to get their process id. A process is created by OS as soon as a program is loaded into the memory. The OS provides the necessary resources for the process. The running process can change state and can be terminated using various system calls.
Creates a new child process which is a copy of the parent with a new pid. The child process gets its own pid, address space, but return different values.
The exec() runs a list of system calls and replaces the current process with a named program. The entire address space of the current process is replaced with a new program.
signal(), kill(), exit() and abort()
abort() terminates the process and claim the resources of the terminated process.
Process Control Block (PCB)
The OS represents a process with a process control block, also known as the task control block. It contains the following information about the process.
Process state – A process could be in any state after it is created such as new, ready,
Process ID – Every new process gets a unique number called process ID to uniquely identify the process.
Program Counter – It contains the address of the next instruction to be executed.
CPU Registers – When an interrupt occurs the current process state is saved, this allows the process to continue later.
CPU Scheduling information – The PCB contains process scheduling information in the form of process priority, a pointer to scheduling queue, and other process scheduling information.
Memory Management Information – Depending on the memory management technique, PCB contains information such as the address of base and limit registers, segments tables or page tables.
Accounting Information – This information includes CPU usage, account number, process number, and so on.
I/O Status – It includes a list of devices assigned to the process and list of open files, etc.
In the next article, you learn about computer system structure.
Abraham Silberschatz, Peter B. Galvin, Greg Gagne (July 29, 2008) Operating System Concepts, 8 edn., : Wiley.
Tanenbaum, Andrew S. (March 3, 2001) Modern Operating Systems, 2nd edn., : Prentice Hall.