Subj : Re: Pre-empting a user-space thread... To : comp.programming.threads From : lindahlb Date : Mon Jan 31 2005 04:15 pm Scott Stoddard wrote: > Thread newbie question here... > > I want to set up a timer thread and a 'bunch' of other execution > threads. When the timer thread 'comes due' I would like it to preempt > the currently executing one of the 'other' threads. Basically, I need > to roll my own scheduler for a project that I'm working on and this is > my current idea about how to do it. > > I have looked into the pthread library and all the info that I can > find on nptl and can't find out if this is possible (I'm therefore > assuming that it is not). Could anyone tell me if this is > possible...or, if not, what might be another way to go here? > > Thanx, > Scott. If you've created your own user threads (via some unportable method such as setjmp/longjmp), you can use SIGALARM to fire off at pre-emption times and utilize unportable methods to set the return context. I've heard of this being done, but I'm unaware of a good means to change contexts on return from signal handler. Just in case that helps... .