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



Posted by Eduardo Goncalves on March 25, 2009
strangely enough the first macro to be called is:


I saw the code of
void vTaskSwitchContext( void ) in tasks.c and in fact the _OUT macro is called at the begin and the _IN at the end.

Any reason for this?
Shouldn't at least a call to the _IN macro be missing when the task is put to run for the very first time?



Posted by Richard on March 25, 2009
traceTASK_SWITCHED_OUT() should be called first. When SWICTHED_OUT is called pxCurrentTCB points to the TCB of the task that was running prior to the context switch. When SWITCHED_IN is called pxCurrentTCB points to the TCB of the task that is selected to run when next.



Posted by Fredrik Liljenvall on September 11, 2012

But the very first task will not be preceeded by an SWITCHED_IN call, I think it would be good to get an call also before the first task is started, this way i can measure the execution time of the first run for the first task aswell.

Best Regards
Fredrik Liljenvall


Posted by Richard on September 11, 2012
The scheduler is started from the port layer - that is - the code that is not common to every microcontroller. It would not be easy to go through all 31 ports and update the code to make a call to the SWITCHED_IN macro.

You know which task is running first, because the SWITCHED_OUT macro that gets called first will tell you. The only information you are missing is the exact time the first task executed for. It would be easier to get this by adding in a new macro in vTaskStartScheduler(). The new macro could then be used to start the run time stats counter - if it was already running before the scheduler started. Please add a feature request in the SourceForge feature request tracker if you would like that added.



Posted by Fredrik Liljenvall on September 13, 2012
Hi Richard,

Thanks for the reply,

I was thinking that adding a traceTASK_SWITCHED_IN(); macro just before xPortStartScheduler() is called inside the generic vTaskStartScheduler code.

Works good when i test it,

I will add an feature request for it or i can send an patch if you want?

Best Regards Fredrik

[ 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