Purpose
Enables recognition of the __thread storage class specifier, which
designates variables that are to be allocated threadlocal storage;
and specifies the threadlocal storage model to be used.
When
this option is in effect, any variables marked with the __thread storage
class specifier are treated as local to each thread in a multi-threaded application.
At run time, a copy of the variable is created for each thread that accesses
it, and destroyed when the thread terminates. Like other high-level constructs
that you can use to parallelize your applications, thread-local storage prevents
race conditions to global data, without the need for low-level synchronization
of threads.
Suboptions allow you to specify thread-local storage models,
which provide better performance but are more restrictive in their applicability.
Note: This option is only supported on AIX® for POWER® version 5.3 with the 5300-05 Technology
Level and higher.
Syntax
>>- -q--+-tls--+-----------------------+-+---------------------><
| | .-unsupported----. | |
| '-=--+-default--------+-' |
| +-global-dynamic-+ |
| +-initial-exec---+ |
| +-local-exec-----+ |
| '-local-dynamic--' |
'-notls--------------------------'
Defaults
-qtls=unsupported
Parameters
- unsupported
- The __thread keyword is not recognized and thread-local
storage is not enabled. This suboption is equivalent to -qnotls.
- global-dynamic
- This model is the most general, and can be used for all thread-local variables.
- initial-exec
- This model provides better performance than the global-dynamic or local-dynamic
models, and can be used for thread-local variables defined in dynamically-loaded
modules, provided that those modules are loaded at the same time as the executable.
That is, it can only be used when all thread-local variables are defined in
modules that are not loaded through dlopen.
- local-dynamic
- This model provides better performance than the global-dynamic model,
and can be used for thread-local variables defined in dynamically-loaded modules.
However, it can only be used when all references to thread-local variables
are contained in the same module in which the variables are defined.
- local-exec
- This model provides the best performance of all of the models, but can
only be used when all thread-local variables are defined and referenced by
the main executable.
- default
- Uses the appropriate model depending on the setting of the -qpic compiler
option, which determines whether position-independent code is generated or
not. When -qpic is in effect, this suboption results in -qtls=global-dynamic.
When -qnopic is in effect, this suboption results in -qtls=initial-exec (-qpic is in effect by default)(-qpic is
in effect by default in 64-bit mode, and cannot be disabled).
Specifying -qtls with no suboption is equivalent
to -qtls=default.