DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Historical Background
Thread Local Storage (TLS) was originally implemented to support pthread-specific data and a per-thread errno variable.
errno
The user errno value was originally kept in the TCB and could be accessed via an OS system call called __errno().
...
Instead user code must explicitly call set_errno(errcode). This a a violation of the accepted usage of the POSIX errno variable.
TLS-Based errno
The current solution has moved the errno storage location out of the protected TCB memory and into the unprotected application thread's stack memory. Then it can be accessed with the appropriate TLS (Thread Local Storage) interfaces.
Task-Specific Globals in the FLAT and PROTECTED builds
...
Using task-specific data, however, it is possible to make getopt() thread-safe. This amounts to keeping the getopt() globals in the main thread's TLS so that there is an individual copy for each thread. That would keep both the standard form of the getopt() interfaces as well as making getopt() full re-entrant with respect to task groups.
TLS-Based errno
The current solution has moved the errno storage location out of the protected TCB memory and into the unprotected application thread's stack memory. Then it can be accessed with the appropriate TLS (Thread Local Storage) interfaces.
Unaligned TLS
Historically, TLS worked by aligning the stack base address then simply AND'ing the current stack pointer to obtain the base address of the stack where the TLS data can be found (as struct tls_info_s). This mechanism is very efficient: No OS system call is required, application logic can obtain the TLS data directly form its stack via AND'ing and casting.
...