Return status code for _Thread_Start()

This avoids having conditional statements to get the API-specific status
code.
This commit is contained in:
Sebastian Huber
2021-04-26 13:36:46 +02:00
parent 9d82150f5a
commit bbc93c119c
4 changed files with 12 additions and 13 deletions

View File

@@ -260,12 +260,11 @@ void _Thread_Free(
* @param[in, out] is the ISR lock context which shall be used to disable the
* local interrupts before the call of this routine.
*
* @retval true The thread was in the dormant state and was sucessefully
* started.
* @retval STATUS_SUCCESSFUL The thread start was successful.
*
* @retval false Otherwise.
* @retval STATUS_INCORRECT_STATE The thread was already started.
*/
bool _Thread_Start(
Status_Control _Thread_Start(
Thread_Control *the_thread,
const Thread_Entry_information *entry,
ISR_lock_Context *lock_context

View File

@@ -74,7 +74,6 @@ int pthread_create(
bool valid;
Thread_Configuration config;
Status_Control status;
bool ok;
Thread_Control *the_thread;
Thread_Control *executing;
int schedpolicy = SCHED_RR;
@@ -289,7 +288,7 @@ int pthread_create(
* POSIX threads are allocated and started in one operation.
*/
_ISR_lock_ISR_disable( &lock_context );
ok = _Thread_Start( the_thread, &entry, &lock_context );
status = _Thread_Start( the_thread, &entry, &lock_context );
#if defined(RTEMS_DEBUG)
/*
@@ -298,7 +297,7 @@ int pthread_create(
* NOTE: This can only happen if someone slips in and touches the
* thread while we are creating it.
*/
if ( !ok ) {
if ( status != STATUS_SUCCESSFUL ) {
_Thread_Free( &_POSIX_Threads_Information, the_thread );
_Objects_Allocator_unlock();
return EINVAL;

View File

@@ -21,6 +21,7 @@
#endif
#include <rtems/rtems/tasks.h>
#include <rtems/rtems/statusimpl.h>
#include <rtems/score/threadimpl.h>
rtems_status_code rtems_task_start(
@@ -40,7 +41,7 @@ rtems_status_code rtems_task_start(
};
Thread_Control *the_thread;
ISR_lock_Context lock_context;
bool ok;
Status_Control status;
the_thread = _Thread_Get( id, &lock_context );
@@ -54,7 +55,7 @@ rtems_status_code rtems_task_start(
return RTEMS_INVALID_ID;
}
ok = _Thread_Start( the_thread, &entry, &lock_context );
status = _Thread_Start( the_thread, &entry, &lock_context );
return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
return _Status_Get( status );
}

View File

@@ -24,7 +24,7 @@
#include <rtems/score/isrlevel.h>
#include <rtems/score/userextimpl.h>
bool _Thread_Start(
Status_Control _Thread_Start(
Thread_Control *the_thread,
const Thread_Entry_information *entry,
ISR_lock_Context *lock_context
@@ -36,7 +36,7 @@ bool _Thread_Start(
if ( !_States_Is_dormant( the_thread->current_state ) ) {
_Thread_State_release( the_thread, lock_context );
return false;
return STATUS_INCORRECT_STATE;
}
the_thread->Start.Entry = *entry;
@@ -49,5 +49,5 @@ bool _Thread_Start(
_User_extensions_Thread_start( the_thread );
_Thread_Dispatch_enable( cpu_self );
return true;
return STATUS_SUCCESSFUL;
}