Quality RTOS & Embedded Software

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


queue priority

Posted by ranco9 on March 25, 2015


I am new to RTOS and looking for best way to implement the next:

Allowing permission to write to a queue with no interruptions (writing packets) and a first come first served policy (no matter the task priority) While waiting for the permission the task should be blocked

What do you think?

Thanks & Best Regards Ran

queue priority

Posted by rtel on March 25, 2015

I'm afraid I don't understand your requirements. Are you talking about FreeRTOS queues? So writing to the queue using xQueueSend()? If so then any task can write to the queue, but only the highest priority task will be running, so the highest priority task will always write first. Assuming you are writing to the back of the queue (xQueueSend() or xQueueSendToBack()) then the queue will act as a FIFO. Data will come out in the same order it went in. As far as ready from the queue - if more than one task is attempting to read from the queue it is always the highest priority task that will read first.

Does that answer the question?


queue priority

Posted by ranco9 on March 25, 2015


Thank you for your kind help

Yes i am talking about freeRTOS queue so using xQueueSend() but i would like to limit writing to it to only one task at a time at a first come first serve priority regardless of the task priority

To use an analogy, same as in a bank with one casheer, you can deposit only when its your turn and no cutting in line regardless your "priority" :)

Thanks again Ran

queue priority

Posted by rtel on March 25, 2015

The queue handles all mutual exclusion issues for you - you do not need to worry about more than one task trying to access the queue at the same time. As far as which task will actually write to the queue - that is handled by the priority of the task. The scheduler will always run the highest priority task that is able to run - if that task is writing to a queue then the write will effectively be atomic - that is - it can't be interrupted by another task writing to the same queue.

queue priority

Posted by ranco9 on March 26, 2015

Thanks again

Queue is wrriten packets so i am guessing the mutual exclusion won't work. I guess i will use a binary semaphore to restrict access and forgo the "first come first served" requirement and leave it to the task priority

Best Regards, Ran

queue priority

Posted by davedoors on March 26, 2015

Mutual exclusion will always work for a single queue write. Are you wanting mutual exclusion across more than one write, so you want a task to write to the queue say 5 times without another task writing? Can you post a code snippet so we can understand better what you want to do.

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

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

Latest News

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