Quality RTOS & Embedded Software

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




Loading

How to repeat xQueueSendToBack atomically?

Posted by Owen on December 2, 2011
Hi all,

In my FreeRTOS project, I want to post several messages to queues (from task) without the possibility of a task switching until after the group of sends. I have implemented it using vTaskSuspendAll, but this appears not to work.
Here is pseudo-code of the section (which is called from a task not ISR):

vTaskSuspendAll();
for (i = loop through routing table)
{
if (route exists)
{
os_err = xQueueSendToBack( queue, &blockToSend_p, 0 );
num_routes++;
}
}
blockToSend_p->num_references = num_routes;
xTaskResumeAll();

At xTaskResumeAll I have a situation that the highest prio task shown as READY in StateViewer is *not* the one that is scheduled next.
I am aware that the FreeRTOS documentation for vTaskSuspendAll/xTaskResumeAll specifies not to use certain RTOS calls including xQueueSendToBack while suspended; however my understanding is that one may not make calls with potential to block. Using delay 0 in 'send' ensures the call does not block. What should I concluded from the unexpected sheduling behaviour?
A. I've used the wrong design.
B. It's the right design, but a stack overflow is breaking the RTOS.
I tried placing a taskYeild() after xTaskResumeAll() but it did not fix my crashes.
Should I consider using xQueueSendToBackFromISR from task in order get queue-but-don't-reschedule behaviour?
My setup: STM32F103, FreeRTOS 7.0.2, IAR EWARM 5.30 with StateViewer plugin.

Many thanks for your suggestions.

Owen

RE: How to repeat xQueueSendToBack atomically?

Posted by Dave on December 3, 2011
I'm not sure if xQueueSendToBack() can be used when the scheduler is suspended, it might even depend on the port being used, but if it says not to do it then it is probably best not to.

As an alternative, try temporarily raising the priority of the task doing the sends to be above any of the tasks doing the receives, then when all the sends are complete, drop the priority back down again and the receive tasks can then run.

RE: How to repeat xQueueSendToBack atomically?

Posted by Owen on December 8, 2011
Thank you for that suggestion.

I had
#define configUSE_PREEMPTION0

and this may have been the issue, but the build has other bugs that are not yet resolved.
So I will report back a solution when the other bugs are fixed.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists