diff --git a/Os/Task.cpp b/Os/Task.cpp index f70382bde3..8c4a0b3258 100644 --- a/Os/Task.cpp +++ b/Os/Task.cpp @@ -106,6 +106,9 @@ Task::Status Task::start(const Task::Arguments& arguments) { Task::Status status = this->m_delegate.start(wrapped_arguments); if (status == Task::Status::OP_OK) { + Task::m_lock.lock(); + this->m_priority = wrapped_arguments.m_priority; + Task::m_lock.unlock(); Task::s_taskMutex.lock(); Task::s_numTasks++; Task::s_taskMutex.unlock(); @@ -163,6 +166,11 @@ bool Task::isCooperative() { return this->m_delegate.isCooperative(); } +FwSizeType Task::getPriority() { + Os::ScopeLock lock(this->m_lock); + return this->m_priority; +} + TaskHandle* Task::getHandle() { FW_ASSERT(&this->m_delegate == reinterpret_cast(&this->m_handle_storage[0])); return this->m_delegate.getHandle(); diff --git a/Os/Task.hpp b/Os/Task.hpp index 269228c4c5..203b287083 100644 --- a/Os/Task.hpp +++ b/Os/Task.hpp @@ -330,6 +330,9 @@ namespace Os { //! \return true if cooperative, false otherwise bool isCooperative() override; + //! \brief get the task priority + FwSizeType getPriority(); + //! \brief return the underlying task handle (implementation specific) //! \return internal task handle representation TaskHandle* getHandle() override; @@ -367,6 +370,7 @@ namespace Os { TaskInterface::State m_state = Task::NOT_STARTED; Mutex m_lock; //!< Guards state transitions TaskRoutineWrapper m_wrapper; //!< Concrete storage for task routine wrapper + FwSizeType m_priority = 0; // Storage of priority bool m_registered = false; //!< Was this task registered