small suggestion / request

ben_fnr wrote on Friday, February 01, 2008:

Can I ask for a small modification to FreeRTOS. I like the configUSE_TRACE_FACILITY option but I notice you are using sprintf to format the output, which has a rather large overhead by the time the appropriate library functions are included. It is something like 20k under GCC, while the RTOS code that gets included is only around 600 bytes.

As it happens I have my own cut down version of sprintf which of course I can easily substitute in task.c, but of course this will get over written should I upgrade it at any time, so my suggestion would be to add

#ifndef SPRINTF_FUNCTION
    #define SPRINTF_FUNCTION    sprintf
#endif

to the top of task.c, and change

sprintf( pcStatusString, ( portCHAR * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );

to

SPRINTF_FUNCTION( pcStatusString, ( portCHAR * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );

that way it can easily be overridden from FreeRTOSConfig.h to point to an alternative function.

woops_ wrote on Friday, February 01, 2008:

That is a good idea. There are two small sprintf implementations in the FreeRTOS code already. One in the cortex code and another somewhere I forget. Once of these could be used by default using this method.