summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/cancel.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-17 14:46:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-26 13:40:24 +0200
commit3cef3198a560d2c9e16afb81f97e05bdc6f13a01 (patch)
tree767704c9062af074884eba3907bcaf0709712aec /cpukit/posix/src/cancel.c
parentrtems: Return RTEMS_CALLED_FROM_ISR (diff)
downloadrtems-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 '')
-rw-r--r--cpukit/posix/src/cancel.c12
1 files changed, 6 insertions, 6 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;
}