What is a Process?
A process is a program in execution. Process is not as same as program code but a lot more than it. A process is an 'active' entity as opposed to program which is considered to be a 'passive' entity. Attributes held by process include hardware state, memory, CPU etc.
Process memory is divided into four sections for efficient working :
- The text section is made up of the compiled program code, read in from non-volatile storage when the program is launched.
- The data section is made up the global and static variables, allocated and initialized prior to executing the main.
- The heap is used for the dynamic memory allocation, and is managed via calls to new, delete, malloc, free, etc.
- The stack is used for local variables. Space on the stack is reserved for local variables when they are declared.
S.N. | Component & Description |
---|---|
1 |
Stack
The process Stack contains the temporary data such as method/function parameters, return address and local variables.
|
2 |
Heap
This is dynamically allocated memory to a process during its run time.
|
3 |
Text
(It is made up of the compiled program code that contain the program instruction)
This includes the current activity represented by the value of Program Counter and the contents of the processor's registers.
|
4 |
Data
This section contains the global and static variables.
|
Memory Layout of a C / C++ Program:
PROCESS CONTROL BLOCK
There is a Process Control Block for each process, enclosing all the information about the process. It is a data structure, which contains the following :
- Process State - It can be running, waiting etc.
- Process ID and parent process ID.
- CPU registers and Program Counter. Program Counter holds the address of the next instruction to be executed for that process.
- CPU Scheduling information - Such as priority information and pointers to scheduling queues.
- Memory Management information - Eg. page tables or segment tables.
- Accounting information - user and kernel CPU time consumed, account numbers, limits, etc.
- I/O Status information - Devices allocated, open file tables, etc.
To learn more about PCB here:-
No comments:
Post a Comment