Have you ever executed a process? Have your process changed states? In this post, we going to cover the notion of a process and process states. We will understand: what is a process? How to convert your program into a process? What are the different states of a process? and Where all the information related to a process is stored?
After you write a program in any language, two steps follow:
The second step is what makes that program a process. You double-click any software in your computer system or you tap on any application your mobile or you write a command like $./a.out, all these convert the application(program) into a process. Every application is a program until you execute it by double click or a tap or a command, after which it becomes a process.
So, a process is a program in execution
Now, once you initiate a process, the operating system loads it into the memory (RAM). Inside the RAM the structure of the process looks like as shown below:
The text section contains the program or the code, the data section contains the global variables. These two sections have fixed size because neither the code is going to change nor the variables used in the program. Heap is used for dynamic memory allocation. Now, we use dynamic memory allocation when we can not determine the memory required. Hence the heap section can grow in size if required.
Lastly, the stack section is used for functions. Again, the size of this section is also variable. Because it is difficult to determine the number of function calls required. Consider a program for factorial calculation which uses recursive functions. If the number is 5 then the function call is 5 times. If the number for factorial is 20, then the function call is 20 times. So the system does not know what exactly will be the stack size. Hence, the stack size is variable.
Program: is a passive entity
Process: is a active entity
Q1.Can two processes be associated with the same program?
Share you answers in comments section below
A process can change its state during its lifetime. The various states of a process are:
For best visualization and better understanding of process states visit this link:
Note: the link may not work in Chrome. Use Microsoft Edge. Also, it might require to allow the use of flash.
Sometimes a running process changes its state to waiting or ready and then back to running. In this case all the related information of a process needs to saved so that it can be later loaded when the process starts to execute again. This information is saved in Process Control Box(PCB). Another name pf PCB is Task Control Box. The most common information stored is:
Note: Clicking on the “next” slide button will not display any animation. Hence, Click within the slide area for animations.
Previous Next OS Services and System Calls Process Schedulers