Quality RTOS & Embedded Software

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


Loading

Preemptive Scheduling and Task Priorities

Posted by dnewby on February 7, 2017

| 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?


Preemptive Scheduling and Task Priorities

Posted by dnewby on February 10, 2017

Anybody?


Preemptive Scheduling and Task Priorities

Posted by rtel on February 10, 2017
I have answered this already but the reply does not seem to have shown up. I will answer again when I'm at my computer.



Preemptive Scheduling and Task Priorities

Posted by rtel on February 10, 2017

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.


Preemptive Scheduling and Task Priorities

Posted by dnewby on February 10, 2017

I'm having trouble finding the code that actually puts the current task back in the ready queue when this occurs. Any hints?


Preemptive Scheduling and Task Priorities

Posted by rtel on February 10, 2017

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.


[ 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.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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.


Careers

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

Renesas

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