From 125f248231c173a038ed9fc00832e0b3d221ad43 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 16 Nov 2016 16:39:43 +0100 Subject: 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. --- cpukit/score/src/threadrestart.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'cpukit/score/src/threadrestart.c') 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( -- cgit v1.2.3