Home > Back-end >  What is the program counter of PCB when multiple threads for same process are running at same time?
What is the program counter of PCB when multiple threads for same process are running at same time?

Time:09-02

There is a Process (P1) which has 4 threads T1, T2, T3 and T4. It's a multi processing system with 2 CPU cores. Now all threads are running in parallel, suppose T1,T2 on CPU Core1 and T3,T4 on CPU Core2. Each thread has its own program counters in TCB. But what will be the Program Counter of the PCB when all threads are running at same time

CodePudding user response:

It is certainly a legacy view since it makes no sense for multi-threaded processes. AFAIK, no mainstream OS has such a field for processes. In fact, Linux do not have really a PCB but a task_struct data structure (see here). It is not clear for Windows, which is closed-source, but it looks like there is not such a field either based on the provided APIs (see here). In FreeBSD, there is a pcb structure but is it always linked to a proc and thread structure (see here) so I guess the RIP field is unused in the PCB. This is especially true since this field has been mostly left untouched since 26 years, apart from the 32-bit to 64-bit switch 20 years ago, that is, mainly before the emergence of multicore processors 15-20 years ago (in fact, the thread data structure has been created 21 years ago).

  • Related