Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Moved the errno storage location out of the TCB and in TLS (into the struct tls_info_s).
  2. Modified the errno access definitions and logic that was in sched/errno to use the TLS logic in user space.  That logic now resides in libs/libc/errno since it is now a user library interface, not a core OS interface.
  3. TLS is now enabled by default.  It is enabled in the unaligned mode for the FLAT and PROTECTED build modes but in the highly efficient aligned mode for KERNEL build mode.
  4. There are no longer an OS system calls related to the error (with the exception of a call to get the struct tls_info_s in the unaligned TLS mode).

Push-Up vs. Push-Down Stacks

TLS data is always located at the beginning thread's stack.  This is true for both CPUs with push-up stacks and CPUs with push-down stacks.  This location required in order to access the TLS by ANDing the aligned stack pointer address.  The stack memory maps, however, then look very different:

   Push Down          Push Up
+-------------+   +-------------+ <- Stack memory allocation
|  TLS Data   |   |  TLS Data   |
+-------------+   +-------------+
|             |   | Task Data*  |
| Available   |   +-------------+
|   Stack     |   |  Arguments  |
|             |   +-------------+
|             |   |             |
|             |   | Available   | |
|             |   |   Stack     | v
|             | ^ |             |
+-------------+ | |             |
|  Arguments  |   |             |
+-------------+   |             |
| Task Data*  |   |             |
+-------------+   +-------------+

* Task data is allocated in the main's thread's stack only

TLS interfaces

TLS is a non-standard, but more general interface. It differs from pthread-specific data only in that its semantics are general; the semantics of the pthread-specific data interfaces are focused on pthreads. But they really should share the same common underlying logic.

...