Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/common/messaging')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c38
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c28
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h12
4 files changed, 20 insertions, 101 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
index 88bb1f38c..fc0a7edb1 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
@@ -20,8 +20,6 @@ void etMessageQueue_init(etMessageQueue* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
self->first = NULL;
self->last = NULL;
- self->statistics.highWaterMark = 0;
- self->statistics.lowWaterMark = 0;
self->size = 0;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -40,9 +38,7 @@ void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
self->last = msg;
}
msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/
-
- if (++self->size > self->statistics.highWaterMark)
- self->statistics.highWaterMark++;
+ self->size++;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -67,9 +63,6 @@ etMessage* etMessageQueue_pop(etMessageQueue* self){
pop_msg->next=NULL;
self->size--;
- if (self->size < self->statistics.lowWaterMark)
- self->statistics.lowWaterMark--;
-
ET_MSC_LOGGER_SYNC_EXIT
return pop_msg;
}
@@ -98,32 +91,3 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
return self->last != NULL;
}
-const etQueueStatistics* etMessageQueue_getStatistics(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return &self->statistics;
-}
-
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->statistics.highWaterMark;
-}
-
-void etMessageQueue_resetHighWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetHighWaterMark")
- self->statistics.highWaterMark = 0;
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLowWaterMark")
- ET_MSC_LOGGER_SYNC_EXIT
- return self->statistics.lowWaterMark;
-}
-
-void etMessageQueue_resetLowWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetLowWaterMark")
- self->statistics.lowWaterMark = self->size;
- ET_MSC_LOGGER_SYNC_EXIT
-}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
index eb3727034..dda05abfa 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
@@ -29,22 +29,12 @@
ET_EXTERN_C_BEGIN
/**
- * a data structure for the queue statistics
- */
-typedef struct etQueueStatistics {
- etInt16 highWaterMark; /**< high water mark */
- etInt16 lowWaterMark; /**< low water mark */
-}
-etQueueStatistics;
-
-/**
* the message queue data structure
*/
typedef struct etMessageQueue {
etMessage* first; /**< the head of the list */
etMessage* last; /**< the tail of the list */
etInt16 size; /**< the size of the list */
- etQueueStatistics statistics; /**< high water mark for statistical purposes */
}
etMessageQueue;
@@ -99,39 +89,6 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
* \return the size of the message queue
*/
etInt16 etMessageQueue_getSize(etMessageQueue* self);
-/**
- * returns the statistics of the queue
- * \param self the this pointer
- * \return the statistics of the queue (immutable)
- */
-const etQueueStatistics* etMessageQueue_getStatistics(etMessageQueue* self);
-/**
- * returns the high water mark of the message queue
- *
- * \param self the this pointer
- * \return the high water mark of the message queue
- */
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
-/**
- * resets the high water mark of the message queue to 0
- *
- * \param self the this pointer
- */
-void etMessageQueue_resetHighWaterMark(etMessageQueue* self);
-/**
- * returns the low water mark of the message queue
- *
- * \param self the this pointer
- * \return the low water mark of the message queue
- */
-etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self);
-/**
- * resets the low water mark of the message queue to the current
- * position (size) of the queue
- *
- * \param self the this pointer
- */
-void etMessageQueue_resetLowWaterMark(etMessageQueue* self);
ET_EXTERN_C_END
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index e7298885c..d752e465a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -90,7 +90,10 @@ void etMessageService_initx(
/* init statistics */
self->statistics.highWaterMark = 0;
- self->statistics.queueStatistics = &self->messageQueue.statistics;
+ self->statistics.queueStatistics.highWaterMark = 0;
+ self->statistics.queueStatistics.lowWaterMark = 0;
+ self->statistics.queueStatistics.nFailingRequests = 0;
+
self->resetStatistics = ET_FALSE;
/* register with runtime */
@@ -152,7 +155,6 @@ void etMessageService_initMessagePool(etMessageService* self){
etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize];
etMessageQueue_push(&self->messagePool, block);
}
- etMessageQueue_resetLowWaterMark(&self->messagePool);
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -184,14 +186,19 @@ etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 si
if (self->messagePool.size>0){
etMessage* msg = etMessageQueue_pop(&self->messagePool);
etMutex_leave(&self->poolMutex);
+ if((self->messageBuffer.maxBlocks - self->messagePool.size) > self->statistics.queueStatistics.highWaterMark) {
+ self->statistics.queueStatistics.highWaterMark++;
+ }
ET_MSC_LOGGER_SYNC_EXIT
return msg;
}
else {
- etLogger_logErrorF("etMessageService_getMessageBuffer: message pool empty: %d", etMessageService_getMessagePoolLowWaterMark(self));
+ self->statistics.queueStatistics.nFailingRequests++;
+ etLogger_logErrorF("etMessageService_getMessageBuffer: message pool empty: %d", self->statistics.queueStatistics.lowWaterMark);
}
}
else {
+ self->statistics.queueStatistics.nFailingRequests++;
etLogger_logErrorF("etMessageService_getMessageBuffer: message too big: %d, blockSize: %d", size, self->messageBuffer.blockSize);
}
etMutex_leave(&self->poolMutex);
@@ -203,6 +210,9 @@ void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buf
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer")
etMutex_enter(&self->poolMutex);
etMessageQueue_push(&self->messagePool, buffer);
+ if ((self->messageBuffer.maxBlocks - self->messagePool.size) < self->statistics.queueStatistics.lowWaterMark) {
+ self->statistics.queueStatistics.lowWaterMark--;
+ }
etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -273,8 +283,9 @@ static void etMessageService_deliverAllMessages(etMessageService* self){
self->resetStatistics = ET_FALSE;
self->statistics.highWaterMark = 0;
- etMessageQueue_resetHighWaterMark(&self->messageQueue);
- etMessageQueue_resetLowWaterMark(&self->messageQueue);
+ self->statistics.queueStatistics.highWaterMark = 0;
+ self->statistics.queueStatistics.lowWaterMark = (self->messageBuffer.maxBlocks - self->messagePool.size);
+ self->statistics.queueStatistics.nFailingRequests = 0;
}
while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
@@ -290,13 +301,6 @@ static void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_EXIT
}
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
- etInt16 lowWaterMark = etMessageQueue_getLowWaterMark(&self->messagePool);
- ET_MSC_LOGGER_SYNC_EXIT
- return lowWaterMark;
-}
-
static void etMessageService_timerCallback(void* data) {
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "timerCallback")
{
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index 1d52a5f3c..2a50e55b6 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -27,6 +27,8 @@
#include "etDatatypes.h"
#include "messaging/etMessageQueue.h"
#include "messaging/etMessageReceiver.h"
+#include "base/etQueue.h"
+#include "base/etQueueStatistics.h"
#include "osal/etMutex.h"
#include "osal/etThread.h"
@@ -71,7 +73,7 @@ struct etHighPrioFunc{
*/
typedef struct etMessageServiceStatistics {
etTimeDiff highWaterMark; /** high water mark */
- etQueueStatistics* queueStatistics; /** a pointer to the queue statistics */
+ etQueueStatistics queueStatistics; /** a pointer to the queue statistics */
}
etMessageServiceStatistics;
@@ -211,14 +213,6 @@ etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 si
*/
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
-/**
- * returns the low water mark of the message pool
- *
- * \param self the this pointer
- * \return the low water mark of the message pool
- */
-etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
-
/* functions to register and unregister high prio functions */
void etMessageService_registerHighPrioFunc(etMessageService* self, etHighPrioFunc* func);
void etMessageService_unregisterHighPrioFunc(etMessageService* self, etHighPrioFunc* func);

Back to the top