A.3 Choosing between Native and FSU Threads Libraries

Some GNAT implementations offer a choice between
native threads and FSU threads.

The native threads library correspond to the standard system threads
implementation (e.g. LinuxThreads on GNU/Linux,
POSIX threads on AIX, or
Solaris threads on Solaris). When this option is chosen, GNAT provides
a full and accurate implementation of the core language tasking model
as described in Chapter 9 of the Ada Reference Manual,
but might not (and probably does not) implement
the exact semantics as specified in Annex D (the Real-Time Systems Annex).
Indeed, the reason that a choice of libraries is offered
on a given target is because some of the
ACATS tests for Annex D fail using the native threads library.
As far as possible, this library is implemented
in accordance with Ada semantics (e.g., modifying priorities as required
to simulate ceiling locking),
but there are often slight inaccuracies, most often in the area of
absolutely respecting the priority rules on a single
processor.
Moreover, it is not possible in general to define the exact behavior,
because the native threads implementations
are not well enough documented.

On systems where the SCHED_FIFO POSIX scheduling policy is supported,
native threads will provide a behavior very close to the Annex D
requirements (i.e., a run-till-blocked scheduler with fixed priorities), but
on some systems (in particular GNU/Linux and Solaris), you need to have root
privileges to use the SCHED_FIFO policy.

The FSU threads library provides a completely accurate implementation
of Annex D.
Thus, operating with this library, GNAT is 100% compliant with both the core
and all Annex D
requirements.
The formal validations for implementations offering
a choice of threads packages are always carried out using the FSU
threads option.

From these considerations, it might seem that FSU threads are the
better choice,
but that is by no means always the case. The FSU threads package
operates with all Ada tasks appearing to the system to be a single
thread. This is often considerably more efficient than operating
with separate threads, since for example, switching between tasks
can be accomplished without the (in some cases considerable)
overhead of a context switch between two system threads. However,
it means that you may well lose concurrency at the system
level. Notably, some system operations (such as I/O) may block all
tasks in a program and not just the calling task. More
significantly, the FSU threads approach likely means you cannot
take advantage of multiple processors, since for this you need
separate threads (or even separate processes) to operate on
different processors.

For most programs, the native threads library is
usually the better choice. Use the FSU threads if absolute
conformance to Annex D is important for your application, or if
you find that the improved efficiency of FSU threads is significant to you.

Note also that to take full advantage of Florist and Glade, it is highly
recommended that you use native threads.