Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 6 Feb 2016 21:20:49 -0800
From: Justin Cormack <>
Subject: Re: setcontext/getcontext/makecontext missing?

On 5 Feb 2016 1:59 am, <> wrote:
> On Thu, Feb 04, 2016 at 02:24:03PM -0500, Rich Felker wrote:
> > > Pthreads feels like an overkill, hardly efficient when all one needs
> > > is cooperative threading designed from the beginning to fit in one
> > > process.
> > the comparison is not between pure-userspace switching and having the
> > kernel involved, but between a SYS_rt_sigprocmask syscall and a
> > voluntary context switch between threads in the same process. The
> > latter is extremely light and comparable to some of the cheapest
> > syscalls, so I suspect the performance difference between ucontext and
> > threads is negligible.
> Thanks for pointing this out, if rt_sigprocmask can not be skipped
> then indeed a switch becomes much more expensive.

Many users of this interface do not actually require this. Actually NetBSD
makes the context functions syscalls themselves. And OpenBSD does not
provide them at all.

I have taken to just including implementations (without the signal calls)
in code that needs to use them, with modifications to fix the prototype
issues as most code only needs to pass a single argument. At one point I
was going to do implementations for Musl but I think it is a bad idea.

> > Given that there are a lot of other good
> > reasons you should be using threads instead of ucontext, I think the
> > matter is pretty clear.
> Sure, the API was not exactly well thought-out.
> Still I'd like to have a lighweight choice when it is enough.
> This is of course offtopic for musl, given that there is no reasonable
> standard/specification for the purpose.
> Regards,
> Rune

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.