summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadrestart.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-16 16:39:43 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-23 12:52:06 +0100
commit125f248231c173a038ed9fc00832e0b3d221ad43 (patch)
tree3894553badc7582b0c460aec4d34955f23ea3e81 /cpukit/score/src/threadrestart.c
parentscore: Robust thread dispatch (diff)
downloadrtems-125f248231c173a038ed9fc00832e0b3d221ad43.tar.bz2
score: Add thread queue enqueue callout
Replace the expected thread dispatch disable level with a thread queue enqueue callout. This enables the use of _Thread_Dispatch_direct() in the thread queue enqueue procedure. This avoids impossible exection paths, e.g. Per_CPU_Control::dispatch_necessary is always true.
Diffstat (limited to 'cpukit/score/src/threadrestart.c')
-rw-r--r--cpukit/score/src/threadrestart.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index a5ed837dfd..46c8e4d979 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -514,21 +514,40 @@ void _Thread_Cancel(
_Thread_Dispatch_enable( cpu_self );
}
-void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
+static void _Thread_Close_enqueue_callout(
+ Thread_queue_Queue *queue,
+ Thread_Control *the_thread,
+ Thread_queue_Context *queue_context
+)
{
- Thread_queue_Context queue_context;
+ Thread_Close_context *context;
+
+ context = (Thread_Close_context *) queue_context;
+ _Thread_Cancel( context->cancel, the_thread, NULL );
+}
- _Thread_queue_Context_initialize( &queue_context );
- _Thread_queue_Context_set_expected_level( &queue_context, 2 );
- _Thread_queue_Context_set_no_timeout( &queue_context );
- _Thread_State_acquire( the_thread, &queue_context.Lock_context.Lock_context );
+void _Thread_Close(
+ Thread_Control *the_thread,
+ Thread_Control *executing,
+ Thread_Close_context *context
+)
+{
+ context->cancel = the_thread;
+ _Thread_queue_Context_set_enqueue_callout(
+ &context->Base,
+ _Thread_Close_enqueue_callout
+ );
+ _Thread_queue_Context_set_no_timeout( &context->Base );
+ _Thread_State_acquire_critical(
+ the_thread,
+ &context->Base.Lock_context.Lock_context
+ );
_Thread_Join(
the_thread,
STATES_WAITING_FOR_JOIN,
executing,
- &queue_context
+ &context->Base
);
- _Thread_Cancel( the_thread, executing, NULL );
}
void _Thread_Exit(