Q- What is process context? Describe it and associated task structure in detail.
Ans- Process context consists of 4 segments mainly which are:-
The process starts from a low address (greater than NULL), and then keeps moving on to a higher address, which is the stack segment.
1. Code Segment
This is the starting segment where all of the code needs to pass through. Here code is thought of as a text mainly.
2. Data Segment
This is the segment which as the name states, stores all the data in it which includes the initialized data, uninitialized data, and heap segment. Heap segment storesall the data declared dynamically, which is the pointers and relevant data using malloc, realloc, calloc and so on.
3. Library Mappings
This is a segment created by engineers working on C, which include in-built header files and their relevant functions like stdio.h, stdlib.h, conio.h, etc.
4. Stack Segment
Stack segment consists of all the static data declared like variables, static variables, etc.
Tasks are the processes running in background which helps your terminal to execute your program easily.
Task structure consists of following things:-
1. Process id
Every process running in system has a process id and there are several processes running in the background, hence there are several process ids. Process id is unique for every project and it starts from 1 to the limit provided by the processor.
2. Parent Process id
This is the id which creates the process id mentioned in the previous step. This include programmes like bash, etc.
3. Real Parent id
This is the id through which all the processes have been created.
4. State
States are of 4 types:-
1. Read Only
2. Write only
3. Read and write
4. Executable
5. Program Counter
As the name signifies, it counts the total no. of programs in the system.