host osal update

This commit is contained in:
Robin Müller 2020-09-05 21:19:53 +02:00
parent a1155686c5
commit 902cd4d210
11 changed files with 42 additions and 37 deletions

View File

@ -90,9 +90,12 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
} }
void FixedTimeslotTask::taskFunctionality() { void FixedTimeslotTask::taskFunctionality() {
pollingSeqTable.intializeSequenceAfterTaskCreation();
// A local iterator for the Polling Sequence Table is created to // A local iterator for the Polling Sequence Table is created to
// find the start time for the first entry. // find the start time for the first entry.
FixedSlotSequence::SlotListIter slotListIter = pollingSeqTable.current; auto slotListIter = pollingSeqTable.current;
// Get start time for first entry. // Get start time for first entry.
chron_ms interval(slotListIter->pollingTimeMs); chron_ms interval(slotListIter->pollingTimeMs);
auto currentStartTime { auto currentStartTime {
@ -122,8 +125,11 @@ void FixedTimeslotTask::taskFunctionality() {
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
uint32_t slotTimeMs, int8_t executionStep) { uint32_t slotTimeMs, int8_t executionStep) {
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) { ExecutableObjectIF* executableObject = objectManager->
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, this); get<ExecutableObjectIF>(componentId);
if (executableObject != nullptr) {
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep,
executableObject, this);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -132,7 +138,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t FixedTimeslotTask::checkAndInitializeSequence() const { ReturnValue_t FixedTimeslotTask::checkSequence() const {
return pollingSeqTable.checkSequence(); return pollingSeqTable.checkSequence();
} }

View File

@ -61,7 +61,7 @@ public:
ReturnValue_t addSlot(object_id_t componentId, ReturnValue_t addSlot(object_id_t componentId,
uint32_t slotTimeMs, int8_t executionStep); uint32_t slotTimeMs, int8_t executionStep);
ReturnValue_t checkAndInitializeSequence() const; ReturnValue_t checkSequence() const override;
uint32_t getPeriodMs() const; uint32_t getPeriodMs() const;

View File

@ -1,6 +1,7 @@
#include "../../osal/host/MessageQueue.h" #include "MessageQueue.h"
#include "QueueMapManager.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
#include "../../osal/host/QueueMapManager.h"
#include "../../ipc/MutexFactory.h" #include "../../ipc/MutexFactory.h"
#include "../../ipc/MutexHelper.h" #include "../../ipc/MutexHelper.h"
@ -9,7 +10,8 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
queueLock = MutexFactory::instance()->createMutex(); queueLock = MutexFactory::instance()->createMutex();
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "MessageQueue: Could not be created" << std::endl; sif::error << "MessageQueue::MessageQueue:"
<< " Could not be created" << std::endl;
} }
} }
@ -61,7 +63,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
} }
// not sure this will work.. // not sure this will work..
//*message = std::move(messageQueue.front()); //*message = std::move(messageQueue.front());
MutexHelper mutexLock(queueLock, 20); MutexHelper mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
MessageQueueMessage* currentMessage = &messageQueue.front(); MessageQueueMessage* currentMessage = &messageQueue.front();
std::copy(currentMessage->getBuffer(), std::copy(currentMessage->getBuffer(),
currentMessage->getBuffer() + messageSize, message->getBuffer()); currentMessage->getBuffer() + messageSize, message->getBuffer());
@ -126,7 +128,8 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
} }
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
MutexHelper mutexLock(targetQueue->queueLock, 20); MutexHelper mutexLock(targetQueue->queueLock,
MutexIF::TimeoutType::WAITING, 20);
// not ideal, works for now though. // not ideal, works for now though.
MessageQueueMessage* mqmMessage = MessageQueueMessage* mqmMessage =
dynamic_cast<MessageQueueMessage*>(message); dynamic_cast<MessageQueueMessage*>(message);
@ -146,8 +149,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t MessageQueue::lockQueue(dur_millis_t lockTimeout) { ReturnValue_t MessageQueue::lockQueue(MutexIF::TimeoutType timeoutType,
return queueLock->lockMutex(lockTimeout); dur_millis_t lockTimeout) {
return queueLock->lockMutex(timeoutType, lockTimeout);
} }
ReturnValue_t MessageQueue::unlockQueue() { ReturnValue_t MessageQueue::unlockQueue() {

View File

@ -182,7 +182,8 @@ public:
bool isDefaultDestinationSet() const override; bool isDefaultDestinationSet() const override;
ReturnValue_t lockQueue(dur_millis_t lockTimeout); ReturnValue_t lockQueue(MutexIF::TimeoutType timeoutType,
dur_millis_t lockTimeout);
ReturnValue_t unlockQueue(); ReturnValue_t unlockQueue();
protected: protected:
/** /**

View File

@ -1,10 +1,9 @@
#include "../../osal/host/Mutex.h" #include "Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
const uint32_t MutexIF::POLLING = 0; Mutex::Mutex() {}
const uint32_t MutexIF::BLOCKING = 0xffffffff;
ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) { ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutMs == MutexIF::BLOCKING) { if(timeoutMs == MutexIF::BLOCKING) {
mutex.lock(); mutex.lock();
locked = true; locked = true;

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_OSAL_FREERTOS_MUTEX_H_ #ifndef FSFW_OSAL_HOSTED_MUTEX_H_
#define FRAMEWORK_OSAL_FREERTOS_MUTEX_H_ #define FSFW_OSAL_HOSTED_MUTEX_H_
#include "../../ipc/MutexIF.h" #include "../../ipc/MutexIF.h"
@ -15,8 +15,9 @@
*/ */
class Mutex : public MutexIF { class Mutex : public MutexIF {
public: public:
Mutex() = default; Mutex();
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override; ReturnValue_t lockMutex(TimeoutType timeoutType =
TimeoutType::BLOCKING, uint32_t timeoutMs = 0) override;
ReturnValue_t unlockMutex() override; ReturnValue_t unlockMutex() override;
std::timed_mutex* getMutexHandle(); std::timed_mutex* getMutexHandle();
@ -25,4 +26,4 @@ private:
std::timed_mutex mutex; std::timed_mutex mutex;
}; };
#endif /* FRAMEWORK_FREERTOS_MUTEX_H_ */ #endif /* FSFW_OSAL_HOSTED_MUTEX_H_ */

View File

@ -1,7 +1,7 @@
#include "../../ipc/MutexFactory.h" #include "Mutex.h"
#include "../../osal/host/Mutex.h" #include "PeriodicTask.h"
#include "../../osal/host/PeriodicTask.h"
#include "../../ipc/MutexFactory.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
#include "../../tasks/ExecutableObjectIF.h" #include "../../tasks/ExecutableObjectIF.h"

View File

@ -1,6 +1,7 @@
#include "QueueMapManager.h"
#include "../../ipc/MutexFactory.h" #include "../../ipc/MutexFactory.h"
#include "../../ipc/MutexHelper.h" #include "../../ipc/MutexHelper.h"
#include "../../osal/host/QueueMapManager.h"
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr; QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
@ -37,7 +38,7 @@ ReturnValue_t QueueMapManager::addMessageQueue(
MessageQueueIF* QueueMapManager::getMessageQueue( MessageQueueIF* QueueMapManager::getMessageQueue(
MessageQueueId_t messageQueueId) const { MessageQueueId_t messageQueueId) const {
MutexHelper(mapLock, 50); MutexHelper(mapLock, MutexIF::TimeoutType::WAITING, 50);
auto queueIter = queueMap.find(messageQueueId); auto queueIter = queueMap.find(messageQueueId);
if(queueIter != queueMap.end()) { if(queueIter != queueMap.end()) {
return queueIter->second; return queueIter->second;

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ #ifndef FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_
#define FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ #define FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_
#include "../../ipc/MessageQueueSenderIF.h" #include "../../ipc/MessageQueueSenderIF.h"
#include "../../osal/host/MessageQueue.h" #include "../../osal/host/MessageQueue.h"
@ -44,4 +44,4 @@ private:
#endif /* FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ */ #endif /* FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_ */

View File

@ -3,9 +3,6 @@
#include "../../osal/linux/CountingSemaphore.h" #include "../../osal/linux/CountingSemaphore.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
const uint32_t SemaphoreIF::POLLING = 0;
const uint32_t SemaphoreIF::BLOCKING = 0xFFFFFFFF;
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
SemaphoreFactory::SemaphoreFactory() { SemaphoreFactory::SemaphoreFactory() {

View File

@ -25,8 +25,6 @@ PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
TaskPriority taskPriority_,TaskStackSize stackSize_, TaskPriority taskPriority_,TaskStackSize stackSize_,
TaskPeriod periodInSeconds_, TaskPeriod periodInSeconds_,
TaskDeadlineMissedFunction deadLineMissedFunction_) { TaskDeadlineMissedFunction deadLineMissedFunction_) {
// This is going to be interesting. Time now learn the C++ threading library
// :-)
return new PeriodicTask(name_, taskPriority_, stackSize_, periodInSeconds_, return new PeriodicTask(name_, taskPriority_, stackSize_, periodInSeconds_,
deadLineMissedFunction_); deadLineMissedFunction_);
} }
@ -35,8 +33,6 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_,
TaskPriority taskPriority_,TaskStackSize stackSize_, TaskPriority taskPriority_,TaskStackSize stackSize_,
TaskPeriod periodInSeconds_, TaskPeriod periodInSeconds_,
TaskDeadlineMissedFunction deadLineMissedFunction_) { TaskDeadlineMissedFunction deadLineMissedFunction_) {
// This is going to be interesting. Time now learn the C++ threading library
// :-)
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, return new FixedTimeslotTask(name_, taskPriority_, stackSize_,
periodInSeconds_, deadLineMissedFunction_); periodInSeconds_, deadLineMissedFunction_);
} }