Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jung2014-12-09 11:15:15 -0500
committerThomas Jung2014-12-09 11:15:15 -0500
commit91beff52d7a0c52390b17dcdfe2a37cb00a34fc4 (patch)
tree55018500573aa37f593ccd2bda8e52fa84b4060c /runtime/org.eclipse.etrice.runtime.c/src/common/messaging
parentf98dcd973aa82ad5064f93f288c65dc603860940 (diff)
downloadorg.eclipse.etrice-91beff52d7a0c52390b17dcdfe2a37cb00a34fc4.tar.gz
org.eclipse.etrice-91beff52d7a0c52390b17dcdfe2a37cb00a34fc4.tar.xz
org.eclipse.etrice-91beff52d7a0c52390b17dcdfe2a37cb00a34fc4.zip
etrice.runtime.c Interrupt included
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/common/messaging')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c43
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h32
2 files changed, 64 insertions, 11 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 346e199a1..196c5be40 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
@@ -54,6 +54,9 @@ void etMessageService_init(
etMutex_construct( &(self->queueMutex) );
etSema_construct( &(self->executionSemaphore) );
+ /* init high prio functions */
+ self->highPrioFuncRoot=NULL;
+
/* init thread */
etThread_construct(&self->thread, stacksize, priority, "MessageService", (etThreadFunction) etMessageService_deliverAllMessages, self);
@@ -165,16 +168,54 @@ void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buf
ET_MSC_LOGGER_SYNC_EXIT
}
+void etMessageService_registerHighPrioFunc(etMessageService* self,etHighPrioFunc *func){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "registerHighPrioFunc")
+ func->next=self->highPrioFuncRoot;
+ self->highPrioFuncRoot=func;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_unregisterHighPrioFunc(etMessageService* self,etHighPrioFunc *func){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "unregisterHighPrioFunc")
+ etHighPrioFunc *highPrioFunc;
+ if (self->highPrioFuncRoot==func){
+ self->highPrioFuncRoot=self->highPrioFuncRoot->next;
+ }else{
+ highPrioFunc = self->highPrioFuncRoot;
+ while(highPrioFunc != NULL){
+ if (highPrioFunc->next==func){
+ highPrioFunc->next=highPrioFunc->next->next;
+ break;
+ }
+ highPrioFunc=highPrioFunc->next;
+ }
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+static void etMessageService_callHighPrioFunc(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "callHighPrioFunc")
+ etHighPrioFunc *highPrioFunc;
+ highPrioFunc = self->highPrioFuncRoot;
+ while (highPrioFunc != NULL){
+ (*(highPrioFunc->func))(highPrioFunc->param);
+ highPrioFunc=highPrioFunc->next;
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
static void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
{
etBool cont = ET_TRUE;
while (cont){
+ etMessageService_callHighPrioFunc(self);
while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
etMessage* msg = etMessageService_popMessage(self);
if (!self->msgDispatcher(msg))
cont = ET_FALSE;
etMessageService_returnMessageBuffer(self, msg);
+ etMessageService_callHighPrioFunc(self);
}
if (cont)
etSema_waitForWakeup(&self->executionSemaphore);
@@ -204,3 +245,5 @@ static void etMessageService_timerCallback(void* data) {
}
ET_MSC_LOGGER_SYNC_EXIT
}
+
+
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 cd729b9a5..7a7110ad1 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
@@ -52,18 +52,25 @@ typedef struct etBuffer{
etUInt16 blockSize; /**< size of blocks for the message pool */
} etBuffer;
+typedef struct etHighPrioFunc etHighPrioFunc;
+struct etHighPrioFunc{
+ void (*func)(void *);
+ void * param;
+ etHighPrioFunc *next;
+};
+
typedef struct etMessageService {
- etMessageQueue messageQueue; /**< message queue that holds all used messages */
- etMessageQueue messagePool; /**< message pool that holds all free messages */
- etBuffer messageBuffer; /**< information about the message buffer that holds information about
- the actual memory position and size for the message pool */
- etDispatcherReceiveMessage msgDispatcher; /**< function pointer to the generated message dispatcher function */
- etThread thread; /**< thread for the execution of the message service */
- etMutex poolMutex; /**< mutex for synchronizing the access to the message pool */
- etMutex queueMutex; /**< mutex for synchronizing the access to the message queue */
- etSema executionSemaphore; /**< semaphore for waiting and waking up the execution */
- etTimer timer; /**< timer for cyclic calls */
- etMessageService_execmode execmode; /**< execution mode*/
+ etMessageQueue messageQueue; /** message queue that holds all used messages */
+ etMessageQueue messagePool; /** message pool that holds all free messages */
+ etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
+ etDispatcherReceiveMessage msgDispatcher; /** function pointer to the generated message dispatcher function */
+ etThread thread; /** thread for the execution of the message service */
+ etMutex poolMutex; /** mutex for synchronizing the access to the message pool */
+ etMutex queueMutex; /** mutex for synchronizing the access to the message queue */
+ etSema executionSemaphore; /** semaphore for waiting and waking up the execution */
+ etTimer timer; /** timer for cyclic calls */
+ etMessageService_execmode execmode; /** execution mode*/
+ etHighPrioFunc *highPrioFuncRoot;
} etMessageService;
/**
@@ -166,5 +173,8 @@ void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buf
*/
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);
#endif /* RMESSAGESERVICE_H_ */

Back to the top