summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-26 13:36:46 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-27 19:40:13 +0200
commitbbc93c119c72f981b5091fa06aea5e7369b79a59 (patch)
tree6c637a0cbfd20e32a2076395034014538de7c561
parent9d82150f5a83e8dcf985de26799f99f7c46ec515 (diff)
downloadrtems-bbc93c119c72f981b5091fa06aea5e7369b79a59.tar.bz2
Return status code for _Thread_Start()
This avoids having conditional statements to get the API-specific status code.
-rw-r--r--cpukit/include/rtems/score/threadimpl.h7
-rw-r--r--cpukit/posix/src/pthreadcreate.c5
-rw-r--r--cpukit/rtems/src/taskstart.c7
-rw-r--r--cpukit/score/src/threadstart.c6
4 files changed, 12 insertions, 13 deletions
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index d9c0779b08..5dfd142b92 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -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
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index f53cd5e310..055d304699 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -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;
diff --git a/cpukit/rtems/src/taskstart.c b/cpukit/rtems/src/taskstart.c
index da29240961..eca9b5795d 100644
--- a/cpukit/rtems/src/taskstart.c
+++ b/cpukit/rtems/src/taskstart.c
@@ -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 );
}
diff --git a/cpukit/score/src/threadstart.c b/cpukit/score/src/threadstart.c
index e75c536a2c..8c1732a35a 100644
--- a/cpukit/score/src/threadstart.c
+++ b/cpukit/score/src/threadstart.c
@@ -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;
}