summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-27 13:19:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-30 09:11:17 +0200
commit12f93fbb13d37e6cc16149c4bbac1590e9b29a29 (patch)
treefd8e02672dfe5c4a5aeceadfb11d029bc3db94d0
parentscore: Use a plain ticket lock for thread locks (diff)
downloadrtems-12f93fbb13d37e6cc16149c4bbac1590e9b29a29.tar.bz2
score: Add thread queue for self-contained objects
-rw-r--r--cpukit/configure.ac1
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h18
-rw-r--r--cpukit/score/src/threadq.c36
3 files changed, 55 insertions, 0 deletions
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index c2b8e8d4f2..14ce0f1a4c 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -71,6 +71,7 @@ AC_CHECK_DECLS([ftrylockfile],[AC_CHECK_FUNCS([ftrylockfile])],,[#include <stdio
AC_CHECK_HEADERS([envlock.h])
AC_CHECK_DECLS([__env_lock],,,[#include <envlock.h>])
AC_CHECK_DECLS([__env_unlock],,,[#include <envlock.h>])
+AC_CHECK_TYPES([struct _Thread_queue_Queue],[],[],[#include <sys/lock.h>])
# Mandated by POSIX, older newlibs bogusly provided CLOCK_PROCESS_CPUTIME+CLOCK_THREAD_CPUTIME
AC_CHECK_DECL([CLOCK_PROCESS_CPUTIME_ID],[],[AC_MSG_ERROR([missing define CLOCK_PROCESS_CPUTIME_ID])],[#include <time.h>])
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 22118aba61..3828f415a6 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -33,6 +33,24 @@ extern "C" {
*/
/**@{*/
+/**
+ * @brief Thread queue with a layout compatible to struct _Thread_queue_Queue
+ * defined in Newlib <sys/lock.h>.
+ */
+typedef struct {
+ Thread_queue_Queue Queue;
+
+#if !defined(RTEMS_SMP)
+ /*
+ * The struct _Thread_queue_Queue definition is independent of the RTEMS
+ * build configuration. Thus, the storage space for the SMP lock is always
+ * present. In SMP configurations, the SMP lock is contained in the
+ * Thread_queue_Queue.
+ */
+ unsigned int reserved[2];
+#endif
+} Thread_queue_Syslock_queue;
+
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
Thread_queue_Queue *queue
)
diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c
index fc81409924..372a07d64c 100644
--- a/cpukit/score/src/threadq.c
+++ b/cpukit/score/src/threadq.c
@@ -22,6 +22,42 @@
#include <rtems/score/rbtreeimpl.h>
#include <rtems/score/threadimpl.h>
+#if HAVE_STRUCT__THREAD_QUEUE_QUEUE
+
+RTEMS_STATIC_ASSERT(
+ offsetof( Thread_queue_Syslock_queue, Queue.heads )
+ == offsetof( struct _Thread_queue_Queue, _heads ),
+ THREAD_QUEUE_SYSLOCK_QUEUE_HEADS
+);
+
+RTEMS_STATIC_ASSERT(
+#if defined(RTEMS_SMP)
+ offsetof( Thread_queue_Syslock_queue, Queue.Lock.next_ticket )
+#else
+ offsetof( Thread_queue_Syslock_queue, reserved[ 0 ] )
+#endif
+ == offsetof( struct _Thread_queue_Queue, _Lock._next_ticket ),
+ THREAD_QUEUE_SYSLOCK_QUEUE_NEXT_TICKET
+);
+
+RTEMS_STATIC_ASSERT(
+#if defined(RTEMS_SMP)
+ offsetof( Thread_queue_Syslock_queue, Queue.Lock.now_serving )
+#else
+ offsetof( Thread_queue_Syslock_queue, reserved[ 1 ] )
+#endif
+ == offsetof( struct _Thread_queue_Queue, _Lock._now_serving ),
+ THREAD_QUEUE_SYSLOCK_QUEUE_NOW_SERVING
+);
+
+RTEMS_STATIC_ASSERT(
+ sizeof( Thread_queue_Syslock_queue )
+ == sizeof( struct _Thread_queue_Queue ),
+ THREAD_QUEUE_SYSLOCK_QUEUE_SIZE
+);
+
+#endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */
+
RBTree_Compare_result _Thread_queue_Compare_priority(
const RBTree_Node *left,
const RBTree_Node *right