summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/taskdelete.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-14 18:53:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-26 13:36:57 +0200
commitb81d1ffd236574dcb9fca539c1efb631165877ea (patch)
tree2c6e7210b9f376887603dc991b39774392b841d7 /cpukit/rtems/src/taskdelete.c
parentsysinit: Do not open console when just referencing reentrancy structure. (diff)
downloadrtems-b81d1ffd236574dcb9fca539c1efb631165877ea.tar.bz2
rtems: Return RTEMS_CALLED_FROM_ISR
If rtems_task_delete() is called from within interrupt context, then return RTEMS_CALLED_FROM_ISR. This makes the behaviour predictable. Update #4414.
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/src/taskdelete.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index 852cf3b4c1..0a8d59a3a8 100644
--- a/cpukit/rtems/src/taskdelete.c
+++ b/cpukit/rtems/src/taskdelete.c
@@ -29,6 +29,7 @@ rtems_status_code rtems_task_delete(
{
Thread_Control *the_thread;
Thread_Close_context context;
+ Per_CPU_Control *cpu_self;
Thread_Control *executing;
_Thread_queue_Context_initialize( &context.Base );
@@ -44,12 +45,20 @@ rtems_status_code rtems_task_delete(
return RTEMS_INVALID_ID;
}
- executing = _Thread_Executing;
+ cpu_self = _Per_CPU_Get();
- if ( the_thread == executing ) {
- Per_CPU_Control *cpu_self;
+ if ( _Per_CPU_Is_ISR_in_progress( cpu_self ) ) {
+ _ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context );
+ return RTEMS_CALLED_FROM_ISR;
+ }
- cpu_self = _Thread_queue_Dispatch_disable( &context.Base );
+ executing = _Per_CPU_Get_executing( cpu_self );
+
+ if ( the_thread == executing ) {
+ _Thread_Dispatch_disable_with_CPU(
+ cpu_self,
+ &context.Base.Lock_context.Lock_context
+ );
_ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context );
/*
@@ -61,7 +70,8 @@ rtems_status_code rtems_task_delete(
THREAD_LIFE_TERMINATING | THREAD_LIFE_DETACHED,
NULL
);
- _Thread_Dispatch_enable( cpu_self );
+ _Thread_Dispatch_direct_no_return( cpu_self );
+ RTEMS_UNREACHABLE();
} else {
_Thread_Close( the_thread, executing, &context );
}