FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2009 Threads] PIC18F4550, taskYIELD() and queueing brokenPosted 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 brokenPosted 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 brokPosted by Richard on March 23, 2009 Could it simply be a stack overflow?
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|