Module: xenomai-forge
Branch: next
Commit: 234d6b0505525499040eca97dad55c5addb510ca
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=234d6b0505525499040eca97dad55c5addb510ca

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct  2 16:19:29 2013 +0200

cobalt/posix/thread: introduce PTHREAD_DISABLE_LOCKBREAK for disabling lock 
breaking

This new mode bit is available with the pthread_set_mode_np() interface.

---

 include/cobalt/uapi/thread.h |    7 ++++---
 kernel/cobalt/posix/thread.c |   11 ++++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/cobalt/uapi/thread.h b/include/cobalt/uapi/thread.h
index 54977cb..ab4bce3 100644
--- a/include/cobalt/uapi/thread.h
+++ b/include/cobalt/uapi/thread.h
@@ -20,9 +20,10 @@
 
 #include <cobalt/uapi/kernel/thread.h>
 
-#define PTHREAD_WARNSW      XNTRAPSW
-#define PTHREAD_LOCK_SCHED  XNLOCK
-#define PTHREAD_CONFORMING  0
+#define PTHREAD_WARNSW             XNTRAPSW
+#define PTHREAD_LOCK_SCHED         XNLOCK
+#define PTHREAD_DISABLE_LOCKBREAK  XNTRAPLB
+#define PTHREAD_CONFORMING     0
 
 struct cobalt_mutexattr {
        unsigned int magic: 24;
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index c638d5d..7ba91fc 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -586,9 +586,14 @@ static inline int pthread_make_periodic_np(struct 
cobalt_thread *thread,
  * current user-space task to its preferred runtime mode. The only
  * meaningful use of this switch is to force a real-time shadow back
  * to primary mode. Any other use leads to a nop.
+ * - PTHREAD_DISABLE_LOCKBREAK disallows breaking the scheduler
+ * lock. In the default case, a thread which holds the scheduler lock
+ * is allowed to drop it temporarily for sleeping. If this mode bit is set,
+ * such thread would return with EINTR immediately from any blocking call.
  *
- * PTHREAD_LOCK_SCHED is valid for any Xenomai thread, the other bits are only
- * valid for Xenomai user-space threads.
+ * PTHREAD_LOCK_SCHED and PTHREAD_DISABLE_LOCKBREAK are valid for any
+ * Xenomai thread, other bits are valid for Xenomai user-space threads
+ * only.
  *
  * This service is a non-portable extension of the POSIX interface.
  *
@@ -610,8 +615,8 @@ static inline int pthread_make_periodic_np(struct 
cobalt_thread *thread,
  */
 static inline int pthread_set_mode_np(int clrmask, int setmask, int *mode_r)
 {
+       const int valid_flags = XNLOCK|XNTRAPSW|XNTRAPLB;
        struct xnthread *cur = xnsched_current_thread();
-       const int valid_flags = XNLOCK|XNTRAPSW;
        int old;
 
        /*


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to