A process is unit of work in operating system. A process is a program in execution. The process is different from the program as program is a passive entity which is a file containing the list of instructions stored on the disk whereas process is an active entity with a program counter specifying the next instruction to execute and a set of associated resources. A process includes:
- Program Counter: It specifies next instruction to be executed.
- Stack: it contains temporary data such as return addresses.
- Data Section: It contains global variables.
As process executes, it changes its state. By its current activity, the process can be in one of the following state:
- New: The process is being created.
- Running: The instructions are being carried out.
- Waiting: The process is waiting for some event to occur.
- Ready: The process is waiting to be assigned to processor.
- Terminated: The process has finished.
It must be noted that only one process can be running on any processor at any instant, other processes may be in ready or waiting state.
Process Control Block
Each process is represented in operating system by Process Control Block (PCB). It contains process specific information:
- Process State: As discussed above, the state can be new, ready, running, waiting, terminated.
- Program Counter: The counter indicates the address of the next instruction to be executed for this process.
- CPU Registers: They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information.
- CPU Scheduling information: This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters.
- Memory-management information
- Accounting information: This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on.
- I/O status information: This information includes the list of I/O devices allocated to the process, a list of open files, and so on.