tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: swapcontext() around pthreads

On Fri, Aug 10, 2012 at 05:11:02AM +0200, Emmanuel Dreyfus wrote:
> Joerg Sonnenberger <> wrote:
> > Is there a point? Our swapcontext is effectively a system call. 
> > If it wasn't, it is still quite expensive for a routine that supposedly
> > only changes %rsp followed by a call, at least for architectures that
> > don't use a register window algorithm.
> It does more than that: it has to swap CPU register, signal mask.

Given that they likely want to implement some form of coroutines, that's
exactly the point of what you do *not* want. As soon as it involves
saving all CPU registers and the signal mask, you can just as well do a
full context switch. For coroutines, that is extremely wasteful on most
architectures as only callee-saved registers really have to be preserved
and the signal mask is constant as well. On x86 that excludes e.g. the
SSE and FPU state, which is quite large.


Home | Main Index | Thread Index | Old Index