Quality RTOS & Embedded Software

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




Loading

I DID FREERTOS CHANGES for memory tracer

Posted by Piero B on February 22, 2008
Hi all. Hi Richard.

I did some little changes in task.c and queue.c, for adding the possibility for user to call an hook function when a task or queue is created, passing some parameters, to trace memory usage information and to save pointer for each task tcb for custom monitoring of stack grow. It could be possible do similar changes in function TaskDelete and QueueDelete. My actual version of freertos is 470

Below there are my changes (all changes have comment "piero" before). Any comments will be appreciate
Bye,
Piero

******************************
FOR TASK.C:
******************************

....

Changes since V4.3.1:

+ Added xTaskGetSchedulerState() function.
+ Added prvIsTaskSuspended() to take into account the Occurrence of
vTaskResume() or vTaskResumeFromISR() being called passing in the
handle of a task that appears in the Suspended list only because it
is blocked on an event without a timeout being specified.
+ Updated xTaskCheckForTimeout() to take into account that tasks blocked
using the Suspended list should never time out.

// ----------------------------------------------------------------------------....

--------------------------------
// piero
Changes:
+ Added hook funtion in TaskCrete for user memory usage check
// ------------------------------------------------------------------------------------------------------------
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "FreeRTOS.h"
#include "task.h"

/*
* Macro to define the amount of stack available to the idle task.
*/
#define tskIDLE_STACK_SIZEconfigMINIMAL_STACK_SIZE

// ------------------------------------------------------------------------------------------------------------
// piero
// Additionale default definition
#ifndef configUSE_TASKCREATE_HOOK
#define configUSE_TASKCREATE_HOOK 0
#endif
// ------------------------------------------------------------------------------------------------------------

....



....
#if portSTACK_GROWTH < 0
{
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );
}
#else
{
pxTopOfStack = pxNewTCB->pxStack;
}
#endif

// ------------------------------------------------------------------------------------------------------------
// piero
#if (configUSE_TASKCREATE_HOOK == 1)
{
extern void vApplicationTaskCreateHook( tskTCB * pxCurrentTCB, unsigned portSHORT usCurrentStackDepth );

/* Call the user defined function from within the create task function.
This allows the application designer to add memory usage check.
NOTE: vApplicationTaskCreateHook(..) MUST NOT, UNDER ANY CIRCUMSTANCES,
CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationTaskCreateHook( pxNewTCB, usStackDepth );
}
#endif
// ------------------------------------------------------------------------------------------------------------



/* Initialize the TCB stack to look as if the task was already running,
but had been interrupted by the scheduler. The return address is set
to the start of the task function. Once the stack has been initialised
thetop of stack variable is updated. */
pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pvTaskCode, pvParameters );

....



******************************
FOR QUEUE.C:
******************************

....

/*
// ------------------------------------------------------------------------------------------------------------
// piero
Changes:
+ Added hook funtion in QueueCreate for user memory usage check
// ------------------------------------------------------------------------------------------------------------
*/


#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"

// ------------------------------------------------------------------------------------------------------------
// piero
// Additionale default definition
#ifndef configUSE_QUEUECREATE_HOOK
#define configUSE_QUEUECREATE_HOOK 0
#endif
// ------------------------------------------------------------------------------------------------------------



/*-----------------------------------------------------------
* PUBLIC LIST API documented in list.h
*----------------------------------------------------------*/


....


....

/* Likewise ensure the event queues start with the correct state. */
vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );

// ------------------------------------------------------------------------------------------------------------
// piero
#if (configUSE_QUEUECREATE_HOOK == 1)
{
extern void vApplicationQueueCreateHook( xQUEUE *pxCurrentQueue, unsigned portBASE_TYPE uxCurrentQueueLength, unsigned portBASE_TYPE uxCurrentItemSize );

/* Call the user defined function from within the create queue function.
This allows the application designer to add memory usage check.
NOTE: vApplicationQueueCreateHook(..) MUST NOT, UNDER ANY CIRCUMSTANCES,
CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationQueueCreateHook( pxNewQueue, uxQueueLength, portBASE_TYPE uxItemSize );;
}
#endif
// ------------------------------------------------------------------------------------------------------------

return pxNewQueue;

....








RE: I DID FREERTOS CHANGES for memory tracer

Posted by Piero B on February 27, 2008

I need feedback about this idea.....

No answers???

Bye,
Piero

RE: I DID FREERTOS CHANGES for memory tracer

Posted by Richard on March 1, 2008
I think the changes are very useful. The next version of FreeRTOS.org will include a new set of trace macros, which will allows all scheduler events to be traced.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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