tech-kern archive

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

Re: swapcontext() around pthreads

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.

I observed an interesting thing: in my test case, pthread_self() reports
that we changed thread, but ktrace shows the same lwp id, therefore
swapcontext() would not preempt anything?

And looking at the code, pthread_self is just a CPU register (gs on
i386, fs on amd64). I suspect I can reach my goal by just not changing
that register on swapccontext. Unfortunately that would be a machine
dependant option.

Emmanuel Dreyfus

Home | Main Index | Thread Index | Old Index