⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel-thread-priorities.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Thread priorities</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="The eCos Kernel"HREF="kernel.html"><LINKREL="PREVIOUS"TITLE="Thread termination"HREF="kernel-thread-termination.html"><LINKREL="NEXT"TITLE="Per-thread data"HREF="kernel-thread-data.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="kernel-thread-termination.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="kernel-thread-data.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="KERNEL-THREAD-PRIORITIES">Thread priorities</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN616"></A><H2>Name</H2>cyg_thread_get_priority, cyg_thread_get_current_priority, cyg_thread_set_priority&nbsp;--&nbsp;Examine and manipulate thread priorities</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN621"><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN622"><P></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="FUNCSYNOPSISINFO">#include &lt;cyg/kernel/kapi.h&gt;        </PRE></TD></TR></TABLE><P><CODE><CODECLASS="FUNCDEF">cyg_priority_t cyg_thread_get_priority</CODE>(cyg_handle_t thread);</CODE></P><P><CODE><CODECLASS="FUNCDEF">cyg_priority_t cyg_thread_get_current_priority</CODE>(cyg_handle_t thread);</CODE></P><P><CODE><CODECLASS="FUNCDEF">void cyg_thread_set_priority</CODE>(cyg_handle_t thread, cyg_priority_t priority);</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN641"></A><H2>Description</H2><P>Typical schedulers use the concept of a thread priority to determinewhich thread should run next. Exactly what this priority consists ofwill depend on the scheduler, but a typical implementation would be asmall integer in the range 0 to 31, with 0 being the highest priority.Usually only the idle thread will run at the lowest priority. Theexact number of priority levels available depends on theconfiguration, typically the option<TTCLASS="VARNAME">CYGNUM_KERNEL_SCHED_PRIORITIES</TT>.      </P><P><TTCLASS="FUNCTION">cyg_thread_get_priority</TT> can be used to determinethe priority of a thread, or more correctly the value last used in a<TTCLASS="FUNCTION">cyg_thread_set_priority</TT> call or when the threadwas first created. In some circumstances it is possible that thethread is actually running at a higher priority. For example, if itowns a mutex and priority ceilings or inheritance is being used toprevent priority inversion problems, then the thread's priority mayhave been boosted temporarily.<TTCLASS="FUNCTION">cyg_thread_get_current_priority</TT> returns the realcurrent priority.      </P><P>In many applications appropriate thread priorities can be determinedand allocated statically. However, if it is necessary for a thread'spriority to change at run-time then the<TTCLASS="FUNCTION">cyg_thread_set_priority</TT> function provides thisfunctionality.       </P></DIV><DIVCLASS="REFSECT1"><ANAME="KERNEL-THREAD-PRIORITIES-CONTEXT"></A><H2>Valid contexts</H2><P><TTCLASS="FUNCTION">cyg_thread_get_priority</TT> and<TTCLASS="FUNCTION">cyg_thread_get_current_priority</TT> can be calledfrom thread or DSR context, although the latter is rarely useful.<TTCLASS="FUNCTION">cyg_thread_set_priority</TT> should also only becalled from thread context.      </P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="kernel-thread-termination.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="kernel-thread-data.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Thread termination</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="kernel.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Per-thread data</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -