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

Remaining time after call taskYield

Posted by juankike11 on September 23, 2016

Hello everyone,

I have a doubt using taskYIELD() in FreeRTOS, after calling this function what happend with the execution time, I mean if the tick doesn't finish yet. Maybe I don't have very clear how the FreeRTOS works, but I assume some things:

-The remaining time is used in the Idlehook until the tick ends and then the next task ready is executed -Imediatley the next task ready is executed

Also I have the doubt if every task is executed just during one tick or if can be executed more than one tick. I say this because in my aplication I can't waste too much time, although I'm not very sure of how much time my critical task takes in make a calculation I think it would take some considerable time.

Regards, Juan.


Remaining time after call taskYield

Posted by richard_damon on September 23, 2016

When a task calls taskYIELD(), the current task is moved to the back of the ready queue of its current priority, and then the schedule finds the highest priority task that is ready and starts it. That might be the task that called taskYIELD() if there are no other ready task of the same (or possible higher) priority available.

When you have FreeRTOS running with Preemption turned on (which I would think is normal) then every timer tick, the system effectively does a taskYIELD() for the currently running task (unless the scheduler has been disabled) which says that if another ready task exists of the same prioirty, they will trade execution back and forth each timer tick. A lower priority task will only get a chance to execute if all the higher priority tasks are blocked waiting on something (time, a queue, a semaphore, etc). If a higher priority task becomes ready, and preemption is on, then the current task will be suspended and the higher task will procceed.

With preemption turned on, the fundamental rule is that the running task will always be the highest priority task that is ready, and multiple ready tasks of the same priority will execute round robin, switching every timer tick.

With preemption off, a higher priority task or same priority task will need to wait for the current task to yield, letting the scheduler find the new highest priority task.

One key thing to remember, is that, except for priority 0 tasks (IDLE priority) all tasks should be blocking for something at times or the lower priority tasks will get starved for time. And prioriry 0 tasks should either yield at times or you need to have preemption turned on.


Remaining time after call taskYield

Posted by juankike11 on October 20, 2016

Thanks Richard

Your explanation is pretty clear and you have solved another doubt I had


[ 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