Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Clearing a counting semaphore.

Posted by Corey Paye on 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.


RE: Clearing a counting semaphore.

Posted by Richard on 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.


RE: Clearing a counting semaphore.

Posted by Corey Paye on August 31, 2012
Thanks for the feedback. What you say makes sense. Unfortunately I cannot change RTOS versions at this point.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner