Multiple events management
Posted: Mon Apr 08, 2019 6:35 pm
Hello,
I just want to make sure I got it right with events.
I have the following code:
Basically the above thread waits for two different events broadcast from other threads and processes them with two handlers.
My question is the following: is it right that, should the two events be broadcast at the same time, the two event handlers will be called one after the other? IOW, if, for example, both handlers access the same UART to send some data, canI avoid protecting such access with a mutex in order not to mess the two transmissions?
Thanks in advance.
Alberto
I just want to make sure I got it right with events.
I have the following code:
Code: Select all
static void sendNlsPktHandler(eventid_t id);
static void sendNhsPktHandler(eventid_t id);
static THD_FUNCTION(serialThread, param) {
(void) param;
static const evhandler_t evhndl[] = {
sendNlsPktHandler,
sendNhsPktHandler,
};
event_listener_t el_nls;
event_listener_t el_nhs;
chRegSetThreadName("SERIAL");
chEvtRegister(&dispatcher_event_nls, &el_nls, 0);
chEvtRegister(&dispatcher_event_nhs, &el_nhs, 1);
while(TRUE) {
chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, TIME_MS2I(500)));
}
}
Basically the above thread waits for two different events broadcast from other threads and processes them with two handlers.
My question is the following: is it right that, should the two events be broadcast at the same time, the two event handlers will be called one after the other? IOW, if, for example, both handlers access the same UART to send some data, canI avoid protecting such access with a mutex in order not to mess the two transmissions?
Thanks in advance.
Alberto