Restartable sequences
Restartable sequences
Posted Jul 17, 2015 5:42 UTC (Fri) by alkbyby (subscriber, #61687)Parent article: Restartable sequences
Process can register a signal (and glibc could automatically register one and "steal" it from userspace similarly to what they're already doing for some pthread stuff).
So kernel would raise this signal to a thread before returning to user-space every time either:
a) this thread was previously running on different CPU
b) this thread gets CPU _back_ after some other thread run on this CPU
Then libc could implement restartable_seq by simply looking at PC in siginfo's ucontext. Quick "current cpu number" cache and perhaps a range of other things could be implemented just as easily with this signal.
This signal does not need to be queue-able. And could be block-able as normal. Seems much cleaner and more generic thing to me.
I know, people in general have bad attitude towards signals, but in this case it looks like better option that glibc can abstract further. Of course unless I'm missing something crucial.