score: Add _Thread_Exit()

The goal is to make _Thread_Exit() a no-return function in follow up
patches.

Update #2555.
Update #2626.
This commit is contained in:
Sebastian Huber
2016-05-12 06:12:06 +02:00
parent e753748703
commit b7f5e391c0
4 changed files with 32 additions and 6 deletions

View File

@@ -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 );

View File

@@ -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 );

View File

@@ -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.
*

View File

@@ -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,