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

finding the task that is running at a given time

Posted by juhc on July 13, 2015

Hi,

Is there a function in Freertos that indicates the task that was running before a given task and the task that will run after it? To be more clear, if the task that is running now is T, can I kow the task that was running before T and the task that will run after T ?

Thank you


finding the task that is running at a given time

Posted by bradgoold on July 13, 2015

Hi, I haven't used the trace facility, but I'm sure that it may do what you require. Check the freeRTOS documentation online for useTraceFacility examples. Brad


finding the task that is running at a given time

Posted by rtel on July 13, 2015

You can determine the task that ran last by adding something like the following to the bottom of FreeRTOSConfig.h.

/* Define xLastTask in a C file somewhere. */
extern TaskHandle_t xLastTask;

#define traceTASK_SWITCHED_OUT() if( xLastTask != pxCurrentTCB ) xLastTask = pxCurrentTCB

Then the handle of the previous task will be stored in xLastTask.

You cannot determine which task will run next, as FreeRTOS doesn't even know that. For example, tasks are often unblocked by an interrupt, and there is no way of knowing which tasks will be unblocked when.

You do know that FreeRTOS will always run the highest priority task that is in the Ready state, and if there is more than one such task at the same priority, then it will run the one that has been in the Ready state the longest since it last executed.

Regards.


finding the task that is running at a given time

Posted by juhc on July 14, 2015

Thank you for your reply.

I added the definition of traceTASKSWITCHEDOUT() like you said and I defined xLastTask at the beginning of the file tasks.c

But when I compile, I get an error : "undefined reference to xLastTask" on the call of the function traceTASKSWITCHEDOUT(). Is it because I defined xLastTask in the wrong place? If so, where should I define it?


finding the task that is running at a given time

Posted by davedoors on July 14, 2015

The post two above is not clear. xLastTask must be declared in a c file and extern in FreeRTOSConfig.h.

In a C file - TaskHandle_t xLastTask;

In FreeRTOSConfig.h - extern TaskHandle_t xLastTask;


finding the task that is running at a given time

Posted by juhc on July 14, 2015

Yes I did this first but I had the error "unknown typename TaskHandlet" in FreeRTOSConfig.h. The type TaskHandlet is defined in task.h so I thought I can't use it in FreeRTOSConfig.h

So I put the extern in the C file and I got "undefined reference to xLastTask"


finding the task that is running at a given time

Posted by rtel on July 14, 2015

Try adding

#include "task.h"

immediately above where TaskHandle_t is used, that way the type should be defined in each file in which FreeRTOSConfig.h is included.

Regards.


finding the task that is running at a given time

Posted by juhc on July 14, 2015

When I add this, I get a lot of new errors


[ 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