Sie sind auf Seite 1von 3

Shahbaz Ali Operating Systems Lab

401-BSCS-14 Assignment 3 ( Q2 )
Section E-1 Dr. Awais Qasim
-------------------------------------------------------------------------------------------------------------------
Process Control Block
Process Control Block, also known as Task Control Block is the structure defined in sched.h file located at
/usr/src/linux-headers-4.8.0-49/include/linux/, by the name of task_struct. This structure has everything that a
process need for its execution. Let’s have look at few of the elements defined in the structure.

- volatile long state


This long variable with keyword volatile (which means variable can change at any time during
program execution) stores the current state of the process. The value of the variable can be one of
the following predefined constants defined in sched.h:
TASK_RUNNING 0
TASK_INTERRUPTIBLE 1
TASK_UNINTERRUPTIBLE 2
TASK_STOPPED 4
TASK_TRACED 8
If the value of state is less than 0 then it means that program cannot run.

- unsigned long sleep_avg


This variable store the average sleep time of the task throughout his life until it dies.

- int static_priority
This integer variable is used to store the priority which is allocated to the process when it is
created.

- int normal_priority
This normal priority stores the value of priority calculated from static_priority and the priority
which is assigned to the process by scheduling algorithm.

- int prio
This is value of priority which is given to the process by the scheduling algorithm/policy
currently in use.
- unsigned int policy
The scheduling policy used by the kernel for this process.

- pid_t pid
Process Identifier of the process assigned by kernel.

- pid_t tgid
Process Identifier of the group leader of the current process if it is working as a thread.

- struct list_head children


The head of the list which contains all the children of the current process.

- struct list_head sibling


The head of the list which contains all the process who has same parent as this one.

- struct task_struct *parent


The pointer to the parent of the current process.

- struct task_struct *group_leader


The pointer to the group leader of the current process/thread.

- cpumask_t cpus_allowed
This defines the number of processes which process can access and use.

- unsigned int time_slice


It defines the time required by the CPU to complete its task. Useful in Round Robin Scheduling
Algorithm.

- unsigned long long timestamp


Keeps the total time of the process since it has come into existence. This is useful to calculate
the priority of the process so that it can’t starve.

- struct list_head tasks


The head of the list containing all the processes which is active in the kernel.
- struct user_struct *user
A pointer to the user who owns (or created ) the process.

-----------------------------------------------------------------------------------------

Das könnte Ihnen auch gefallen