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



linq936 wrote:
Hi,
I come across this question: each process and thread has its own
register set, at least program counter register. But one processor has
only one PC register, right? If this is the case, then how can
multiple processes have their own PC register?

They don't. Each has a *copy* of the contents of the PC register.
When a task switch occurs (either from one process to another or from one thread to another), the old contents of the PC register are saved (e.g. automatically by the processor hardware onto the stack due to an interupt) and the new contents of the PC register are restored (e.g. autmatically by the processor hardware from the stack due to the "Return From Interrupt" machine instruction).
Of course, when you have multiple CPUs (either on separate chips or as a multi-core on one chip), then you do have as many PC registers as there are CPUs, and you can have as many tasks (processes or threads) running in parallel.

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

For this discussion, just set "thread" == "process".

--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

.



Relevant Pages

  • Re: Cost of calling a standard library function
    ... because, though faster from dropping the stack and using EBP, they ... exact same register we copied from, meaning that we're copying a value ... this stuff makes sense and HLL compilers and HLL ... There's no need to optimise ...
    (alt.lang.asm)
  • Re: push pop ebp
    ... > mov ebp, 9000 ... you may use it there; EBP _is_ a general purpose register ... It also nominally the so-called "base pointer" register to be ... "stack frame"...this behaviour, though, is NOT enforced in any ...
    (alt.lang.asm)
  • Re: Forth and OO design?
    ... cell circular data stack ... return stack index register ... No, that is not design. ... language which became the bastardized basis of Javascript. ...
    (comp.lang.forth)
  • Re: ml64, PROC and parameters
    ... _test_nested creates 98h bytes of stack space for the sake of the exercise. ... You should push on the stack only the non-parameter register. ... The first 4 parameters are in registers rcx, rdx, r8, r9. ... mov,rcx ...
    (microsoft.public.development.device.drivers)
  • Re: ml64, PROC and parameters
    ... It does not use them, but, the stack space could be used for temporary ... You should push on the stack only the non-parameter register. ... The first 4 parameters are in registers rcx, rdx, r8, r9. ... mov,rcx ...
    (microsoft.public.development.device.drivers)