[rtems commit] Return status code for _Thread_Start()
Sebastian Huber
sebh at rtems.org
Tue Apr 27 17:53:09 UTC 2021
Module: rtems
Branch: master
Commit: bbc93c119c72f981b5091fa06aea5e7369b79a59
Changeset: http://git.rtems.org/rtems/commit/?id=bbc93c119c72f981b5091fa06aea5e7369b79a59
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Apr 26 13:36:46 2021 +0200
Return status code for _Thread_Start()
This avoids having conditional statements to get the API-specific status
code.
---
cpukit/include/rtems/score/threadimpl.h | 7 +++----
cpukit/posix/src/pthreadcreate.c | 5 ++---
cpukit/rtems/src/taskstart.c | 7 ++++---
cpukit/score/src/threadstart.c | 6 +++---
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index d9c0779..5dfd142 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 f53cd5e..055d304 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 da29240..eca9b57 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 e75c536..8c1732a 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;
}
More information about the vc
mailing list