What is a process
A program in execution is called as a process. A process is an active entity, means it can be a cause of change in system’s state/data/elements.
when does a program becomes a process
A program is a file stored on secondary storage which contains, set of instruction written for some specific purpose. When this program is executed (say double clicked) it will be loaded into main memory (file or the instruction). To execute it, CPU looks for PC (program counter, which stores tells CPU the next instruction to be executed). So this program will be be allocated a PC value. A stack, heap to store static/local and dynamic/global variables, and an ID (PID or process ID) to disgustingly recognize it among all other processes, will also be assigned to it. After allocating these information/resources now it becomes a process.
So, a process can be realized as:
Process = program+resources
Process in main memory(RAM)
Following figure shows a process in main memory:
- Creating and removing (destroying) process
- Controlling the progress of processes
- Acting on interrupts and arithmetic errors.
- Resource allocation among processes
- Inter process communication
Process creation using fork() system call
When a process invokes/calls fork() function, a new process is created which has the same address space.
As the address space is copied => PC (program counter) will also has the same value as old process has. That means the newly created process (also called as child process) will start executing from the instruction, parent process is currently executing => just after the fork().
For more details about Process management and Inter process communication please refer following slide: