2020-09-04 14:31:39 +02:00
|
|
|
#ifndef FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
|
|
|
#define FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_
|
2018-07-13 18:28:26 +02:00
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "PosixThread.h"
|
2022-05-18 15:42:18 +02:00
|
|
|
#include "fsfw/tasks/FixedSlotSequence.h"
|
2022-05-19 00:44:34 +02:00
|
|
|
#include "fsfw/tasks/FixedTimeslotTaskBase.h"
|
2022-05-18 15:42:18 +02:00
|
|
|
#include "fsfw/tasks/definitions.h"
|
2022-02-02 10:29:30 +01:00
|
|
|
|
2022-05-19 00:44:34 +02:00
|
|
|
class FixedTimeslotTask : public FixedTimeslotTaskBase {
|
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-19 00:44:34 +02:00
|
|
|
FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_,
|
|
|
|
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_);
|
|
|
|
~FixedTimeslotTask() override = default;
|
2018-07-13 18:28:26 +02:00
|
|
|
|
2022-05-14 09:38:59 +02:00
|
|
|
ReturnValue_t startTask() override;
|
2018-07-13 18:28:26 +02:00
|
|
|
|
2022-05-14 09:38:59 +02:00
|
|
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
2018-07-13 18:28:26 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* @brief This function holds the main functionality of the thread.
|
|
|
|
* @details
|
|
|
|
* Holding the main functionality of the task, this method is most important.
|
|
|
|
* It links the functionalities provided by FixedSlotSequence with the
|
|
|
|
* OS's System Calls to keep the timing of the periods.
|
|
|
|
*/
|
2022-05-19 00:44:34 +02:00
|
|
|
[[noreturn]] virtual void taskFunctionality();
|
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;
|
2022-05-19 00:44:34 +02:00
|
|
|
bool started;
|
2022-05-18 15:42:18 +02:00
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* The void* returnvalue is not used yet but could be used to return
|
|
|
|
* arbitrary data.
|
|
|
|
*/
|
|
|
|
static void* taskEntryPoint(void* arg);
|
2018-07-13 18:28:26 +02:00
|
|
|
};
|
|
|
|
|
2020-09-04 14:31:39 +02:00
|
|
|
#endif /* FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */
|