Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Difference B/W TCB(Thread control block) & PCB(Process)

A process control block (PCB) and a Thread Control Block (TCB) are both used in linux kernels to have time on the CPU delegated to them. What are the difference between the two?

What information is generally maintained in a process control bloc (PCB)?

like image 429
Gabriel Fair Avatar asked Feb 29 '12 15:02

Gabriel Fair


3 Answers

Some notable fields that the PCB could contain are the process id, process group id, the parent process and child processes, the heap pointer, program counter, scheduling state (running, ready, blocked), permissions (what system resources the process is allowed to access), content of the general purpose registers, and open files.

TCB has a few of the same fields as the PCB (register values, stack pointer, program counter, scheduling state), in addition to a few specific values like the thread id and a pointer to the process that contains that thread. Note that there is not protection between threads.

In Linux there is a struct task_struct that stores information about a thread or process. It is declared in sched.h.

like image 184
phinkle Avatar answered Oct 05 '22 18:10

phinkle


The PCB stores information about the kernel process. Like adressspaces etc...

A process can include different kernel threads. Both are managed by the dispatcher and scheduler.

The TCB includes thread specific information.

like image 40
TheBassMan Avatar answered Oct 05 '22 17:10

TheBassMan


'A process control block (PCB) and a Thread Control Block (TCB) are both used in kernels to have time on the CPU delegated to them' - not normally, no. A PCB will have one or more TCB's linked to it. The TCB describes an execution context, (eg. stack pointer), the PCB an environment context, (eg. memory segments and permissions).

like image 43
Martin James Avatar answered Oct 05 '22 19:10

Martin James