FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2010 Threads] get current task namePosted by Martin Velek on March 5, 2010 Is it possible to get current task name in a user application? In the task.c is stated tskTaskControlBlock.pcTaskName is for debugging only but it is not surrounded by any #if .... #endif. So it exists all the time. I have tried to do extern tskTCB pxCurrentTCB but the struck tskTCB is defined only in task.c and is not exported. If possible I would like not to do some kernel hacks(modify kernel files).
Thank you for your help. Martin
RE: get current task namePosted by Richard Damon on March 5, 2010 The variable is declared static, so it can not be accessed outside that file. if you add a #define portREMOVE_STATIC_QUALIFIER to FreeRTOSConfig.h then the static will be removed and it will be accessable.
RE: get current task namePosted by Martin Velek on March 5, 2010 Thanks, but still no success.
line 191: extern tskTCB pxCurrentTCB;
../uEZ_SRC/Source/RTOS/uEZRTOS_FreeRTOS.c:191: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pxCurrentTCB' ../uEZ_SRC/Source/RTOS/uEZRTOS_FreeRTOS.c:191: error: 'pxCurrentTCB' undeclared (first use in this function) ../uEZ_SRC/Source/RTOS/uEZRTOS_FreeRTOS.c:191: error: (Each undeclared identifier is reported only once ../uEZ_SRC/Source/RTOS/uEZRTOS_FreeRTOS.c:191: error: for each function it appears in.)
I do not want to copy struct tskTCB to uEZRTOS_FreeRTOS.c because the FreeRTOS can change in the future and I would have to maintain two files. Maybe a feature request?
RE: get current task namePosted by Richard on March 5, 2010 “line 191: extern tskTCB pxCurrentTCB” I'm not sure what I can add to that, other than it looks like it doesn't know what the tskTCB type is. Is uEZRTOS_FreeRTOS.c the FreeRTOS implementation of the uEZ RTOS abstraction? Regards.
RE: get current task namePosted by Richard Damon on March 5, 2010 The problem is that FreeRTOS hides the definitions of its structures in the c files, for data hiding. A way to fix this and allow selected user files to be able to see the structure information, while still keeping the hiding for most user files, would be to move the structure definition to the header files, but use a preprocessor definition to control whether the structure is defined with details or opaquely. The FreeRTOS files would define this definition, and any use file that for debugging needed it could define it, but the reset get the void* typedef.
I do something like this in the version I use. To help with updating, I didn't remove the definition from the c files, just bracketed it with #if 0 and #endif, that way when I diff the current code with the old, I can detect any changes in the data structures and move the changes over. Perhaps I should clean up how I do this and submit it to Richard as a suggested improvement.
I understand that the current method being used grew out of a need to support a number of somewhat broken C compilers (the embedded market is know for this problem, many chips with smaller market share don't generate enough interest for the manufactures to get a fully working compiler up, so they often don't support the full language). Technically, the technique used invokes undefined behavior, since the prototype used by the user code passes void* pointers, but the functions are declared with struct* pointers, which are not guaranteed by the language to look the same, but for practical purposes will be as long as the machine is inherently "byte addressable", which all the target processors are.
RE: get current task namePosted by Preet Kang on March 9, 2010 You can add a function : void getTaskName(char* name) { strcpy(name, pxCurrentTCB->taskname); }
at tasks.c and task.h
Preet
RE: get current task namePosted by Martin Velek on March 9, 2010 Thank you Preet, a similar function exist in my project. However my FreeRTOS upgrade procedure consist of copying files if the new version is declared backward compatible. It is hard to keep track. Currently I have only one line at the end of tasks.c, #include "FreeRTOSExtensions.c" and function prototype is in the FreeRTOS.h. I think that both way are not the right solution to the future.
Martin
RE: get current task namePosted by Preet Kang on March 9, 2010 Martin, Try one of these (they both compiled fine on my GCC, but I didn't try to use it):
extern struct tskTaskControlBlock* volatile pxCurrentTCB; extern volatile void * volatile pxCurrentTCB;
Preet
RE: get current task namePosted by Tyrel Newton on March 10, 2010 I ran into this same problem while I was debugging modifications to a port and I simply added a function like the one Preet mentioned above in both the tasks.c and task.h file. Other than the #include .c file at the end of tasks.c, the only way to cleanly do this is to manually edit tasks.c, since this is where the struct is FULLY defined WITH the task name field. Any other extern struct defintion method should result in a compiler error since it won't know where the task name field is within the structure. So, count me for a vote to either move the struct definition to a header file or add a few struct field get accessor functions to tasks.c and task.h.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|