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] [February 2017 Threads]
| TaskName | Priority | State
| ---------- | ------ | ------
| TaskL1 | 1 | RUN
| TaskL2 | 1 | RDY
| TaskH1 | 2 | BLOCKED
I am seeing the following behavior:
TaskH1 becomes ready.
TaskL1 is preempted and sent to the back of the Priority 1 Task Queue.
TaskH1 completes processing and blocks.
TaskL2 is set to RUN.
TaskH1 becomes ready.
TaskL2 is preempted and sent to the back of the Priority 1 Task Queue.
TaskH1 completes processing and blocks.
TaskL1 is set to RUN.
So, in effect, if we have the higher priority task running at a specific interval, and two lower (shared) priority tasks that are both ready to run, every time we switch to the high priority task, the lower priority tasks will swap RUN/RDY after the high priority task completes.
The desired functionality is that if the lower priority task is preempted, it will regain control of the processor after the higher priority task completes, whereas if it relinquishes control of the processor voluntarily, then tasks with the same priority will be able to run.
The current functionality is that it will not regain immediate control of the processor if it is forcibly preempted.
Is there configuration options available to get the desired functionality?
The behaviour you describe is that intended. Tasks of equal priority are scheduled in a round robin fashion, so the task that has been waiting the longest is the task that is scheduled next. You can turn time slicing off, but that won't change the behaviour you are describing, it will just prevent a switch between equal priority tasks on a tick interrupt. What is desired by one application writer is not necessarily by another. The code that selects the next task to run is designed to be as small as possible, there are all sorts of alternative, but they would all take extra time to execute.
I'm having trouble finding the code that actually puts the current task back in the ready queue when this occurs. Any hints?
The task never leaves the ready list - hence you can't find the code
that puts it back in :o) The pxCurrentTCB point just points to it
within the ready list.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.