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

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