This is the start of another mini series on Process Management in Operating Systems. Process Managemenet is a wide topic that cannot be covered I think in two to three posts. I will be discussing about Processes, Threads, Scheduling, and Concurrency etc.
In the early days of the computers one computer which was as big as a truck could run only one program at a time. That means that one program had access to all the resources a computer but modern computers allow us to run multiple programs at once and can fit in the palms of our hands.
Modern computers are becoming more and more powerful everyday and are able to handle hundreds of processes at a time. But what is a process and that is what I will be learning about from now.
The Process
As mentioned above that the early computers only executed one program at a time, We call these types of computers Batch Computers. But now a days even a single-user system can execute more than one programs at a time like a browser and a word processing softwore etc. All these programs are handeled by the OS that run activites to execute them. These activites are called processes. Process is also called a Job because in the past when OS was a new concept job was the term used for what we now call a process so many of the terms in the OS are named after the term job rather than the process.
A Process is a program in execution. it needs resources during the execution to accomplish it task. A process is like a unit of work in most of the systems. The status of current activity of a process is represented by the value of the program counter and the contents of the processor's registers.
The memory layout of a process is divided into multiple parts, Text, Data, Heap and Stack.
- Text Section - The executeable code
- Data Section - Global variables
- Heap Section - The memory that is dynamically allocated during the program runtime
- Stack Section - Temporary data storage when invoking functions
The size of Text and Data in memory are fixed and will not change during the execution while the Heap and Stack will shrik and grow according to their use in the program. Heap will grow when ever the memory is allocated dynamically during the execution and will shrink whenever the memory is deallocated during the execution. Stack will grow when a function is called and will shrink whenever the dunction will return something.
A process is not a program itself but a program becomes a process when it is called into the memory either by double clicking the program icon or typing the name of the program in a command-line interface. Even if two processes are associated with the same program they will be considered two different execution environments.
The State Of The Process
A process has a state which changes as it executes. A process state is defined by the current activity of that process. It could be in waiting state of terminating state etc. A process can be in one of the following states.
- New - The process is being created.
- Ready - The process is ready to be assigned to the processor.
- Waiting - The process is waiting for some event to occur like a key press.
- Running - The process instructions are being executed.
- Terminated - The process has finished execution.
Figure from Book Operating System Concepts