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

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