9

A PCB is a process control block , this is its definition on Wikipedia

Process Control Block (PCB, also called Task Controlling Block,[1] Task Struct, or Switchframe) is a data structure in the operating system kernel containing the information needed to manage a particular process. The PCB is "the manifestation of a process in an operating system

and its duty is :

Process identification data
Processor state data
Process control data

So where is the PCB of a process to be found?

14

In the Linux kernel, each process is represented by a task_struct in a doubly-linked list, the head of which is init_task (pid 0, not pid 1). This is commonly known as the process table.

In user mode, the process table is visible to normal users under /proc. Taking the headings for your question:

  • Process identification data is the process ID (which is in the path /proc/<process-id>/...), the command line (cmd), and possibly other attributes depending on your definition of 'identification'.

  • Process state data includes scheduling data (sched, stat and schedstat), what the process is currently waiting on (wchan), its environment (environ) etc.

  • Process control data could be said to be its credentials (uid_map) and resource limits (limits).

So it all depends how you define your terms... but in general, all data about a process can be found in /proc.

  • "the head of which is init_task (pid 0, not pid 1)" There's no such thing as init_task. It's init, and its pid is 1, not 0 (confirmed via pidof init). – AleksandrH Sep 15 '18 at 14:42
  • 1
    @AleksandrH init_task is a kernel structure and not a process. It points to the idle task which is internally represented by pid 0. init_task and init are completely different things. – Flup Sep 15 '18 at 15:39
  • And yet pid is only for processes... – AleksandrH Sep 15 '18 at 16:38
  • 1
    @AleksandrH Read init/init_task.c in the kernel source tree (github.com/torvalds/linux/blob/master/init/init_task.c). – Flup Sep 15 '18 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.