forked from Imagelibrary/rtems
Return status code for _Thread_Start()
This avoids having conditional statements to get the API-specific status code.
This commit is contained in:
@@ -260,12 +260,11 @@ void _Thread_Free(
|
|||||||
* @param[in, out] is the ISR lock context which shall be used to disable the
|
* @param[in, out] is the ISR lock context which shall be used to disable the
|
||||||
* local interrupts before the call of this routine.
|
* local interrupts before the call of this routine.
|
||||||
*
|
*
|
||||||
* @retval true The thread was in the dormant state and was sucessefully
|
* @retval STATUS_SUCCESSFUL The thread start was successful.
|
||||||
* started.
|
|
||||||
*
|
*
|
||||||
* @retval false Otherwise.
|
* @retval STATUS_INCORRECT_STATE The thread was already started.
|
||||||
*/
|
*/
|
||||||
bool _Thread_Start(
|
Status_Control _Thread_Start(
|
||||||
Thread_Control *the_thread,
|
Thread_Control *the_thread,
|
||||||
const Thread_Entry_information *entry,
|
const Thread_Entry_information *entry,
|
||||||
ISR_lock_Context *lock_context
|
ISR_lock_Context *lock_context
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ int pthread_create(
|
|||||||
bool valid;
|
bool valid;
|
||||||
Thread_Configuration config;
|
Thread_Configuration config;
|
||||||
Status_Control status;
|
Status_Control status;
|
||||||
bool ok;
|
|
||||||
Thread_Control *the_thread;
|
Thread_Control *the_thread;
|
||||||
Thread_Control *executing;
|
Thread_Control *executing;
|
||||||
int schedpolicy = SCHED_RR;
|
int schedpolicy = SCHED_RR;
|
||||||
@@ -289,7 +288,7 @@ int pthread_create(
|
|||||||
* POSIX threads are allocated and started in one operation.
|
* POSIX threads are allocated and started in one operation.
|
||||||
*/
|
*/
|
||||||
_ISR_lock_ISR_disable( &lock_context );
|
_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)
|
#if defined(RTEMS_DEBUG)
|
||||||
/*
|
/*
|
||||||
@@ -298,7 +297,7 @@ int pthread_create(
|
|||||||
* NOTE: This can only happen if someone slips in and touches the
|
* NOTE: This can only happen if someone slips in and touches the
|
||||||
* thread while we are creating it.
|
* thread while we are creating it.
|
||||||
*/
|
*/
|
||||||
if ( !ok ) {
|
if ( status != STATUS_SUCCESSFUL ) {
|
||||||
_Thread_Free( &_POSIX_Threads_Information, the_thread );
|
_Thread_Free( &_POSIX_Threads_Information, the_thread );
|
||||||
_Objects_Allocator_unlock();
|
_Objects_Allocator_unlock();
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/tasks.h>
|
#include <rtems/rtems/tasks.h>
|
||||||
|
#include <rtems/rtems/statusimpl.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
#include <rtems/score/threadimpl.h>
|
||||||
|
|
||||||
rtems_status_code rtems_task_start(
|
rtems_status_code rtems_task_start(
|
||||||
@@ -40,7 +41,7 @@ rtems_status_code rtems_task_start(
|
|||||||
};
|
};
|
||||||
Thread_Control *the_thread;
|
Thread_Control *the_thread;
|
||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
bool ok;
|
Status_Control status;
|
||||||
|
|
||||||
the_thread = _Thread_Get( id, &lock_context );
|
the_thread = _Thread_Get( id, &lock_context );
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ rtems_status_code rtems_task_start(
|
|||||||
return RTEMS_INVALID_ID;
|
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 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <rtems/score/isrlevel.h>
|
#include <rtems/score/isrlevel.h>
|
||||||
#include <rtems/score/userextimpl.h>
|
#include <rtems/score/userextimpl.h>
|
||||||
|
|
||||||
bool _Thread_Start(
|
Status_Control _Thread_Start(
|
||||||
Thread_Control *the_thread,
|
Thread_Control *the_thread,
|
||||||
const Thread_Entry_information *entry,
|
const Thread_Entry_information *entry,
|
||||||
ISR_lock_Context *lock_context
|
ISR_lock_Context *lock_context
|
||||||
@@ -36,7 +36,7 @@ bool _Thread_Start(
|
|||||||
|
|
||||||
if ( !_States_Is_dormant( the_thread->current_state ) ) {
|
if ( !_States_Is_dormant( the_thread->current_state ) ) {
|
||||||
_Thread_State_release( the_thread, lock_context );
|
_Thread_State_release( the_thread, lock_context );
|
||||||
return false;
|
return STATUS_INCORRECT_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
the_thread->Start.Entry = *entry;
|
the_thread->Start.Entry = *entry;
|
||||||
@@ -49,5 +49,5 @@ bool _Thread_Start(
|
|||||||
_User_extensions_Thread_start( the_thread );
|
_User_extensions_Thread_start( the_thread );
|
||||||
|
|
||||||
_Thread_Dispatch_enable( cpu_self );
|
_Thread_Dispatch_enable( cpu_self );
|
||||||
return true;
|
return STATUS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user