All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Getting mutex state/rt <-> non-rt communication
@ 2007-05-16 16:53 Maciek Godek
  2007-05-16 17:13 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Maciek Godek @ 2007-05-16 16:53 UTC (permalink / raw)
  To: xenomai

Hi,
is it obligatory to use the rt_mutex_inquire in order to get the mutex
state, or could I possibly use the field lockcnt from struct RT_MUTEX
directly? (the test should be, as I believe, atomic - so should I
worry?)

The thing is that I'm using mutices for IPC between an rt-task and a
regular linux process. The rt code is critical, but in the
non-realtime code I can pay the cost of low latency polling to find
out if the realtime code has finished. (Perhaps there is a better way
to do it? The code now looks like this:

RT_MUTEX busy;
RT_COND data_ready;
// both are initialized (elsewhere)

void realtime_thread(void *) {
  rt_mutex_acquire(&busy, 0);
  for(;;) {
    rt_cond_wait(&data_ready, &busy, TM_INFINITE);
    // here it does something critical - it actually communicates
    // with an external device over serial port using the famous rtdm
    // serial driver developed and maintained by Jan Kiszka.
  }
}
 ...
// there is only one thread that communicates with the realtime
// thread above - and this code is invoked within it.
rt_cond_signal(&data_ready);
// now the rt-thread does something. I can estimate the upper time limit
// of the one iteration of that task.
usleep(predicted_time);
if(busy.lockcnt) {
  // timeout - this is possible as it depends on the external devices. Of course
  // sooner or later the mutex will be released by the rt thread.
}

is there any wiser way to communicate these threads?)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-05-21 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-16 16:53 [Xenomai-help] Getting mutex state/rt <-> non-rt communication Maciek Godek
2007-05-16 17:13 ` Jan Kiszka
     [not found]   ` <e2ceda030705161103xf625855w3ff98016770ec37@domain.hid>
2007-05-17  9:02     ` Jan Kiszka
2007-05-21 14:38       ` Maciek Godek
2007-05-21 16:58         ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.