diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-16 16:39:43 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-23 12:52:06 +0100 |
commit | 125f248231c173a038ed9fc00832e0b3d221ad43 (patch) | |
tree | 3894553badc7582b0c460aec4d34955f23ea3e81 /cpukit/rtems/src/taskdelete.c | |
parent | score: Robust thread dispatch (diff) | |
download | rtems-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/rtems/src/taskdelete.c')
-rw-r--r-- | cpukit/rtems/src/taskdelete.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c index c3ddc77d0a..de57fb3ec0 100644 --- a/cpukit/rtems/src/taskdelete.c +++ b/cpukit/rtems/src/taskdelete.c @@ -25,12 +25,12 @@ rtems_status_code rtems_task_delete( rtems_id id ) { - Thread_Control *the_thread; - ISR_lock_Context lock_context; - Thread_Control *executing; - Per_CPU_Control *cpu_self; + Thread_Control *the_thread; + Thread_Close_context context; + Thread_Control *executing; - the_thread = _Thread_Get( id, &lock_context ); + _Thread_queue_Context_initialize( &context.Base ); + the_thread = _Thread_Get( id, &context.Base.Lock_context.Lock_context ); if ( the_thread == NULL ) { #if defined(RTEMS_MULTIPROCESSING) @@ -42,12 +42,16 @@ rtems_status_code rtems_task_delete( return RTEMS_INVALID_ID; } - cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); - _ISR_lock_ISR_enable( &lock_context ); - - executing = _Per_CPU_Get_executing( cpu_self ); + executing = _Thread_Executing; if ( the_thread == executing ) { + Per_CPU_Control *cpu_self; + + cpu_self = _Thread_Dispatch_disable_critical( + &context.Base.Lock_context.Lock_context + ); + _ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context ); + /* * The Classic tasks are neither detached nor joinable. In case of * self deletion, they are detached, otherwise joinable by default. @@ -57,10 +61,10 @@ rtems_status_code rtems_task_delete( THREAD_LIFE_TERMINATING | THREAD_LIFE_DETACHED, NULL ); + _Thread_Dispatch_enable( cpu_self ); } else { - _Thread_Close( the_thread, executing ); + _Thread_Close( the_thread, executing, &context ); } - _Thread_Dispatch_enable( cpu_self ); return RTEMS_SUCCESSFUL; } |