Clearing a counting semaphore.

cmp1104 wrote on Friday, August 31, 2012:

I am using Free RTOS v7.02 and am relatively new to it.  I am considering using a counting semaphore as a way of counting the number of interrupts that occur in a fixed period of time.  However there is a chance that I cannot “take” all of the accumulated semaphore counts before a separate part of the program takes over.  Is there a way to clear the accumulated counts?  Deleting the semaphore would not work because a task will be blocked on it.  I know that the queue management api has a “QueueReset” function but I could not find anything similar in the semaphore/mutex api.

Thanks.

rtel wrote on Friday, August 31, 2012:

You can pass your semaphore handle into the queue reset function.  Just cast the xSemaphoreHandle to an xQueueHandle if the compiler generates a warning about the type mismatch.

However, xQueueReset() was only introduced in V7.1.1, and even then it will not let you reset a queue/semaphore when tasks are blocked on it.  V7.2.0 will allow queues that have tasks blocked on them to be reset.

Regards.

cmp1104 wrote on Friday, August 31, 2012:

Thanks for the feedback.  What you say makes sense.  Unfortunately I cannot change RTOS versions at this point.