![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
#include <Os/Task.hpp>
Classes | |
class | TaskRoutineWrapper |
Wrapper for task routine that ensures onStart() is called once the task actually begins. More... | |
Public Types | |
typedef FwSizeType | ParamType |
backwards-compatible parameter type | |
![]() | |
enum | Status { OP_OK , INVALID_HANDLE , INVALID_PARAMS , INVALID_STACK , UNKNOWN_ERROR , INVALID_AFFINITY , DELAY_ERROR , JOIN_ERROR , ERROR_RESOURCES , ERROR_PERMISSION , INVALID_STATE } |
enum | SuspensionType { INTENTIONAL , UNINTENTIONAL } |
enum | State { NOT_STARTED , STARTING , RUNNING , SUSPENDED_INTENTIONALLY , SUSPENDED_UNINTENTIONALLY , EXITED , UNKNOWN } |
typedef void(* | taskRoutine) (void *ptr) |
Prototype for task routine started in task context. | |
Public Member Functions | |
Task () | |
default constructor | |
~Task () final | |
default virtual destructor | |
Task (const Task &other)=delete | |
copy constructor is forbidden | |
Task & | operator= (const Task &other)=delete |
assignment operator is forbidden | |
void | suspend () |
suspend the current task | |
State | getState () |
get the task's state | |
DEPRECATED (Status start(const Fw::StringBase &name, const taskRoutine routine, void *const arg=nullptr, const ParamType priority=TASK_DEFAULT, const ParamType stackSize=TASK_DEFAULT, const ParamType cpuAffinity=TASK_DEFAULT, const ParamType identifier=TASK_DEFAULT), "Switch to Task::start(Arguments&)") | |
start this task | |
Status | start (const Arguments &arguments) override |
start the task | |
void | onStart () override |
perform delegate's required task start actions | |
void | invokeRoutine () |
invoke the task's routine | |
DEPRECATED (Status join(void **value_ptr), "Please switch to argument free join.") | |
join calling thread to this thread | |
Status | join () override |
block until the task has ended | |
void | suspend (SuspensionType suspensionType) override |
suspend the task given the suspension type | |
void | resume () override |
resume a suspended task | |
Status | _delay (Fw::TimeInterval interval) override |
delay the current task | |
bool | isCooperative () override |
determine if the task is cooperative multitasking (implementation specific) | |
FwSizeType | getPriority () |
get the task priority | |
TaskHandle * | getHandle () override |
return the underlying task handle (implementation specific) | |
![]() | |
TaskInterface ()=default | |
default constructor | |
virtual | ~TaskInterface ()=default |
default virtual destructor | |
TaskInterface (const TaskInterface &other)=delete | |
copy constructor is forbidden | |
TaskInterface & | operator= (const TaskInterface &other)=delete |
assignment operator is forbidden | |
Static Public Member Functions | |
static void | init () |
initialize singleton | |
static FwSizeType | getNumTasks () |
get the current number of tasks | |
static void | registerTaskRegistry (TaskRegistry *registry) |
register a task registry to track Threads | |
static Task & | getSingleton () |
get a reference to singleton | |
static Status | delay (Fw::TimeInterval interval) |
delay the current task | |
![]() | |
static TaskInterface * | getDelegate (TaskHandleStorage &aligned_placement_new_memory) |
provide a pointer to a task delegate object | |
Additional Inherited Members | |
![]() | |
static constexpr FwSizeType | TASK_DEFAULT = std::numeric_limits<FwSizeType>::max() |
Task class intended to be used by the rest of the fprime system. This is final as it is not intended to be a parent class. Instead it wraps a delegate provided by TaskInterface::getDelegate()
to provide system specific behaviour.
typedef FwSizeType Os::Task::ParamType |
|
delete |
copy constructor is forbidden
|
overridevirtual |
delay the current task
Delays, or sleeps, the current task by the supplied time interval. In non-preempting os implementations the task will resume no earlier than expected but an exact wake-up time is not guaranteed.
interval | delay time |
Implements Os::TaskInterface.
|
static |
delay the current task
Delays, or sleeps, the current task by the supplied time interval. In non-preempting os implementations the task will resume no earlier than expected but an exact wake-up time is not guaranteed.
interval | delay time |
Os::Task::DEPRECATED | ( | Status | joinvoid **value_ptr, |
"Please switch to argument free join." | |||
) |
join calling thread to this thread
Note: this function is deprecated as the value_ptr object is not used anyway and should always be set to nullptr.
value_ptr | must be set to nullptr |
Os::Task::DEPRECATED | ( | Status | startconst Fw::StringBase &name, const taskRoutine routine, void *const arg=nullptr, const ParamType priority=TASK_DEFAULT, const ParamType stackSize=TASK_DEFAULT, const ParamType cpuAffinity=TASK_DEFAULT, const ParamType identifier=TASK_DEFAULT, |
"Switch to Task::start(Arguments&)" | |||
) |
start this task
Start this task with supplied name, task routine (run function), priority, stack, affinity, and task identifier. These arguments are supplied into an Arguments class and that version of the function is called. It is illegal to supply a nullptr as routine.
name | name of the task to start |
routine | user routine to run |
arg | (optional) user argument to supply to task routine |
priority | (optional) priority of this task |
stackSize | (optional) stack size of this task |
cpuAffinity | (optional) affinity of this task. Use Task::start(Arguments&) to supply affinity set. |
identifier | (optional) identifier of this task |
|
overridevirtual |
return the underlying task handle (implementation specific)
Implements Os::TaskInterface.
|
static |
FwSizeType Os::Task::getPriority | ( | ) |
|
static |
Task::State Os::Task::getState | ( | ) |
void Os::Task::invokeRoutine | ( | ) |
|
overridevirtual |
determine if the task is cooperative multitasking (implementation specific)
Reimplemented from Os::TaskInterface.
|
overridevirtual |
block until the task has ended
Blocks the current (calling) task until this task execution has ended. Callers should ensure that any signals required to stop this task have already been emitted or will be emitted by another task.
Implements Os::TaskInterface.
|
overridevirtual |
perform delegate's required task start actions
Implements Os::TaskInterface.
|
static |
|
overridevirtual |
resume a suspended task
Resumes this task. Not started, running, and exited tasks take no action.
Implements Os::TaskInterface.
|
overridevirtual |
start the task
Starts the task given the supplied arguments. This is done via a task routine wrapper intermediary that ensures that setStarted
is called once the task has actually started to run. The task then runs the user routine. This function may return before the new task begins to run. It is illegal for arguments.m_routine to be null.
arguments | arguments supplied to the task start call |
Implements Os::TaskInterface.
void Os::Task::suspend | ( | ) |
|
overridevirtual |
suspend the task given the suspension type
Suspends the task. Some implementations track if the suspension of a task was intentional or unintentional. The supplied suspensionType
parameter indicates that this was intentional or unintentional. The type of suspension is also returned when calling isSuspended
.
suspensionType | intentionality of the suspension |
Implements Os::TaskInterface.