Multithreaded Programming Guide


POSIX specifies three scheduling policies: first-in-first-out (SCHED_FIFO), round-robin (SCHED_RR), and custom (SCHED_OTHER). SCHED_FIFO is a queue-based scheduler with different queues for each priority level. SCHED_RR is like FIFO except that each thread has an execution time quota.

Both SCHED_FIFO and SCHED_RR are POSIX Realtime extensions. SCHED_OTHER is the default scheduling policy.

See LWPs and Scheduling Classesfor information about the SCHED_OTHER policy.

Two scheduling scopes are available: process scope for unbound threads and system scope for bound threads. Threads with differing scope states can coexist on the same system and even in the same process. In general, the scope sets the range in which the threads scheduling policy is in effect.

Process Scope (Unbound Threads)

PTHREAD_SCOPE_PROCESS threads are created as unbound threads. The association of these threads with LWPs is managed by the threads library.

In most cases, threads should be PTHREAD_SCOPE_PROCESS. These threads have no restriction to execute on a particular LWP, and are equivalent to Solaris thread created without the THR_BOUND flag. The threads library decides the association between individual threads and LWPs.

System Scope (Bound Threads)

PTHREAD_SCOPE_SYSTEM threads are created as bound threads. A bound thread is permanently attached to an LWP.

Each bound thread is bound to an LWP for the lifetime of the thread. This is equivalent to creating a Solaris thread in the THR_BOUND state. You can bind a thread to use special scheduling attributes with Realtime scheduling.

Note –

In neither case, bound or unbound, can a thread be directly accessed by or moved to another process.