Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h9
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c3
3 files changed, 23 insertions, 7 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 b1a5fea54..8c87c853f 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
@@ -19,6 +19,7 @@ void etMessageQueue_init(etMessageQueue* self){
self->first = NULL;
self->last = NULL;
self->highWaterMark = 0;
+ self->lowWaterMark = 0;
self->size = 0;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -64,6 +65,9 @@ etMessage* etMessageQueue_pop(etMessageQueue* self){
pop_msg->next=NULL;
self->size--;
+ if (self->size < self->lowWaterMark)
+ self->lowWaterMark--;
+
ET_MSC_LOGGER_SYNC_EXIT
return pop_msg;
}
@@ -93,7 +97,19 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
}
etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
- ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHightWaterMark")
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
ET_MSC_LOGGER_SYNC_EXIT
return self->highWaterMark;
}
+
+etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLowWaterMark")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return self->lowWaterMark;
+}
+
+void etMessageQueue_resetLowWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetLowWaterMark")
+ self->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 f305d1aa9..a9a6cb13e 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
@@ -20,6 +20,7 @@ typedef struct etMessageQueue {
etMessage* first;
etMessage* last;
etInt16 highWaterMark;
+ etInt16 lowWaterMark;
etInt16 size;
} etMessageQueue;
@@ -27,19 +28,17 @@ typedef struct etMessageQueue {
void etMessageQueue_init(etMessageQueue* self);
void etMessageQueue_push(etMessageQueue* self, etMessage* msg);
-
etMessage* etMessageQueue_pop(etMessageQueue* self);
etMessage* etMessageQueue_getFirst(etMessageQueue* self);
-
etMessage* etMessageQueue_getLast(etMessageQueue* self);
etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
-etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
-
etInt16 etMessageQueue_getSize(etMessageQueue* self);
-
+etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
+etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self);
+void etMessageQueue_resetLowWaterMark(etMessageQueue* self);
#endif /* _RMESSAGEQUEUE_H_ */
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 3d119ea80..d78287349 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
@@ -80,6 +80,7 @@ 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
}
@@ -153,7 +154,7 @@ void etMessageService_execute(etMessageService* self){
etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
- etInt16 lowWaterMark = self->messageBuffer.maxBlocks - etMessageQueue_getHighWaterMark(&self->messageQueue);
+ etInt16 lowWaterMark = etMessageQueue_getLowWaterMark(&self->messagePool);
ET_MSC_LOGGER_SYNC_EXIT
return lowWaterMark;
}

Back to the top