Next: , Previous: Pragma Test_Case, Up: Implementation Defined Pragmas


Pragma Thread_Local_Storage

Syntax:

     pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);

This pragma specifies that the specified entity, which must be a variable declared in a library level package, is to be marked as "Thread Local Storage" (TLS). On systems supporting this (which include Solaris, GNU/Linux and VxWorks 6), this causes each thread (and hence each Ada task) to see a distinct copy of the variable.

The variable may not have default initialization, and if there is an explicit initialization, it must be either null for an access variable, or a static expression for a scalar variable. This provides a low level mechanism similar to that provided by the Ada.Task_Attributes package, but much more efficient and is also useful in writing interface code that will interact with foreign threads.

If this pragma is used on a system where TLS is not supported, then an error message will be generated and the program will be rejected.