[Xenomai] Posix replacement for rt_task_suspend(), rt_task_resume() and rt_task_delete()

Philippe Gerum rpm at xenomai.org
Mon Oct 2 12:06:30 CEST 2017


On 10/02/2017 03:38 AM, Giulio Moro wrote:
> Hello,
> I am porting a Xenomai 3 application from Alchemy to the Posix API*. Under Alchemy, I was using rt_task_suspend(NULL) to suspend a task and rt_task_resume(&task) to resume the task from a separate thread. What is the best / recommended way of porting this to the Posix API?
> Are there any drop-in replacements? Otherwise, I was thinking of using a condition variable.

That would definitely work, being much safer than using asynchronous
suspend calls (who knows where in the code the target thread is going to
suspend, maybe while it holds a lock?...).

If you really have to suspend other threads than the running one, then
Cobalt defines the special SIGSUSP/SIGRESM signals, which are recognized
by libcobalt's pthread_kill() and kill() implementations. I would not
recommend to use them though, only if you have no other choice and are
willing to risk suspending threads in the middle of nowhere.

> 
> What about rt_task_delete() ? The Xenomai documentation does not list pthread_cancel (though I see it is being used by copperplate in the rt_task_delete() call). Is it ok to use pthread_cancel() on a xenomai task?
> 

Yes, this is the way to terminate POSIX threads with Cobalt as well.

-- 
Philippe.



More information about the Xenomai mailing list