How do I notify a freeRTOS Task that a global variable or Mailbox has changed?

For my example, I have 3 tasks; UserInterfaceTask.c, WorkerTask.c and ControllerTask.c. When a user pushes a button the UserInterfaceTask detects it and sends a Queue message to the ControllerTask as a command with parameter and value. The ControllerTask then updates a global Mailbox which any tasks, including WorkerTask.c can access via xQueuePeek() however how do I notify the WorkerTask that a new value has been changed by ControllerTask using xQueueOverwrite()? My WorkerTask is polling, so is it acceptable to poll xQueuePeek() every 1 or 2ms or is there a cleaner way to be notified of changes to global variable or mailbox values?

Thank you!

For a task to get notified of an event immediately it needs to be blocked on whichever mechanism the event is sent through - otherwise it can only poll for the event, no matter what the event is. There isn’t an equivalent of a “signal” in unix, which is sort of a method of interrupting a thread.

Ok, thanks for the info. I plan on using TaskNotify and setting TaskNotification value bits to flag two types of notifications. If it’s a ‘type=1’, than the receiving task will know to peek at mailbox values which have changed. If it’s a ‘type=2’, than the task will run it’s work. Is this a good approach or should I just use a Queue? I rather not incur the overhead queues bring.

Thanks!

Seems okay approach to me - since you are setting bits, just make sure to test bits (i.e. the value 3 may also be valid where both the notification are received before they are processed).

Ok, thanks, I’ll try this out today. In this case, I can use the bit flags as the ‘command byte’ of my communication protocol, and the mailbox as my ‘packet payload’, with no need to poll global variables. Thx.