[PATCH] RTEMS: Add user-defined name to thread queues

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Dec 20 08:29:01 UTC 2016


Add a user-defined name to the self-contained synchronization objects in
order to make system diagnostics, tracing and debugging more user
friendly.

Signed-off-by: Sebastian Huber <sebastian.huber at embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/lock.h | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/sys/rtems/include/sys/lock.h b/newlib/libc/sys/rtems/include/sys/lock.h
index c0549db..663d672 100644
--- a/newlib/libc/sys/rtems/include/sys/lock.h
+++ b/newlib/libc/sys/rtems/include/sys/lock.h
@@ -46,6 +46,7 @@ struct _Thread_queue_Queue {
 	struct _Ticket_lock_Control _Lock;
 	struct _Thread_queue_Heads *_heads;
 	struct _Thread_Control *_owner;
+	const char *_name;
 };
 
 struct _Mutex_Control {
@@ -72,18 +73,36 @@ struct _Futex_Control {
 
 #define _TICKET_LOCK_INITIALIZER { 0, 0 }
 
-#define _THREAD_QUEUE_INITIALIZER { _TICKET_LOCK_INITIALIZER, 0, 0 }
+#define _THREAD_QUEUE_INITIALIZER { _TICKET_LOCK_INITIALIZER, 0, 0, 0 }
+
+#define _THREAD_QUEUE_NAMED_INITIALIZER(_name) \
+    { _TICKET_LOCK_INITIALIZER, 0, 0, _name }
 
 #define _MUTEX_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
 
+#define _MUTEX_NAMED_INITIALIZER(_name) \
+    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
+
 #define _MUTEX_RECURSIVE_INITIALIZER { _MUTEX_INITIALIZER, 0 }
 
+#define _MUTEX_RECURSIVE_NAMED_INITIALIZER(_name) \
+    { _MUTEX_NAMED_INITIALIZER(_name), 0 }
+
 #define _CONDITION_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
 
+#define _CONDITION_NAMED_INITIALIZER(_name) \
+    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
+
 #define _SEMAPHORE_INITIALIZER(_count) { _THREAD_QUEUE_INITIALIZER, _count }
 
+#define _SEMAPHORE_NAMED_INITIALIZER(_name, _count) \
+    { _THREAD_QUEUE_NAMED_INITIALIZER(_name), _count }
+
 #define _FUTEX_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
 
+#define _FUTEX_NAMED_INITIALIZER(_name) \
+    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
+
 static __inline void
 _Mutex_Initialize(struct _Mutex_Control *_mutex)
 {
-- 
1.8.4.5



More information about the devel mailing list