Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Multithreading vs. Forks


Andrew Bennetts wrote:

I was under the impression that a different thread *is* a different
context... it has its own stack, its own registers, and probably can
have its own memory address space too.  They're basically like
processes, except they tend to share an awful lot of their memory with
other threads of the same "process".

In this case, I fail to see why it would be significantly faster to
switch between threads than it is to switch between processes.  I should
probably write a program to benchmark this to find out for certain, I
suppose.

Threads do not have to reload the total program vtable, each copy of the thread runs in the same address space and therefore it does not need to switch address spaces, it is entirely possible that different programs will generate more page faults due to duplicated memory structures that are not really required, for example those startup parameters.

KenF