Re: how this is done: process and thread have their own register set?



On Sep 17, 9:46 pm, linq936 <linq...@xxxxxxxxx> wrote:
Hi,
I come across this question: each process and thread has its own
register set, at least program counter register.

It's own *logical* program counter. It does not have its own program
counter register. Only cores (CPUs) have physical program counter
register.

But one processor has
only one PC register, right?

Right, so when a thread is running on a processor, that's where its
program counter is. When it's not running, it's program counter is
stored elsewhere. When a thread is not running, there is no reason its
program counter needs to be in a CPU's program counter register.

If this is the case, then how can
multiple processes have their own PC register?

Each thread always stores its logical PC register *somewhere*. While
it's running, that in a CPU's physical PC register. While a thread is
not running, that's in a memory area somewhere.

Do they have to swap out? But how about thread?

They have to swap out of the CPU register and into memory. This whole
discussion should more properly about threads, not processes.

Part of a thread's context, when its not running, it its PC register,
its stack pointer, and anything else needed for it to resuming
running.

DS

.



Relevant Pages

  • Re: Rtos Design
    ... of which all could be used as program counter. ... simply specify which register to use as the program counter ... When the subroutine is going to "exit", ... register using the SEP R7 instruction and the calling routine ...
    (comp.arch.embedded)
  • Re: [PATCH] 2-ptrace_multi
    ... that the error number is stored in the register PT_CCR (a.k.a. R38) ... so I need an extra call to get that, then I need the program counter which is ... Daniel Jacobowitz ...
    (Linux-Kernel)
  • Re: Assistance with linking ramDrv
    ... Non operational vector ... Status Register: 0x10007f01 ... Tlb Load Exception ... Exception Program Counter: 0x803774b0 ...
    (comp.os.vxworks)
  • Re: Dumping stacktrace on HPUX itanium using gdb
    ... You can always do "info registers" to get the register contents. ... Program counter can be ... > pointer, register values etc., debug at assembly level). ...
    (comp.sys.hp.hpux)
  • Re: Why are variables stored on the stack?
    ... memory area that is accessed by a dedicated register. ... dedicated stack registers but within C it HAS A STACK as I ...
    (comp.lang.c)