Waking up a linux thread from a xenomai thread, without mode switch
rpm at xenomai.org
Fri Dec 14 12:07:11 CET 2018
On 12/14/18 11:48 AM, Julien Blanc via Xenomai wrote:
> We’re currently using semaphores and a shared buffer to allow
> communication between a xenomai cobalt thread and a linux regular
> thread (the xddp interface has been tested and does not perform well
> for our use case, which is exchanging a lot a very small messages).
> While this works fine most of the time, we’ve noticed that this incurs
> a mode switch when the xenomai rt-thread calls real_sem_post, and,
> under heavy load, it can results in that specific thread being
> suspended for too long.
Which is expected.
> I couldn’t find in the documentation how to do this properly :
> * waiting on a xenomai semaphore from a linux thread is forbidden
> * posting a linux semaphore from a xenomai thread incurs a mode switch
> I’d like each thread to stay in its mode. I can live with the linux
> thread entering the primary mode for a small amount of time, but not
> the xenomai thread entering the secondary mode.
You could use non-rt Xenomai threads on the linux side with policies
SCHED_FIFO+prio=0 or SCHED_WEAK, allowing the thread to issue blocking
Xenomai syscalls (such as waiting on a Cobalt sema4).
But, since this would incur two mode switches for the caller - one to
switch to primary, then a converse switch to relax when returning from
the blocking syscall - you certainly don't want to use that method in
high-frequency loops, because this would be very costly CPU-wise.
More information about the Xenomai