mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-11 13:54:16 -04:00
Kernel updates:
- Add user configurable thread local storage array, with get/set access function.
This commit is contained in:
parent
51aa373c4c
commit
dfdc319518
7 changed files with 95 additions and 25 deletions
|
@ -195,6 +195,10 @@ extern "C" {
|
|||
#define configUSE_APPLICATION_TASK_TAG 0
|
||||
#endif
|
||||
|
||||
#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_uxTaskGetStackHighWaterMark
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 0
|
||||
#endif
|
||||
|
|
|
@ -1158,6 +1158,18 @@ constant. */
|
|||
#endif /* configUSE_APPLICATION_TASK_TAG ==1 */
|
||||
#endif /* ifdef configUSE_APPLICATION_TASK_TAG */
|
||||
|
||||
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
|
||||
|
||||
/* Each task contains an array of pointers that is dimensioned by the
|
||||
configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
|
||||
kernel does not use the pointers itself, so the application writer can use
|
||||
the pointers for any purpose they wish. The following two functions are
|
||||
used to set and query a pointer respectively. */
|
||||
void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue );
|
||||
void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex );
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* task.h
|
||||
* <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>
|
||||
|
|
|
@ -168,6 +168,10 @@ typedef struct tskTaskControlBlock
|
|||
TaskHookFunction_t pxTaskTag;
|
||||
#endif
|
||||
|
||||
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
|
||||
void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
|
||||
#endif
|
||||
|
||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||
uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
|
||||
#endif
|
||||
|
@ -2882,6 +2886,15 @@ UBaseType_t x;
|
|||
}
|
||||
#endif /* portUSING_MPU_WRAPPERS */
|
||||
|
||||
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
|
||||
{
|
||||
for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ )
|
||||
{
|
||||
pxTCB->pvThreadLocalStoragePointers[ x ] = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
{
|
||||
pxTCB->ulNotifiedValue = 0;
|
||||
|
@ -2898,6 +2911,45 @@ UBaseType_t x;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
|
||||
|
||||
void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )
|
||||
{
|
||||
TCB_t *pxTCB;
|
||||
|
||||
if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )
|
||||
{
|
||||
pxTCB = prvGetTCBFromHandle( xTaskToSet );
|
||||
pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
|
||||
|
||||
void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex )
|
||||
{
|
||||
void *pvReturn = NULL;
|
||||
TCB_t *pxTCB;
|
||||
|
||||
if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )
|
||||
{
|
||||
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
|
||||
pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];
|
||||
}
|
||||
else
|
||||
{
|
||||
pvReturn = NULL;
|
||||
}
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
|
||||
#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
|
||||
void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, const MemoryRegion_t * const xRegions )
|
||||
|
@ -4100,7 +4152,7 @@ TickType_t uxReturn;
|
|||
{
|
||||
/* The notified task has a priority above the currently
|
||||
executing task so a yield is required. */
|
||||
portYIELD_WITHIN_API();
|
||||
taskYIELD_IF_USING_PREEMPTION();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue