/* Write the 32-bit 0x12345678 value directly into index 1 of the thread
local storage array. Passing NULL as the task handle has the effect of writing
to the calling task's thread local storage array. */
vTaskSetThreadLocalStoragePointer( NULL, /* Task handle. */
1, /* Index into the array. */
( void * ) 0x12345678 );
/* Store the value of the 32-bit variable ulVariable to index 0 of the calling
task's thread local storage array. */
ulVariable = ERROR_CODE;
vTaskSetThreadLocalStoragePointer( NULL, /* Task handle. */
0, /* Index into the array. */
( void * ) ulVariable );
/* Read the value stored in index 5 of the calling task's thread local storage
array into ulVariable. */
ulVariable = ( uint32_t ) pvTaskGetThreadLocalStoragePointer( NULL, 5 );
Storing and retrieving 32-bit values directly from an index in the thread local storage array
/* Create a structure for use by this task. */
pxStruct = pvPortMalloc( sizeof( xExampleStruct ) );
/* Set the structure members. */
pxStruct->ulValue1 = 0;
pxStruct->ulValue2 = 1;
/* Store a pointer to the structure in index 0 of the calling task's thread
local storage array. */
vTaskSetThreadLocalStoragePointer( NULL, /* Task handle. */
0, /* Index into the array. */
( void * ) pxStruct );
/* Locate the structure used by the calling task by reading its location from
index 0 of the calling task's thread local storage array. */
pxStruct = ( xExampleStruct * ) pvTaskGetThreadLocalStoragePointer( NULL, 0 );
Storing a pointer to a structure in the calling task's thread local storage array
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.