From 29187be532c7d6c7b81f2e7def132bbfba7c916c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 17 May 2021 14:51:45 +0200 Subject: posix: Allow pthread_cancel() from within ISRs Close #4413. --- cpukit/posix/src/cancel.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/cancel.c b/cpukit/posix/src/cancel.c index f2636e6a97..aa4a434037 100644 --- a/cpukit/posix/src/cancel.c +++ b/cpukit/posix/src/cancel.c @@ -38,14 +38,6 @@ int pthread_cancel( pthread_t thread ) Thread_Control *executing; Per_CPU_Control *cpu_self; - /* - * Don't even think about deleting a resource from an ISR. - */ - - if ( _ISR_Is_in_progress() ) { - return EPROTO; - } - the_thread = _Thread_Get( thread, &lock_context ); if ( the_thread == NULL ) { @@ -55,7 +47,10 @@ int pthread_cancel( pthread_t thread ) cpu_self = _Per_CPU_Get(); executing = _Per_CPU_Get_executing( cpu_self ); - if ( the_thread == executing ) { + if ( + the_thread == executing && + !_Per_CPU_Is_ISR_in_progress( cpu_self ) + ) { _ISR_lock_ISR_enable( &lock_context ); _Thread_Exit( PTHREAD_CANCELED, THREAD_LIFE_TERMINATING ); } else { -- cgit v1.2.3