Module: xenomai-forge
Branch: next
Commit: e440da777515f6ec64bbe27890f26d19291a9249
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e440da777515f6ec64bbe27890f26d19291a9249
Author: Philippe Gerum r...@xenomai.org
Date: Thu Mar 27 17:12:04 2014 +0100
cobalt/thread: introduce xnthread_try_grab()
We allow the caller to bypass xnsynch_acquire() for assigning the
ownership of an object to a given thread, by calling
xnthread_try_grab(), provided the object does not share any fastlock
area with userland.
xnthread_try_grab() returns non-zero if the object was successfully
grabbed, zero otherwise (i.e. this object was already owned by another
thread).
---
include/cobalt/kernel/thread.h | 16
1 file changed, 16 insertions(+)
diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 9ec09b1..252fd9a 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -302,6 +302,22 @@ void xnthread_set_sync_window(struct xnthread *thread, int
bits)
thread-u_window-state = thread-state | bits;
}
+static inline int xnthread_try_grab(struct xnthread *thread,
+ struct xnsynch *synch)
+{
+ XENO_BUGON(NUCLEUS, xnsynch_fastlock_p(synch));
+
+ if (xnsynch_owner(synch) != NULL)
+ return 0;
+
+ xnsynch_set_owner(synch, thread);
+
+ if (xnthread_test_state(thread, XNOTHER))
+ xnthread_inc_rescnt(thread);
+
+ return 1;
+}
+
/*
* XXX: Mutual dependency issue with synch.h, we have to define
* xnsynch_release() here.
___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git