Messages in this thread | | | Date | Sat, 21 Jun 2008 19:02:28 -0700 (PDT) | Subject | Re: Any lightweight way for one thread to force another thread to suspend execution? | From | "Eric Smith" <> |
| |
Bart wrote: > Trying to suspend another thread synchronously is a bad idea because > this can easily trigger deadlocks. E.g. if you suspend a thread while > that thread holds a lock on a mutex, your application will deadlock.
I understand that and am willing to take responsibility for ensuring that my application doesn't get into that situation. Basically I'm trying to port something that ran on a strict priority preemptive kernel (on a single processor) to run on a Linux SMP system, so I need a higher priority thread to completely preempt a lower priority thread, even though the lower priority thread might be running on another processor.
As far as I can tell, pthreads doesn't solve this problem, which is unfortunately, since in other respects pthreads looks like it is mostly suitable for use in porting code from other real-time kernels to Linux.
It appears that some pthreads implementations add a nonstandard pthread_suspend() that can do this. What I'm looking for is a way to efficiently implement pthrad_suspend() on Linux, ideally with a minimum of system calls.
It seems to me that in principle, if the kernel provided a way to do this, it should be able to suspend a thread that wasn't currently executing merely by changing some of that thread's metadata, while suspending a thread that is executing on another processor would be more expensive since it would be necessary to force an interrupt on that processor, etc.
Thanks, Eric
| |