[rtems commit] rtems: Return RTEMS_CALLED_FROM_ISR
Sebastian Huber
sebh at rtems.org
Wed May 26 12:41:09 UTC 2021
Module: rtems
Branch: master
Commit: b81d1ffd236574dcb9fca539c1efb631165877ea
Changeset: http://git.rtems.org/rtems/commit/?id=b81d1ffd236574dcb9fca539c1efb631165877ea
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri May 14 18:53:55 2021 +0200
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.
---
cpukit/rtems/src/taskdelete.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index 852cf3b..0a8d59a 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 );
}
More information about the vc
mailing list