This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

swapcontext() slow


Hello.

I am implementing the user-space cooperative
threading with swapcontext(), but it is quite slow
because swapcontext() calls sigprocmask().

Firstly, I'd like to know the reason of this.
Is this so that (1) every coroutine can have its separate
signal mask, or is it to (2) allow switching in/out of a
signal handler?

I can think of the possible work-arounds, depending on an
answer to the above question.
If (1) is true, then perhaps the "light" version of
swapcontext()/setcontext() can be added that do not call
sigprocmask(). If (2) is true, then perhaps the vDSO can
be introduced to get the current signal mask. Then glibc
could compare the old and new masks and not call sigprocmask()
when not needed.

Would some optimization be possible?
It would be very good to have the user-space threads
lightweight, not calling to the kernel at all when possible.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]