2

I am currently working with a PREEMPT_RT patched Linux system (including librt and libpthread) and it seems that my real-time threads work fairly reliable from a timing point of view. What mechanism would be suitable to prevent race conditions when it comes to access of shared resources? In my situation I would like to share statistical information between a real-time and a non-real-time thread (e. g. a telnet interface).

E. g. using a mutex (''pthread_mutex_lock'' and ''pthread_mutex_unlock'') would IMHO undermine the deterministic nature of my real-time task in case the mutex is locked by a non-real-time task and the real-time task has to wait for it. Are there any alternatives or better approaches?

Claudio
  • 10,614
  • 4
  • 31
  • 71
dubbaluga
  • 2,223
  • 5
  • 29
  • 38
  • I'm not familiar with methods (or libraries) for lockless data transfer, but you should be able to use priority-inheritance locks (although I haven't worked with pthread directly, I expect is has PI locks). Priority inheritance "solves" the problem you mention by boosting the priority of the task holding the lock to the priority of the (highest-priority) task waiting on the lock. As long as the low-priority task doesn't execute high-latency commands while holding the lock, this bounds the effects of latency on the high-priority task. Lockless data transfer is preferable if possible, though. – crosstalk Jul 05 '14 at 06:36

0 Answers0