[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]


> > Does this mean that getcontext/setcontext continue to work? FreeBSD recently
> > killed these 'for now' in their threading efforts which scares me as I
> > depend on them.
> These functions provide you enough rope to shoot yourself in the foot.
> In principal there are no problems (within the documented limitations of
> the implementation of these functions).

The getcontext/setcontext can be implemented using straight pthread api.
The basic steps are:

1) send a signal to target thread.
2) target thread receives signal
3) target publisize its signal ucontext to global/thread variable
3) target thread blocks on sigwait/sigsuspend until it is let go

In practice, the above approach can be VERY FAST, since get/set is just
reading/writing a user-level structures. The step 1 and 4 are plain
thread suspend/resume, whose performance is limited by pthread_kill.

Summary: getcontext/setcontext is FREE gift from thread suspend/resume.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]