diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 06:12:06 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 07:49:36 +0200 |
commit | b7f5e391c0c0e94e5958a294e5d38b1dda7332cc (patch) | |
tree | 6d48062b02d6ce9ba56b188be6e6ed1840a19a34 /cpukit | |
parent | score: Delete redundant thread life enums (diff) | |
download | rtems-b7f5e391c0c0e94e5958a294e5d38b1dda7332cc.tar.bz2 |
score: Add _Thread_Exit()
The goal is to make _Thread_Exit() a no-return function in follow up
patches.
Update #2555.
Update #2626.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/posix/src/pthreadexit.c | 9 | ||||
-rw-r--r-- | cpukit/rtems/src/taskdelete.c | 9 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadrestart.c | 18 |
4 files changed, 32 insertions, 6 deletions
diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c index e2ae806654..940fa381c1 100644 --- a/cpukit/posix/src/pthreadexit.c +++ b/cpukit/posix/src/pthreadexit.c @@ -31,6 +31,7 @@ void _POSIX_Thread_Exit( void *value_ptr ) { + Thread_Control *executing; Thread_Control *unblocked; POSIX_API_Control *api; bool previous_life_protection; @@ -61,10 +62,16 @@ void _POSIX_Thread_Exit( } } + executing = _Thread_Executing; + /* * Now shut down the thread */ - _Thread_Close( the_thread, _Thread_Executing ); + if ( the_thread == executing ) { + _Thread_Exit( executing ); + } else { + _Thread_Close( the_thread, executing ); + } _Thread_Enable_dispatch(); _Thread_Set_life_protection( previous_life_protection ); diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c index 7a06c51eac..c0d46d8807 100644 --- a/cpukit/rtems/src/taskdelete.c +++ b/cpukit/rtems/src/taskdelete.c @@ -28,6 +28,7 @@ rtems_status_code rtems_task_delete( ) { Thread_Control *the_thread; + Thread_Control *executing; Objects_Locations location; bool previous_life_protection; @@ -50,7 +51,13 @@ rtems_status_code rtems_task_delete( } #endif - _Thread_Close( the_thread, _Thread_Executing ); + executing = _Thread_Executing; + + if ( the_thread == executing ) { + _Thread_Exit( executing ); + } else { + _Thread_Close( the_thread, executing ); + } _Objects_Put( &the_thread->Object ); _Thread_Set_life_protection( previous_life_protection ); diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 3fdc2e8615..be2095e023 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -211,6 +211,8 @@ bool _Thread_Set_life_protection( bool protect ); */ void _Thread_Kill_zombies( void ); +void _Thread_Exit( Thread_Control *executing ); + /** * @brief Closes the thread. * diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index ca054fab55..0184fd1532 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -341,14 +341,12 @@ 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 ) ) { _Thread_Make_zombie( the_thread ); } else { - if ( - the_thread != executing - && !_Thread_Is_life_terminating( executing->Life.state ) - ) { + if ( !_Thread_Is_life_terminating( executing->Life.state ) ) { /* * Wait for termination of victim thread. If the executing thread is * also terminated, then do not wait. This avoids potential cyclic @@ -367,6 +365,18 @@ 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, + executing->current_priority, + THREAD_LIFE_TERMINATING + ); +} + bool _Thread_Restart( Thread_Control *the_thread, Thread_Control *executing, |