You are on page 1of 4

ASSIGNMENT NO: 2

Operating System - Null

JUNE 25, 2020

RUKHSAR TARIQ
17137072
Q: What is PCB?
Ans:
Pcb stands for “Process control Block”. It is a data structure and is used
by operating system to store all the information about a process. When a
process is initialized, a corresponding pcb is created by OS. It is also
called “task controlling block”.
Pcb keeps all the information needed to keep track of a process. The main
components of pcb are as follows:

 Process state
 Pointer
 Program counter
 Registers
 Scheduling information
 I/O status information
 Memory Management Information
 Accounting information
 Process privileges

Q: What is the Format of Process Control Block (PCB)


in Linux?
Ans:
The pcb in Linux is represented by C structure task_struct. It
contains all the necessary information for representing a process which
includes process state, scheduling, memory management information,
list of open files and pointers to the process’s parent and its children.
Format of task_struct in Linux:

Task_Struct:
Volatile long state: This contains the state of the process.
Long counter: This value acts as pointer on the task structure of a
process.
Long priority: when several process are being executed, there is an
order according to which those processes supposed to execute and this
is handled by Long priority.

Unsigned long signals: This handles the pending signals involved


during process.
Unsigned long block: this handles masked signals.

Process Relationships:
Struct task_struct p_opptr: this is the pointer to the original parent.
Struct task_struct p_pptr: this points to intermediate parent.
Struct task_struct p_cptr: this points to most recent children.
Struct task_struct p_ysptr: this is the pointer to current/following
sibling.
Struct task_struct p_osptr: this points to previous sibling.

next_task: it has the structure of the next task in queue of process.


prev_task: this contains the structure of the previous tasks in the
process list.
next_run: it contains the structure of the next process which are ready
to run in ready queue.
prev_run: it contains the structure of previous executed process in
ready queue.
Struct thread_struct tss: it contains saved registers.
Struct_mm_struct mm: it contains the address space of the current
process.
Int pid,gpid: every process has an id i.e. pid which is the id of first
process and a group thread id tgid, getpid() returns this id so all the
threads in the process share the same process id. Linux kernel uses
pidhash to efficiently find the processes by pids.
Unsigned int time_slice: it contains scheduling information.

You might also like