[PATCH 04/32] score: Avoid superfluous life protection

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 18 09:20:23 UTC 2016


Disable thread dispatching is enough to prevent deletion of the
executing thread.  There is no need for an additional life protection.

Update #2555.
Update #2626.
---
 cpukit/posix/src/pthreadexit.c   | 3 ---
 cpukit/rtems/src/taskdelete.c    | 6 ------
 cpukit/score/src/threadrestart.c | 3 ---
 3 files changed, 12 deletions(-)

diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c
index 940fa38..559e37c 100644
--- a/cpukit/posix/src/pthreadexit.c
+++ b/cpukit/posix/src/pthreadexit.c
@@ -34,13 +34,11 @@ void _POSIX_Thread_Exit(
   Thread_Control    *executing;
   Thread_Control    *unblocked;
   POSIX_API_Control *api;
-  bool               previous_life_protection;
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
   _Assert( _Debug_Is_thread_dispatching_allowed() );
 
-  previous_life_protection = _Thread_Set_life_protection( true );
   _Thread_Disable_dispatch();
 
   the_thread->Wait.return_argument = value_ptr;
@@ -74,7 +72,6 @@ void _POSIX_Thread_Exit(
   }
 
   _Thread_Enable_dispatch();
-  _Thread_Set_life_protection( previous_life_protection );
 }
 
 void pthread_exit(
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index c0d46d8..5830793 100644
--- a/cpukit/rtems/src/taskdelete.c
+++ b/cpukit/rtems/src/taskdelete.c
@@ -30,9 +30,7 @@ rtems_status_code rtems_task_delete(
   Thread_Control    *the_thread;
   Thread_Control    *executing;
   Objects_Locations  location;
-  bool               previous_life_protection;
 
-  previous_life_protection = _Thread_Set_life_protection( true );
   the_thread = _Thread_Get( id, &location );
   switch ( location ) {
 
@@ -60,13 +58,11 @@ rtems_status_code rtems_task_delete(
       }
 
       _Objects_Put( &the_thread->Object );
-      _Thread_Set_life_protection( previous_life_protection );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
     case OBJECTS_REMOTE:
       _Thread_Dispatch();
-      _Thread_Set_life_protection( previous_life_protection );
       return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
 #endif
 
@@ -74,7 +70,5 @@ rtems_status_code rtems_task_delete(
       break;
   }
 
-  _Thread_Set_life_protection( previous_life_protection );
-
   return RTEMS_INVALID_ID;
 }
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 0184fd1..272fe7b 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -340,7 +340,6 @@ static void _Thread_Request_life_change(
 
 void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
 {
-  _Assert( _Thread_Is_life_protected( executing->Life.state ) );
   _Assert( the_thread != executing );
 
   if ( _States_Is_dormant( the_thread->current_state ) ) {
@@ -367,8 +366,6 @@ void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
 
 void _Thread_Exit( Thread_Control *executing )
 {
-  _Assert( _Thread_Is_life_protected( executing->Life.state ) );
-
   _Thread_Request_life_change(
     executing,
     executing,
-- 
1.8.4.5




More information about the devel mailing list