Skip to content

Commit 05403d4

Browse files
committed
rtos: Add Inactive return to thread get state
If a thread hasn't been started return Inactive as the status when Thread::get_state() is called.
1 parent 11ef1d1 commit 05403d4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rtos/Thread.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,15 @@ int32_t Thread::signal_clr(int32_t signals) {
179179
Thread::State Thread::get_state() {
180180
#if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM)
181181
#ifdef CMSIS_OS_RTX
182-
State status = Deleted;
182+
State status;
183183
_mutex.lock();
184184

185185
if (_tid != NULL) {
186186
status = (State)_thread_def.tcb.state;
187+
} else if (_finished) {
188+
status = Deleted;
189+
} else {
190+
status = Inactive;
187191
}
188192

189193
_mutex.unlock();

rtos/Thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class Thread {
252252

253253
/** State of the Thread */
254254
enum State {
255-
Inactive, /**< Not created or terminated */
255+
Inactive, /**< Not created */
256256
Ready, /**< Ready to run */
257257
Running, /**< Running */
258258
WaitingDelay, /**< Waiting for a delay to occur */

0 commit comments

Comments
 (0)