[PATCH 03/26] posix: Simplify cleanup push/pop

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Nov 15 13:51:35 UTC 2016


The POSIX cleanup list must be proteced from asynchronous thread
deletion.  Here local interrupt disable is sufficient.
---
 cpukit/posix/src/cleanuppush.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/cpukit/posix/src/cleanuppush.c b/cpukit/posix/src/cleanuppush.c
index 0e55458..d3d7c8f 100644
--- a/cpukit/posix/src/cleanuppush.c
+++ b/cpukit/posix/src/cleanuppush.c
@@ -31,8 +31,8 @@ void _pthread_cleanup_push(
   void                              *arg
 )
 {
-  Per_CPU_Control *cpu_self;
-  Thread_Control  *executing;
+  ISR_Level       level;
+  Thread_Control *executing;
 
   context->_routine = routine;
   context->_arg = arg;
@@ -40,13 +40,13 @@ void _pthread_cleanup_push(
   /* This value is unused, just provide a deterministic value */
   context->_canceltype = -1;
 
-  cpu_self = _Thread_Dispatch_disable();
+  _ISR_Local_disable( level );
 
-  executing = _Per_CPU_Get_executing( cpu_self );
+  executing = _Thread_Executing;
   context->_previous = executing->last_cleanup_context;
   executing->last_cleanup_context = context;
 
-  _Thread_Dispatch_enable( cpu_self );
+  _ISR_Local_enable( level );
 }
 
 void _pthread_cleanup_pop(
@@ -54,19 +54,19 @@ void _pthread_cleanup_pop(
   int                              execute
 )
 {
-  Per_CPU_Control *cpu_self;
-  Thread_Control  *executing;
+  ISR_Level       level;
+  Thread_Control *executing;
 
   if ( execute != 0 ) {
     ( *context->_routine )( context->_arg );
   }
 
-  cpu_self = _Thread_Dispatch_disable();
+  _ISR_Local_disable( level );
 
-  executing = _Per_CPU_Get_executing( cpu_self );
+  executing = _Thread_Executing;
   executing->last_cleanup_context = context->_previous;
 
-  _Thread_Dispatch_enable( cpu_self );
+  _ISR_Local_enable( level );
 }
 
 static void _POSIX_Cleanup_terminate_extension( Thread_Control *the_thread )
-- 
1.8.4.5




More information about the devel mailing list