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.
pull/3862/head
Russ Butler 2017-03-03 11:31:50 -06:00
parent 11ef1d10b8
commit 05403d4231
2 changed files with 6 additions and 2 deletions

View File

@ -179,11 +179,15 @@ int32_t Thread::signal_clr(int32_t signals) {
Thread::State Thread::get_state() { Thread::State Thread::get_state() {
#if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM) #if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM)
#ifdef CMSIS_OS_RTX #ifdef CMSIS_OS_RTX
State status = Deleted; State status;
_mutex.lock(); _mutex.lock();
if (_tid != NULL) { if (_tid != NULL) {
status = (State)_thread_def.tcb.state; status = (State)_thread_def.tcb.state;
} else if (_finished) {
status = Deleted;
} else {
status = Inactive;
} }
_mutex.unlock(); _mutex.unlock();

View File

@ -252,7 +252,7 @@ public:
/** State of the Thread */ /** State of the Thread */
enum State { enum State {
Inactive, /**< Not created or terminated */ Inactive, /**< Not created */
Ready, /**< Ready to run */ Ready, /**< Ready to run */
Running, /**< Running */ Running, /**< Running */
WaitingDelay, /**< Waiting for a delay to occur */ WaitingDelay, /**< Waiting for a delay to occur */