[rtems commit] score: Dismantle _Thread_queue_Do_extract_locked()
Sebastian Huber
sebh at rtems.org
Thu Aug 11 09:33:53 UTC 2016
Module: rtems
Branch: master
Commit: a827447b203f41c8e47d2deab4205a663c08649c
Changeset: http://git.rtems.org/rtems/commit/?id=a827447b203f41c8e47d2deab4205a663c08649c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Aug 11 09:47:21 2016 +0200
score: Dismantle _Thread_queue_Do_extract_locked()
Dismantle _Thread_queue_Do_extract_locked() into re-usable parts like
_Thread_queue_MP_set_callout() and _Thread_queue_Make_ready_again().
Use them in _Thread_queue_Surrender() to propare for a new thread queue
surrender operation.
---
cpukit/score/src/threadqenqueue.c | 67 +++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 28 deletions(-)
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index b70af5d..2f6b041 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -439,32 +439,31 @@ void _Thread_queue_Enqueue_critical(
_Thread_Dispatch_enable( cpu_self );
}
-bool _Thread_queue_Do_extract_locked(
- Thread_queue_Queue *queue,
- const Thread_queue_Operations *operations,
- Thread_Control *the_thread
#if defined(RTEMS_MULTIPROCESSING)
- ,
- const Thread_queue_Context *queue_context
-#endif
+static bool _Thread_queue_MP_set_callout(
+ Thread_Control *the_thread,
+ const Thread_queue_Context *queue_context
)
{
- bool success;
- bool unblock;
+ Thread_Proxy_control *the_proxy;
+ Thread_queue_MP_callout mp_callout;
-#if defined(RTEMS_MULTIPROCESSING)
- if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
- Thread_Proxy_control *the_proxy;
- Thread_queue_MP_callout mp_callout;
-
- the_proxy = (Thread_Proxy_control *) the_thread;
- mp_callout = queue_context->mp_callout;
- _Assert( mp_callout != NULL );
- the_proxy->thread_queue_callout = queue_context->mp_callout;
+ if ( _Objects_Is_local_id( the_thread->Object.id ) ) {
+ return false;
}
+
+ the_proxy = (Thread_Proxy_control *) the_thread;
+ mp_callout = queue_context->mp_callout;
+ _Assert( mp_callout != NULL );
+ the_proxy->thread_queue_callout = queue_context->mp_callout;
+ return true;
+}
#endif
- ( *operations->extract )( queue, the_thread );
+static bool _Thread_queue_Make_ready_again( Thread_Control *the_thread )
+{
+ bool success;
+ bool unblock;
/*
* We must update the wait flags under protection of the current thread lock,
@@ -484,10 +483,26 @@ bool _Thread_queue_Do_extract_locked(
}
_Thread_Wait_restore_default( the_thread );
-
return unblock;
}
+bool _Thread_queue_Do_extract_locked(
+ Thread_queue_Queue *queue,
+ const Thread_queue_Operations *operations,
+ Thread_Control *the_thread
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ const Thread_queue_Context *queue_context
+#endif
+)
+{
+#if defined(RTEMS_MULTIPROCESSING)
+ _Thread_queue_MP_set_callout( the_thread, queue_context );
+#endif
+ ( *operations->extract )( queue, the_thread );
+ return _Thread_queue_Make_ready_again( the_thread );
+}
+
void _Thread_queue_Unblock_critical(
bool unblock,
Thread_queue_Queue *queue,
@@ -555,7 +570,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
queue,
the_thread->Wait.operations,
the_thread,
- &queue_context.Lock_context
+ &queue_context
);
_Thread_queue_Unblock_critical(
unblock,
@@ -585,19 +600,15 @@ void _Thread_queue_Surrender(
queue->owner = new_owner;
#if defined(RTEMS_MULTIPROCESSING)
- if ( _Objects_Is_local_id( new_owner->Object.id ) )
+ if ( !_Thread_queue_MP_set_callout( new_owner, queue_context ) )
#endif
{
++new_owner->resource_count;
_Thread_queue_Boost_priority( queue, new_owner );
}
- unblock = _Thread_queue_Extract_locked(
- queue,
- operations,
- new_owner,
- queue_context
- );
+ ( *operations->extract )( queue, new_owner );
+ unblock = _Thread_queue_Make_ready_again( new_owner );
_Thread_queue_Unblock_critical(
unblock,
More information about the vc
mailing list