1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Thread priorities</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="The eCos Kernel"
23 HREF="kernel.html"><LINK
25 TITLE="Thread termination"
26 HREF="kernel-thread-termination.html"><LINK
28 TITLE="Per-thread data"
29 HREF="kernel-thread-data.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="kernel-thread-termination.html"
71 HREF="kernel-thread-data.html"
82 NAME="KERNEL-THREAD-PRIORITIES">Thread priorities</H1
90 >cyg_thread_get_priority, cyg_thread_get_current_priority, cyg_thread_set_priority -- Examine and manipulate thread priorities</DIV
92 CLASS="REFSYNOPSISDIV"
108 CLASS="FUNCSYNOPSISINFO"
109 >#include <cyg/kernel/kapi.h>
118 >cyg_priority_t cyg_thread_get_priority</CODE
119 >(cyg_handle_t thread);</CODE
125 >cyg_priority_t cyg_thread_get_current_priority</CODE
126 >(cyg_handle_t thread);</CODE
132 >void cyg_thread_set_priority</CODE
133 >(cyg_handle_t thread, cyg_priority_t priority);</CODE
147 >Typical schedulers use the concept of a thread priority to determine
148 which thread should run next. Exactly what this priority consists of
149 will depend on the scheduler, but a typical implementation would be a
150 small integer in the range 0 to 31, with 0 being the highest priority.
151 Usually only the idle thread will run at the lowest priority. The
152 exact number of priority levels available depends on the
153 configuration, typically the option
156 >CYGNUM_KERNEL_SCHED_PRIORITIES</TT
162 >cyg_thread_get_priority</TT
163 > can be used to determine
164 the priority of a thread, or more correctly the value last used in a
167 >cyg_thread_set_priority</TT
168 > call or when the thread
169 was first created. In some circumstances it is possible that the
170 thread is actually running at a higher priority. For example, if it
171 owns a mutex and priority ceilings or inheritance is being used to
172 prevent priority inversion problems, then the thread's priority may
173 have been boosted temporarily.
176 >cyg_thread_get_current_priority</TT
181 >In many applications appropriate thread priorities can be determined
182 and allocated statically. However, if it is necessary for a thread's
183 priority to change at run-time then the
186 >cyg_thread_set_priority</TT
187 > function provides this
194 NAME="KERNEL-THREAD-PRIORITIES-CONTEXT"
201 >cyg_thread_get_priority</TT
205 >cyg_thread_get_current_priority</TT
207 from thread or DSR context, although the latter is rarely useful.
210 >cyg_thread_set_priority</TT
211 > should also only be
212 called from thread context.
220 SUMMARY="Footer navigation table"
231 HREF="kernel-thread-termination.html"
249 HREF="kernel-thread-data.html"
259 >Thread termination</TD