pastebin - collaborative debugging tool
rovema.kpaste.net RSS


igb_avb: 0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch
Posted by Anonymous on Thu 14th Dec 2023 15:29
raw | new post

  1. From e8ca16ec8ac0259c7d60bdb4a181995b7a5f3d61 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 12 Oct 2023 11:42:20 +0200
  4. Subject: [PATCH] libigb: Use PTHREAD_PRIO_INHERIT for mutex to avoid realtime
  5.  issues
  6.  
  7. libigb: Use the |PTHREAD_PRIO_INHERIT| thread priority inheritence
  8. protocol for the POSIX mutex to avoid realtime issues where one
  9. lower-priority thread can stall a higher-priority RT thread.
  10.  
  11. Seen in real-life with our SERCOS software.
  12.  
  13. Reviewed-by: Siegfried Wulsch <siegfried.wulsch@rovema.de>
  14. Signed-off-by: Marvin Wenzel <marvin.wenzel@rovema.de>
  15. ---
  16. lib/igb.c | 8 ++++++++
  17.  1 file changed, 8 insertions(+)
  18.  
  19. diff --git a/lib/igb.c b/lib/igb.c
  20. index 00a3560..647234f 100644
  21. --- a/lib/igb.c
  22. +++ b/lib/igb.c
  23. @@ -2562,6 +2562,14 @@ static int igb_create_lock(struct adapter *adapter)
  24.  
  25.                 attr_allocated = true;
  26.  
  27. +#if ((_POSIX_THREAD_ROBUST_PRIO_INHERIT-0) < 200809L)
  28. +/* Protect against libc implementations which do not support this */
  29. +#error Priority inheritence not supported for robust mutexes with this pthread implementation
  30. +#endif
  31. +               // realtime applications usually require priority inheritence
  32. +               if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT) != 0)
  33. +                       goto err;
  34. +
  35.                 // to be used for both inter-process and inter-thread synchronization
  36.                 if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED) != 0)
  37.                         goto err;
  38. --
  39. 2.30.2

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at