Quality RTOS & Embedded Software

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


Queues and Semaphores

Posted by Bonanza35 on January 7, 2009

We're in a severe RAM crunch on a project, and are looking for ways to free up some RAM. There are some places where queues are used where they aren't really needed, and semaphores would work just as well. So, I started looking at the effects of replacing a few queues with semaphores.

Then I discovered that a semaphore is just another kind of queue, and the memory overhead is the same (76 bytes, IIRC).

Isn't there a better way to implement semaphores that won't use up quite as much memory?

RE: Queues and Semaphores

Posted by MEdwards on January 7, 2009
There it is just a trade off between ROM and RAM. Semaphores are implemented so they add nothing to the code size by reusing the queue. Semaphores are free as far as ROM is concerned.

Most of the RAM overhead is part of the event control. That is how the tasks are blocked and unblocked. Some RTOS use separate semaphore and event control structures, but add the two together and there is the same usage.

RE: Queues and Semaphores

Posted by Dmitriy A. Cherepanov on January 8, 2009
Year ago I had such question too. And I had try to write a binary semaphore.
You can see it on http://freertos.narod.ru/.

It use less ram. Actually it consist only from one List. This mean that xList == xMySemaphoreImplementationStructure.

It is a pity but I did not test it very well, but this variant of semaphores worked in PC demo tests instead of original variant. So you can try to use it. May be Richard or somebody else will do some attention to this sources.

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

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

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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

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