F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Os::TaskInterface Class Referenceabstract

#include <Os/Task.hpp>

Inheritance diagram for Os::TaskInterface:
Os::Posix::Task::PosixTask Os::Stub::Task::StubTask Os::Task

Classes

class  Arguments
 

Public Types

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. More...
 

Public Member Functions

 TaskInterface ()=default
 default constructor More...
 
virtual ~TaskInterface ()=default
 default virtual destructor More...
 
 TaskInterface (const TaskInterface &other)=delete
 copy constructor is forbidden More...
 
TaskInterfaceoperator= (const TaskInterface &other)=delete
 assignment operator is forbidden More...
 
virtual void onStart ()=0
 perform required task start actions More...
 
virtual Status join ()=0
 block until the task has ended More...
 
virtual void suspend (SuspensionType suspensionType)=0
 suspend the task given the suspension type More...
 
virtual void resume ()=0
 resume a suspended task More...
 
virtual Status _delay (Fw::TimeInterval interval)=0
 delay the currently scheduled task using the given architecture More...
 
virtual bool isCooperative ()
 determine if the task requires cooperative multitasking More...
 
virtual TaskHandlegetHandle ()=0
 return the underlying task handle (implementation specific) More...
 
virtual Status start (const Arguments &arguments)=0
 start the task More...
 

Static Public Member Functions

static TaskInterfacegetDelegate (TaskHandleStorage &aligned_placement_new_memory)
 provide a pointer to a task delegate object More...
 

Static Public Attributes

static constexpr FwSizeType TASK_DEFAULT = std::numeric_limits<FwSizeType>::max()
 

Detailed Description

Definition at line 26 of file Task.hpp.

Member Typedef Documentation

◆ taskRoutine

typedef void(* Os::TaskInterface::taskRoutine) (void *ptr)

Prototype for task routine started in task context.

Definition at line 59 of file Task.hpp.

Member Enumeration Documentation

◆ State

Enumerator
NOT_STARTED 
STARTING 
RUNNING 
SUSPENDED_INTENTIONALLY 
SUSPENDED_UNINTENTIONALLY 
EXITED 
UNKNOWN 

Definition at line 48 of file Task.hpp.

◆ Status

Enumerator
OP_OK 

message sent/received okay

INVALID_HANDLE 

Task handle invalid.

INVALID_PARAMS 

started task with invalid parameters

INVALID_STACK 

started with invalid stack size

UNKNOWN_ERROR 

unexpected error return value

INVALID_AFFINITY 

unable to set the task affinity

DELAY_ERROR 

error trying to delay the task

JOIN_ERROR 

error trying to join the task

ERROR_RESOURCES 

unable to allocate more tasks

ERROR_PERMISSION 

permissions error setting-up tasks

INVALID_STATE 

Task is in an invalid state for the operation.

Definition at line 29 of file Task.hpp.

◆ SuspensionType

Enumerator
INTENTIONAL 
UNINTENTIONAL 

Definition at line 43 of file Task.hpp.

Constructor & Destructor Documentation

◆ TaskInterface() [1/2]

Os::TaskInterface::TaskInterface ( )
default

default constructor

◆ ~TaskInterface()

virtual Os::TaskInterface::~TaskInterface ( )
virtualdefault

default virtual destructor

◆ TaskInterface() [2/2]

Os::TaskInterface::TaskInterface ( const TaskInterface other)
delete

copy constructor is forbidden

Member Function Documentation

◆ _delay()

virtual Status Os::TaskInterface::_delay ( Fw::TimeInterval  interval)
pure virtual

delay the currently scheduled task using the given architecture

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.

Parameters
intervaldelay time
Returns
status of the delay

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ getDelegate()

TaskInterface * Os::TaskInterface::getDelegate ( TaskHandleStorage aligned_placement_new_memory)
static

provide a pointer to a task delegate object

This function must return a pointer to a TaskInterface object that contains the real implementation of the file functions as defined by the implementor. This function must do several things to be considered correctly implemented:

  1. Assert that the supplied memory is non-null. e.g FW_ASSERT(aligned_placement_new_memory != NULL);
  2. Assert that their implementation fits within FW_HANDLE_MAX_SIZE. e.g. static_assert(sizeof(PosixTaskImplementation) <= sizeof Os::Task::m_handle_storage, "FW_HANDLE_MAX_SIZE to small");
  3. Assert that their implementation aligns within FW_HANDLE_ALIGNMENT. e.g. static_assert((FW_HANDLE_ALIGNMENT % alignof(PosixTaskImplementation)) == 0, "Bad handle alignment");
  4. Placement new their implementation into aligned_placement_new_memory e.g. TaskInterface* interface = new (aligned_placement_new_memory) PosixTaskImplementation;
  5. Return the result of the placement new e.g. return interface;
Returns
result of placement new, must be equivalent to aligned_placement_new_memory

Definition at line 11 of file DefaultTask.cpp.

◆ getHandle()

virtual TaskHandle* Os::TaskInterface::getHandle ( )
pure virtual

return the underlying task handle (implementation specific)

Returns
internal task handle representation

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ isCooperative()

bool Os::TaskInterface::isCooperative ( )
virtual

determine if the task requires cooperative multitasking

Some task implementations require cooperative multitasking where the task execution is run by a user defined task scheduler and not the operating system task scheduler. These tasks cooperatively on multitask by doing one unit of work and return from the function.

This function indicates if the task requires cooperative support. The default implementation returns false.

Returns
true when the task expects cooperation, false otherwise

Reimplemented in Os::Task, and Os::Stub::Task::StubTask.

Definition at line 56 of file Task.cpp.

◆ join()

virtual Status Os::TaskInterface::join ( )
pure virtual

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.

Returns
status of the block

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ onStart()

virtual void Os::TaskInterface::onStart ( )
pure virtual

perform required task start actions

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ operator=()

TaskInterface& Os::TaskInterface::operator= ( const TaskInterface other)
delete

assignment operator is forbidden

◆ resume()

virtual void Os::TaskInterface::resume ( )
pure virtual

resume a suspended task

Resumes this task. Not started, running, and exited tasks take no action.

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ start()

virtual Status Os::TaskInterface::start ( const Arguments arguments)
pure virtual

start the task

Starts the task given the supplied arguments.

Parameters
argumentsarguments supplied to the task start call
Returns
status of the task start

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

◆ suspend()

virtual void Os::TaskInterface::suspend ( SuspensionType  suspensionType)
pure virtual

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.

Parameters
suspensionTypeintentionality of the suspension

Implemented in Os::Task, Os::Stub::Task::StubTask, and Os::Posix::Task::PosixTask.

Member Data Documentation

◆ TASK_DEFAULT

constexpr FwSizeType Os::TaskInterface::TASK_DEFAULT = std::numeric_limits<FwSizeType>::max()
staticconstexpr

Definition at line 28 of file Task.hpp.


The documentation for this class was generated from the following files: