Quality RTOS & Embedded Software

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


Loading

How to know where my tasks are waiting

Posted by Sergio Sider on April 23, 2010
Hi All,

I did not find or was unable to find this info...

I have an application using several tasks of the same priority using/waiting for Mutexes. I was debugging for hours and then, two or more tasks stopped wainting for something. I am sure it's a deadlock of badly using those Mutexes.
But that's not the main problem.

What is the way to know where in the task, the task is stopped ? and what resource is it waiting for ?
My tasks are quite complex and could have stopped in several points and waiting for different resources (mutexes).

I am using Eclipse, codesourcery and Jlink debugger.. I can't stop and run the program (only one task is running), but I could not figure out by myself where the tasks are stopped.

Thanks for any help!!
Regards,
Sergio Sider


RE: How to know where my tasks are waiting

Posted by MEdwards on April 25, 2010
You can get this information from the Eclipse FreeRTOS plug in, which is a free download. Go to http://www.highintegritysystems.com and follow the links to the downloads.

RE: How to know where my tasks are waiting

Posted by Sergio Sider on April 25, 2010
Hi edwards,

I have the plugin, and now I registered my Mutexes in the FreeRTOS registry so I can see them in the "Queue Table" tab.

I found that the plugin shows the mutex name in the "Event Object" column of the task that appears to have gained the Mutex. It looks like a "dedly embrace", but I still do not know where in the program the tasks are waiting.
I suppose it's possible to find this info in the stack of the task or in another place, but did not figured out.

I could, and I probably will, put some debug routines to help me find it, but it would help a lot in the future to know how to go directly to the "offending line" of the task.

Regards,
Sergio.

RE: How to know where my tasks are waiting

Posted by MEdwards on April 25, 2010
Something else you can do is provide some trace macros. Take a look at http://www.freertos.org/rtos-trace-macros.html then search through queue.c for the word "trace". You can log when a task takes or gives a semaphore, so when your crash happens you know what the task did last.

RE: How to know where my tasks are waiting

Posted by Juha Kuusama on April 26, 2010
The simple approach: Use global variables. There are not that many points where your tasks could be stuck, so looking the value of the global volatile variable of task1tracepoint in a debugger should be informative.

RE: How to know where my tasks are waiting

Posted by Sergio Sider on April 26, 2010
Hi guys,

Thanks for the suggestions. Actually I found the bug that caused the deadly embrace (and it was not a deadly embrace... was a deadly stupidity: the same task was trying to get a Mutex already taken by itself... :-( )

I don't want to sound whinny, but it would be great to have the knowledge to get the "Program Counter" of a blocked task.

Thanks again,
Sergio.

RE: How to know where my tasks are waiting

Posted by Dave on April 26, 2010
FreeRTOS also supports recursive semaphores, if that would help?

RE: How to know where my tasks are waiting

Posted by Richard Damon on April 26, 2010
sergioside, you will probably find that the "Program Counter" that the task last suspended at isn't all that useful, as the main thing this will tell you is which api function suspended the task, but not information about where in the task that call was, or which object (Semaphore, etc) it was called on. That would require a much more complicate parsing of the stack, or saving additional information somewhere task specific.

RE: How to know where my tasks are waiting

Posted by Sergio Sider on April 28, 2010
Hi All,

Thanks for your help!

Now, I am convinced that the "program counter" idea is problematic and debugging techniques are the way to go in that case ;-)

Regards,
Sergio.


[ 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