From 05403d4231a5665eac69f17bf9c0ce87c323239e Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Fri, 3 Mar 2017 11:31:50 -0600 Subject: [PATCH] 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. --- rtos/Thread.cpp | 6 +++++- rtos/Thread.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rtos/Thread.cpp b/rtos/Thread.cpp index c168afde2f..9969e09670 100644 --- a/rtos/Thread.cpp +++ b/rtos/Thread.cpp @@ -179,11 +179,15 @@ int32_t Thread::signal_clr(int32_t signals) { Thread::State Thread::get_state() { #if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM) #ifdef CMSIS_OS_RTX - State status = Deleted; + State status; _mutex.lock(); if (_tid != NULL) { status = (State)_thread_def.tcb.state; + } else if (_finished) { + status = Deleted; + } else { + status = Inactive; } _mutex.unlock(); diff --git a/rtos/Thread.h b/rtos/Thread.h index 1df34c3712..edad0840e9 100644 --- a/rtos/Thread.h +++ b/rtos/Thread.h @@ -252,7 +252,7 @@ public: /** State of the Thread */ enum State { - Inactive, /**< Not created or terminated */ + Inactive, /**< Not created */ Ready, /**< Ready to run */ Running, /**< Running */ WaitingDelay, /**< Waiting for a delay to occur */