Quality RTOS & Embedded Software

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




Loading

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.

Thanks.

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.

Regards.

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 ]    [ Sitemap ]    [ ]




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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