issues with fixed timeslo ttask on linux

This commit is contained in:
Robin Müller 2020-06-06 14:45:45 +02:00
parent 788f7a3745
commit 212cd58f9a
4 changed files with 31 additions and 15 deletions

View File

@ -64,7 +64,7 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
// Run the unlockRealtime script or grant the mode manully by using:
// sudo setcap 'CAP_SYS_RESOURCE=+ep' <pathToBinary>
// Permanent solution:
// Permanent solution (EventManager has mq depth of 80):
// echo msg_max | sudo tee /proc/sys/fs/mqueue/msg_max
sif::error << "MessageQueue::MessageQueue: Default MQ size "
<< defaultMqMaxMsg << " is too small for requested size "

View File

@ -3,6 +3,10 @@
#include <errno.h>
#include <framework/osal/linux/PosixThread.h>
PosixThread::PosixThread(const char* name_, int priority_, size_t stackSize_):
thread(0),priority(priority_),stackSize(stackSize_) {
strcpy(name,name_);
}
PosixThread::~PosixThread() {
//No deletion and no free of Stack Pointer
@ -113,12 +117,6 @@ uint64_t PosixThread::getCurrentMonotonicTimeMs(){
return currentTime_ms;
}
PosixThread::PosixThread(const char* name_, int priority_, size_t stackSize_):
thread(0),priority(priority_),stackSize(stackSize_) {
strcpy(name,name_);
}
void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
//sif::debug << "PosixThread::createTask" << std::endl;
@ -135,14 +133,24 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
sif::error << "Posix Thread attribute init failed with: " <<
strerror(status) << std::endl;
}
void* sp;
status = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stackSize);
void* stackPointer;
status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize);
if(status != 0){
sif::error << "PosixThread::createTask: Stack init failed with: " <<
strerror(status) << std::endl;
if(errno == ENOMEM) {
double stackMb = (double)((double)stackSize/(double)10e6);
sif::error << "PosixThread::createTask: Insufficient memory for"
" the requested " << stackMb << " MB" << std::endl;
}
else if(errno == EINVAL) {
sif::error << "PosixThread::createTask: Wrong alignment argument!"
<< std::endl;
}
return;
}
status = pthread_attr_setstack(&attributes, sp, stackSize);
status = pthread_attr_setstack(&attributes, stackPointer, stackSize);
if(status != 0){
sif::error << "Posix Thread attribute setStack failed with: " <<
strerror(status) << std::endl;

View File

@ -68,7 +68,7 @@ protected:
private:
char name[10];
int priority;
size_t stackSize;
size_t stackSize = 0;
};
#endif /* FRAMEWORK_OSAL_LINUX_POSIXTHREAD_H_ */

View File

@ -13,12 +13,20 @@ TaskFactory* TaskFactory::instance() {
return TaskFactory::factoryInstance;
}
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) {
return static_cast<PeriodicTaskIF*>(new PeriodicPosixTask(name_, taskPriority_,stackSize_,periodInSeconds_ * 1000,deadLineMissedFunction_));
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
TaskPriority taskPriority_,TaskStackSize stackSize_,
TaskPeriod periodInSeconds_,
TaskDeadlineMissedFunction deadLineMissedFunction_) {
return new PeriodicPosixTask(name_, taskPriority_,stackSize_,
periodInSeconds_ * 1000, deadLineMissedFunction_);
}
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,TaskPriority taskPriority_,TaskStackSize stackSize_,TaskPeriod periodInSeconds_,TaskDeadlineMissedFunction deadLineMissedFunction_) {
return static_cast<FixedTimeslotTaskIF*>(new FixedTimeslotTask(name_, taskPriority_,stackSize_,periodInSeconds_*1000));
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,
TaskPriority taskPriority_,TaskStackSize stackSize_,
TaskPeriod periodInSeconds_,
TaskDeadlineMissedFunction deadLineMissedFunction_) {
return new FixedTimeslotTask(name_, taskPriority_,stackSize_,
periodInSeconds_*1000);
}
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {