Quality RTOS & Embedded Software

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


Message queues - how to determine size of queue task?

Posted by groger57 on October 26, 2015


I posted a few days ago about using a message queue, someone posted a response and it helped solve the issue. I now have the message queue working just fine. It's getting messages as I can print out the value passed in in the task handler.

The task handler calls a function to update flash memory. It has a mutex around the call to write. In creating the task handler, I initially set the size to 120 bytes. However, it was causing a WDT reset when the queue handler called the memory update function. After setting the handler size to 180 bytes on the task creation, it is OK.

I would rather understand what the right approach is to setting the task size. Can someone explain how to establish this?

Thanks! Gary

Message queues - how to determine size of queue task?

Posted by rtel on October 26, 2015

Are you referring to the size of the stack?

The stack requirements are determined by your program (how many automatic variables you have, how deep the function call nesting is, etc.) and the compiler options (the higher the compiler optimisation the less stack it will use in most cases). You can calculate this in the same way you would calculate it for a non RTOS (bare metal) application.

However, a pragmatic approach is to use the stack overflow checking (http://www.freertos.org/Stacks-and-stack-overflow-checking.html) feature to know when the stack is too small, and the stack high water mark queries (http://www.freertos.org/uxTaskGetStackHighWaterMark.html) to know how much you have actually used - then you can just tune it accordingly.


Message queues - how to determine size of queue task?

Posted by groger57 on October 28, 2015


Yes, referring to stack size set in the individual tasks. Thank you, and I will do some reading and testing to understand this.

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

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

Latest News

Meet Richard Barry and learn what's new in the FreeRTOS project at Embedded World 2019

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

Version 10.1.1 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