summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/threadqimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-06-26 12:54:33 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-30 09:11:13 +0200
commit0e3c59d65c3d1d3351103abf743aa9702452343c (patch)
tree39b7187c20bad43b43f0999d55c957d29c0b8adc /cpukit/score/include/rtems/score/threadqimpl.h
parentscore: Add potpourri lock statistics (diff)
downloadrtems-0e3c59d65c3d1d3351103abf743aa9702452343c.tar.bz2
score: Use a plain ticket lock for thread locks
This enables external libraries to use thread locks since they are independent of the actual RTEMS build configuration, e.g. profiling enabled or disabled.
Diffstat (limited to 'cpukit/score/include/rtems/score/threadqimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/threadqimpl.h73
1 files changed, 64 insertions, 9 deletions
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index cf3aeed053..22118aba61 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -38,23 +38,53 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
)
{
queue->heads = NULL;
- _ISR_lock_Initialize( &queue->Lock, "Thread Queue" );
+#if defined(RTEMS_SMP)
+ _SMP_ticket_lock_Initialize( &queue->Lock );
+#endif
}
-RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_acquire_critical(
+RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(
Thread_queue_Queue *queue,
+#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
+ SMP_lock_Stats *lock_stats,
+#endif
ISR_lock_Context *lock_context
)
{
- _ISR_lock_Acquire( &queue->Lock, lock_context );
+#if defined(RTEMS_SMP)
+ _SMP_ticket_lock_Acquire(
+ &queue->Lock,
+ lock_stats,
+ &lock_context->Lock_context.Stats_context
+ );
+#else
+ (void) queue;
+ (void) lock_context;
+#endif
}
+#if defined(RTEMS_SMP) && defined( RTEMS_PROFILING )
+ #define \
+ _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
+ _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context )
+#else
+ #define \
+ _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
+ _Thread_queue_Queue_do_acquire_critical( queue, lock_context )
+#endif
+
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
Thread_queue_Queue *queue,
ISR_lock_Context *lock_context
)
{
- _ISR_lock_Release_and_ISR_enable( &queue->Lock, lock_context );
+#if defined(RTEMS_SMP)
+ _SMP_ticket_lock_Release(
+ &queue->Lock,
+ &lock_context->Lock_context.Stats_context
+ );
+#endif
+ _ISR_lock_ISR_enable( lock_context );
}
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
@@ -64,6 +94,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
{
_Thread_queue_Queue_acquire_critical(
&the_thread_queue->Queue,
+ &the_thread_queue->Lock_stats,
lock_context
);
}
@@ -82,7 +113,10 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
ISR_lock_Context *lock_context
)
{
- _Thread_queue_Queue_release( &the_thread_queue->Queue, lock_context );
+ _Thread_queue_Queue_release(
+ &the_thread_queue->Queue,
+ lock_context
+ );
}
/**
@@ -397,11 +431,29 @@ void _Thread_queue_Initialize(
Thread_queue_Disciplines the_discipline
);
-#if defined(RTEMS_SMP)
+#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
+ #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
+ .Queue = { \
+ .heads = NULL, \
+ .Lock = SMP_TICKET_LOCK_INITIALIZER, \
+ }, \
+ .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \
+ .operations = &_Thread_queue_Operations_FIFO \
+ }
+
+ #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
+ .Queue = { \
+ .heads = NULL, \
+ .Lock = SMP_TICKET_LOCK_INITIALIZER, \
+ }, \
+ .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \
+ .operations = &_Thread_queue_Operations_priority \
+ }
+#elif defined(RTEMS_SMP)
#define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
.Queue = { \
.heads = NULL, \
- .Lock = ISR_LOCK_INITIALIZER( name ), \
+ .Lock = SMP_TICKET_LOCK_INITIALIZER, \
}, \
.operations = &_Thread_queue_Operations_FIFO \
}
@@ -409,7 +461,7 @@ void _Thread_queue_Initialize(
#define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
.Queue = { \
.heads = NULL, \
- .Lock = ISR_LOCK_INITIALIZER( name ), \
+ .Lock = SMP_TICKET_LOCK_INITIALIZER, \
}, \
.operations = &_Thread_queue_Operations_priority \
}
@@ -429,7 +481,10 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
Thread_queue_Control *the_thread_queue
)
{
- _ISR_lock_Destroy( &the_thread_queue->Queue.Lock );
+#if defined(RTEMS_SMP)
+ _SMP_ticket_lock_Destroy( &the_thread_queue->Queue.Lock );
+ _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats );
+#endif
}
/**