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

PIC18F4550, taskYIELD() and queueing broken

Posted by Giorgis Georgakoudis on March 23, 2009
I'm using the FreeRTOS v5.0.0 with a PIC18 mcu and the MPLAB building toolchain.

I have two tasks, with the same priority (tskIDLE_PRIORITY + 1). Task T1 sends a message every two seconds (using vTaskDelayUntil) to a Queue and Task T2 receives this message from the Queue using a blocking xQueueReceive (meaning porTMAX_DELAY is used as blocking time and vTaskSuspend support is enabled) and sends it over the serial.

System hangs for some reason Monitoring what happens the execution sequence until system stops is:

1) T2 starts execution and blocks waiting for a message to arrive at the Queue
2) T1 starts execution, successfully waits for two seconds and then calls XQueueSend

System is hanged!

I've pinpointed the problem on using taskYIELD() inside the critical section of xQueueGenericSend(). When T2 is removed from the event list, xTaskRemoveFromEventList() returns pdTRUE because both tasks have the same priority (it's supposed to return true if the unblocked task has higher priority but it works the same way for equal priorities too). The taskYIELD() following for some reasons fails. Any ideas? I'm still looking out why this is happening. If I comment out taskYIELD() everything works fine.

ggeorgak

RE: PIC18F4550, taskYIELD() and queueing broken

Posted by Samuel Tardieu on March 23, 2009
Just to answer the part on trying to switch to the receiving task when it has the same priority as the sending task: I wouldn't want to second-guess Richard's intent here, but this is probably just an optimization (which is also done in the Erlang language runtime when one Erlang process sends a message to another one if I remember correctly). If two tasks do have the same priority, the scheduler is free to choose which one to execute. If one of them is trying to get a message from a queue, it is often more efficient to schedule it so that one place in the queue can be freed.

This optimization reduces the chance of later having a higher priority task block because it wants to write into the queue, thus causing a priority inversion. It's generally best to have empty queues than full ones.

RE: PIC18F4550, taskYIELD() and queueing brok

Posted by Richard on March 23, 2009
Could it simply be a stack overflow?

Regards.


[ 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