Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2013-01-04 19:00:51 -0500
committerThomas Schuetz2013-01-04 19:00:51 -0500
commiteb28454f2975f5747427be583bfc89b0796265d4 (patch)
tree7a2660cf67bfa629673da0243da42d973ffeebb0 /runtime/org.eclipse.etrice.runtime.c
parentd098da1cde5c178c682c57533e514b3e4976250e (diff)
downloadorg.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.tar.gz
org.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.tar.xz
org.eclipse.etrice-eb28454f2975f5747427be583bfc89b0796265d4.zip
[runtime.c , generator.c.reference] added src-gen folder with reference
code, synchronization for push and pop Change-Id: I03ca0251e622d862a34cfabc00dd615af7228160
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c20
1 files changed, 16 insertions, 4 deletions
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 59e205e99..d602edb65 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
@@ -83,13 +83,18 @@ void etMessageService_initMessagePool(etMessageService* self){
void etMessageService_pushMessage(etMessageService* self, etMessage* msg){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "pushMessage")
+ etMutex_enter(&self->queueMutex);
etMessageQueue_push(&self->messageQueue, msg);
+ etSema_wakeup(&self->executionSemaphore);
+ etMutex_leave(&self->queueMutex);
ET_MSC_LOGGER_SYNC_EXIT
}
etMessage* etMessageService_popMessage(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "popMessage")
+ etMutex_enter(&self->queueMutex);
etMessage* msg = etMessageQueue_pop(&self->messageQueue);
+ etMutex_leave(&self->queueMutex);
ET_MSC_LOGGER_SYNC_EXIT
return msg;
}
@@ -97,6 +102,7 @@ etMessage* etMessageService_popMessage(etMessageService* self){
etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessageBuffer")
+ etMutex_enter(&self->poolMutex);
if (size<=self->messageBuffer.blockSize){
if (self->messagePool.size>0){
etMessage* msg = etMessageQueue_pop(&self->messagePool);
@@ -104,22 +110,28 @@ etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 si
return msg;
}
}
+ etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
return NULL;
}
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer")
+ etMutex_enter(&self->poolMutex);
etMessageQueue_push(&self->messagePool, buffer);
+ etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
}
void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
- while (etMessageQueue_isNotEmpty(&self->messageQueue)){
- etMessage* msg = etMessageService_popMessage(self);
- self->msgDispatcher(msg);
- etMessageService_returnMessageBuffer(self, msg);
+ while (TRUE){
+ while (etMessageQueue_isNotEmpty(&self->messageQueue)){
+ etMessage* msg = etMessageService_popMessage(self);
+ self->msgDispatcher(msg);
+ etMessageService_returnMessageBuffer(self, msg);
+ }
+ etSema_waitForWakeup(&self->executionSemaphore);
}
ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top