summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-13 13:49:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-23 08:01:14 +0200
commite709aa8522788a45adc0adf22daac82c574fcae4 (patch)
tree0d98e853cde5065aac1fe4eda5517ac22d8445f9 /cpukit/score/src
parentscore: Introduce Thread_queue_Heads (diff)
downloadrtems-e709aa8522788a45adc0adf22daac82c574fcae4.tar.bz2
score: Move wait flag update to tq extract
This makes it possible to use _Thread_queue_Extract_locked() for barrier operations which extract all threads on the queue in one critical section.
Diffstat (limited to '')
-rw-r--r--cpukit/score/src/coremutexsurrender.c5
-rw-r--r--cpukit/score/src/threadqenqueue.c31
2 files changed, 22 insertions, 14 deletions
diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c
index e3f0d6f2e4..d3f965d55d 100644
--- a/cpukit/score/src/coremutexsurrender.c
+++ b/cpukit/score/src/coremutexsurrender.c
@@ -179,13 +179,15 @@ CORE_mutex_Status _CORE_mutex_Surrender(
* transfer the mutex to that thread.
*/
if ( ( the_thread = _Thread_queue_First_locked( &the_mutex->Wait_queue ) ) ) {
+ bool unblock;
+
/*
* We must extract the thread now since this will restore its default
* thread lock. This is necessary to avoid a deadlock in the
* _Thread_Change_priority() below due to a recursive thread queue lock
* acquire.
*/
- _Thread_queue_Extract_locked(
+ unblock = _Thread_queue_Extract_locked(
&the_mutex->Wait_queue.Queue,
the_mutex->Wait_queue.operations,
the_thread
@@ -220,6 +222,7 @@ CORE_mutex_Status _CORE_mutex_Surrender(
}
_Thread_queue_Unblock_critical(
+ unblock,
&the_mutex->Wait_queue.Queue,
the_thread,
lock_context
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 5ed01b7a95..1d1581a2fb 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -100,27 +100,20 @@ void _Thread_queue_Enqueue_critical(
_Thread_Dispatch_enable( cpu_self );
}
-void _Thread_queue_Extract_locked(
+bool _Thread_queue_Extract_locked(
Thread_queue_Queue *queue,
const Thread_queue_Operations *operations,
Thread_Control *the_thread
)
{
+ bool success;
+ bool unblock;
+
( *operations->extract )( queue, the_thread );
_Thread_Wait_set_queue( the_thread, NULL );
_Thread_Wait_restore_default_operations( the_thread );
_Thread_Lock_restore_default( the_thread );
-}
-
-void _Thread_queue_Unblock_critical(
- Thread_queue_Queue *queue,
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
-)
-{
- bool success;
- bool unblock;
success = _Thread_Wait_flags_try_change_critical(
the_thread,
@@ -135,6 +128,16 @@ void _Thread_queue_Unblock_critical(
unblock = true;
}
+ return unblock;
+}
+
+void _Thread_queue_Unblock_critical(
+ bool unblock,
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+ ISR_lock_Context *lock_context
+)
+{
if ( unblock ) {
Per_CPU_Control *cpu_self;
@@ -156,8 +159,10 @@ void _Thread_queue_Extract_critical(
ISR_lock_Context *lock_context
)
{
- _Thread_queue_Extract_locked( queue, operations, the_thread );
- _Thread_queue_Unblock_critical( queue, the_thread, lock_context );
+ bool unblock;
+
+ unblock = _Thread_queue_Extract_locked( queue, operations, the_thread );
+ _Thread_queue_Unblock_critical( unblock, queue, the_thread, lock_context );
}
void _Thread_queue_Extract( Thread_Control *the_thread )