diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-05-17 14:46:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-05-26 13:40:24 +0200 |
commit | 3cef3198a560d2c9e16afb81f97e05bdc6f13a01 (patch) | |
tree | 767704c9062af074884eba3907bcaf0709712aec /cpukit/posix | |
parent | rtems: Return RTEMS_CALLED_FROM_ISR (diff) | |
download | rtems-3cef3198a560d2c9e16afb81f97e05bdc6f13a01.tar.bz2 |
score: Simplify calling _Thread_Exit()
Move common code into _Thread_Exit(). This enables a tail call
optimization in most cases.
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/src/cancel.c | 12 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadexit.c | 11 |
2 files changed, 7 insertions, 16 deletions
diff --git a/cpukit/posix/src/cancel.c b/cpukit/posix/src/cancel.c index 4756f10389..f2636e6a97 100644 --- a/cpukit/posix/src/cancel.c +++ b/cpukit/posix/src/cancel.c @@ -52,17 +52,17 @@ int pthread_cancel( pthread_t thread ) return ESRCH; } - cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); - _ISR_lock_ISR_enable( &lock_context ); - + cpu_self = _Per_CPU_Get(); executing = _Per_CPU_Get_executing( cpu_self ); if ( the_thread == executing ) { - _Thread_Exit( executing, THREAD_LIFE_TERMINATING, PTHREAD_CANCELED ); + _ISR_lock_ISR_enable( &lock_context ); + _Thread_Exit( PTHREAD_CANCELED, THREAD_LIFE_TERMINATING ); } else { + _Thread_Dispatch_disable_with_CPU( cpu_self, &lock_context ); + _ISR_lock_ISR_enable( &lock_context ); _Thread_Cancel( the_thread, executing, PTHREAD_CANCELED ); + _Thread_Dispatch_enable( cpu_self ); } - - _Thread_Dispatch_enable( cpu_self ); return 0; } diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c index 657497010b..d5b53bb45f 100644 --- a/cpukit/posix/src/pthreadexit.c +++ b/cpukit/posix/src/pthreadexit.c @@ -27,14 +27,5 @@ void pthread_exit( void *value_ptr ) { - Thread_Control *executing; - Per_CPU_Control *cpu_self; - - cpu_self = _Thread_Dispatch_disable(); - executing = _Per_CPU_Get_executing( cpu_self ); - - _Thread_Exit( executing, THREAD_LIFE_TERMINATING, value_ptr ); - - _Thread_Dispatch_direct_no_return( cpu_self ); - RTEMS_UNREACHABLE(); + _Thread_Exit( value_ptr, THREAD_LIFE_TERMINATING ); } |