Skip to content

Commit

Permalink
Add priority to Os::Task (#2984)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch authored Oct 25, 2024
1 parent 2c8d0db commit 40583c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Os/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<TaskInterface*>(&this->m_handle_storage[0]));
return this->m_delegate.getHandle();
Expand Down
4 changes: 4 additions & 0 deletions Os/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 40583c1

Please sign in to comment.