Small addition for event_wait_timeout()

Topics related to events, messages or semaphores

Small addition for event_wait_timeout()

Postby Purple » Sat Aug 05, 2017 8:29 pm


Sometimes it can be useful to know with event_wait_timeout() if the actual event occurred, or if it timed out. For that, I've added a few lines of code which return the timeout value with event_get_timeout(). If the returned value is 0, the event timed out, otherwise the event occurred. This also allows one to keep track of how long it took for an event to arrive, if this is of interest. The code additions:

Code: Select all
in: os_applAPI.h

+/* Get the timeout value from the task when we wait for an event with timeout.            */
+/* That way we know if this is due to a timeout (value == 0)  or actual event (value != 0 */
+#define event_get_timeout()                   OS_GET_TASK_TIMEOUT_VALUE()

in: os_event.h
+#define OS_GET_TASK_TIMEOUT_VALUE()  os_task_timeout_get(running_tid)
in: os_task.c

+/* Use this to differentiate between event timeout or not */
+uint16_t os_task_timeout_get( uint8_t tid ) {
+    return task_list[ tid ].time;

Sorry, don't have proper patches against the code, but it's straight forward anyway... Hope it can be useful form someone else.

Posts: 1
Joined: Thu Jul 20, 2017 12:16 am

Return to Events, Messages and Semaphores

Who is online

Users browsing this forum: No registered users and 1 guest