With Crossworks 3.0 for MSP430 and CTL the thread local storage now has a special section in, what seems, is a way to allow for an arbitrary amount of thread local storage.
I am not sure how one is supposed to use this from C.
Presumable one puts a variable in the THREAD section and then accesses it through the CTL_TASK_t structure for each task.
I think I can do the first part, put a variable into the THREAD section but, I am unsure how to access it in a reliable manner. Presumable one would calculate the offset from the beginning of the THREAD section and use that to access the thread local storage. My attempt at this failed and I am unable to proceed.
I have declared the following:
extern unsigned char thread_init_begin;
unsigned char thread_test=0;
And I attempt to access them in the following manner:
printf("thread_test = %p\r\n""thread_init_begin = %p\r\n""offset = %p\r\n",&thread_test,&thread_init_begin,&thread_test-&thread_init_begin);
The code compiles fine but the linker complains of "undefined symbol '_thread_init_begin. This is obvously because of the preceding underscore but, I don't know how to remove it as it is automatically inserted by the compiler.
Is there an example out there of how to access and use the thread local storage? I have googled it an returned very few references to thread local storage.
Please sign in to leave a comment.