tech-userlevel archive

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

Re: getcontext()/setcontext()/makecontext() reliability?

In article <>,
David Young  <> wrote:
>On Thu, May 03, 2012 at 07:35:41PM -0400, Matthew Mondor wrote:
>> On Thu, 3 May 2012 12:59:45 -0500
>> David Young <> wrote:
>> > Are getcontext()/setcontext()/makecontext() known to work reliably on
>> > NetBSD?  It looks to me like they are used in NetBSD/usermode and in
>> > puffs, and there are tests exercising them, so I hoep that the answer is
>> > "yes!"
>> I can't confirm that it's still the case, but there's a CAVEATS section:
>>      Due to limitations in the current pthread implementation, makecontext
>>      should not be used in programs which link against the pthread(3) library
>>      (whether threads are used or not).
>Right.  It's also deprecated by POSIX in favor of pthread(3).
>I'm looking into getcontext()/setcontext() because I think that its
>overhead may be way less than POSIX threads for an I/O server with
>potentially hundreds or thousands of active sessions.  Not so?
>In NetBSD, switching POSIX threads require, I thought, a user-kernel
>round trip.  I figure that's the costly part.

You realize {g,s}etcontext are system calls too, and they are not like the
old setjmp/longjmp that most of the time were implemented in userland?


Home | Main Index | Thread Index | Old Index