OSF DCE Application Development Guide--Core Components
Thread Concepts and Operations
7.3.3 Thread Attributes
A thread attributes object allows you to specify values for thread attributes other than the
defaults when you create a thread with the pthread_create( ) routine. To use a thread
attributes object, perform the following steps:
1. Create a thread attributes object by calling the routine pthread_attr_create().
2. Call the routines discussed in the following subsections to set the individual
attributes of the thread attributes object.
3. Create a new thread by calling the pthread_create() routine and specifying the
identifier of the thread attributes object.
You have control over the following attributes of a new thread:
• Scheduling policy attribute
• Scheduling priority attribute
• Inherit scheduling attribute
• Stacksize attribute
7.3.3.1 Scheduling Policy Attribute
The scheduling policy attribute describes the overall scheduling policy of the threads in
your application. A thread has one of the following scheduling policies:
• SCHED_FIFO (First In, First Out)
The highest-priority thread runs until it blocks. If there is more than one thread with
the same priority, and that priority is the highest among other threads, the first thread
to begin running continues until it blocks.
• SCHED_RR (Round Robin)
The highest-priority thread runs until it blocks; however, threads of equal priority, if
that priority is the highest among other threads, are timesliced. (Timeslicing is a
mechanism that ensures that every thread is allowed time to execute by preempting
running threads at fixed intervals.)
• SCHED_OTHER, SCHED_FG_NP (Default)
All threads are timesliced. SCHED_OTHER and SCHED_FG_NP do the same
thing; however, SCHED_FG_NP is simply more precise terminology. The FG
stands for foreground and the NP for new primitive. All threads running under the
SCHED_OTHER and SCHED_FG_NP policy, regardless of priority, receive some
scheduling. Therefore, no thread is completely denied execution time. However,
SCHED_OTHER and SCHED_FG_NP threads can be denied execution time by
SCHED_FIFO or SCHED_RR threads.
124245 Tandem Computers Incorporated 7−5