fsfw/src/fsfw/osal/linux/PeriodicPosixTask.h

68 lines
2.2 KiB
C
Raw Normal View History

2018-07-13 18:28:26 +02:00
#ifndef FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_
#define FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_
2022-05-17 18:12:05 +02:00
#include <vector>
2018-07-13 18:28:26 +02:00
2022-05-18 15:42:18 +02:00
#include "PosixThread.h"
2022-05-18 14:32:35 +02:00
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tasks/PeriodicTaskBase.h"
2022-05-18 15:42:18 +02:00
#include "fsfw/tasks/PeriodicTaskIF.h"
2022-05-18 15:42:18 +02:00
class PeriodicPosixTask : public PeriodicTaskBase {
2022-02-02 10:29:30 +01:00
public:
/**
* Create a generic periodic task.
* @param name_
* Name, maximum allowed size of linux is 16 chars, everything else will
* be truncated.
* @param priority_
* Real-time priority, ranges from 1 to 99 for Linux.
* See: https://man7.org/linux/man-pages/man7/sched.7.html
* @param stackSize_
* @param period_
* @param deadlineMissedFunc_
*/
2022-05-18 15:42:18 +02:00
PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, TaskPeriod period_,
TaskDeadlineMissedFunction dlmFunc_);
~PeriodicPosixTask() override = default;
2018-07-13 18:28:26 +02:00
2022-02-02 10:29:30 +01:00
/**
* @brief The method to start the task.
* @details The method starts the task with the respective system call.
* Entry point is the taskEntryPoint method described below.
* The address of the task object is passed as an argument
* to the system call.
*/
ReturnValue_t startTask() override;
2018-07-13 18:28:26 +02:00
2022-02-02 10:29:30 +01:00
ReturnValue_t sleepFor(uint32_t ms) override;
2018-07-13 18:28:26 +02:00
2022-02-02 10:29:30 +01:00
private:
2022-05-18 15:42:18 +02:00
PosixThread posixThread;
2018-07-13 18:28:26 +02:00
2022-02-02 10:29:30 +01:00
/**
* @brief Flag to indicate that the task was started and is allowed to run
*/
bool started;
2018-07-13 18:28:26 +02:00
2022-02-02 10:29:30 +01:00
/**
* @brief The function containing the actual functionality of the task.
* @details The method sets and starts
2022-02-22 11:16:33 +01:00
* the task's period, then enters a loop that is repeated indefinitely. Within
* the loop, all performOperation methods of the added objects are called. Afterwards the task
* will be blocked until the next period. On missing the deadline, the deadlineMissedFunction is
* executed.
2022-02-02 10:29:30 +01:00
*/
[[noreturn]] virtual void taskFunctionality();
2022-02-02 10:29:30 +01:00
/**
* @brief This is the entry point in a new thread.
*
* @details This method, that is the entry point in the new thread and calls taskFunctionality
* of the child class. Needs a valid pointer to the derived class.
*/
static void* taskEntryPoint(void* arg);
2018-07-13 18:28:26 +02:00
};
#endif /* FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_ */