📄 compat-uitron-task-management-functions.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>Task Management Functions</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="礗TRON API"HREF="compat-uitron-microitron-api.html"><LINKREL="PREVIOUS"TITLE="礗TRON and eCos"HREF="compat-uitron-over-ecos.html"><LINKREL="NEXT"TITLE="Task-Dependent Synchronization Functions"HREF="compat-uitron-task-dependent-synch-functions.html"></HEAD><BODYCLASS="SECT1"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="compat-uitron-over-ecos.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 32. µITRON API</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="compat-uitron-task-dependent-synch-functions.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="COMPAT-UITRON-TASK-MANAGEMENT-FUNCTIONS">Task Management Functions</H1><P>The following functions are fully supported in this release: </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">sta_tsk</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid,</I></SPAN> INT <SPANCLASS="emphasis"><ICLASS="EMPHASIS">stacd</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void <TTCLASS="FUNCTION">ext_tsk</TT>( void )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void <TTCLASS="FUNCTION">exd_tsk</TT>( void )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">dis_dsp</TT>( void )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">ena_dsp</TT>( void )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">chg_pri</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid,</I></SPAN> PRI <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskpri</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">rot_rdq</TT>( PRI <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskpri</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">get_tid</TT>( ID *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_tskid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">ref_tsk</TT>( T_RTSK *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_rtsk,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">ter_tsk</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">rel_wai</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid</I></SPAN> )</PRE></TD></TR></TABLE><P>The following two functions are supported in this release,when enabled with the configuration option <TTCLASS="LITERAL">CYGPKG_UITRON_TASKS_CREATE_DELETE</TT>with some restrictions:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">cre_tsk</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid,</I></SPAN> T_CTSK *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_ctsk</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">del_tsk</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tskid</I></SPAN> )</PRE></TD></TR></TABLE><P>These functions are restricted as follows:</P><P>Because of the static initialization facilities provided forsystem objects, a task is allocated stack space statically in theconfiguration. So while tasks can be created and deleted, the samestack space is used for that task (task ID number) each time. Thusthe stack size (pk_ctsk->stksz) requested in <TTCLASS="FUNCTION">cre_tsk()</TT> ischecked for being less than that which was statically allocated,and otherwise ignored. This ensures that the new task will haveenough stack to run. For this reason <TTCLASS="FUNCTION">del_tsk()</TT> doesnot in any sense free the memory that was in use for the task'sstack. </P><P>The task attributes (pk_ctsk->tskatr) areignored; current versions of <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> do not needto know whether a task is written in assembler or C/C++ solong as the procedure call standard appropriate to the CPU is followed.</P><P>Extended information (pk_ctsk->exinf) is ignored.</P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN13490">Error checking</H2><P>For all these calls, an invalid task id (tskid) (less than1 or greater than the number of configured tasks) only returns E_IDwhen bad params return errors (<TTCLASS="LITERAL">CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS</TT>is enabled, see above).</P><P>Similarly, the following conditions are only checked for,and only return errors if <TTCLASS="LITERAL">CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS</TT>is enabled:</P><P></P><UL><LI><P>pk_crtk in <TTCLASS="FUNCTION">cre_tsk()</TT> is a valid pointer, otherwise return E_PAR</P></LI><LI><P><TTCLASS="FUNCTION">ter_tsk()</TT> or <TTCLASS="FUNCTION">rel_wai()</TT> on the calling task returns E_OBJ</P></LI><LI><P>the CPU is not locked already in <TTCLASS="FUNCTION">dis_dsp()</TT> and <TTCLASS="FUNCTION">ena_dsp()</TT>; returns E_CTX</P></LI><LI><P>priority level in <TTCLASS="FUNCTION">chg_pri()</TT> and <TTCLASS="FUNCTION">rot_rdq()</TT> is checked for validity, E_PAR</P></LI><LI><P>return value pointer in <TTCLASS="FUNCTION">get_tid()</TT> and <TTCLASS="FUNCTION">ref_tsk()</TT> is a valid pointer, or E_PAR</P></LI></UL><P>The following conditions are checked for, and return error codes if appropriate, regardless of the setting of<TTCLASS="LITERAL">CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS</TT>:</P><P></P><UL><LI><P>When create and delete functions <TTCLASS="FUNCTION">cre_tsk()</TT> and <TTCLASS="FUNCTION">del_tsk()</TT> are supported, all calls which use a valid task ID number checkthat the task exists; if not, E_NOEXS is returned</P></LI><LI><P>When supported, <TTCLASS="FUNCTION">cre_tsk()</TT>: the task must not already exist; otherwise E_OBJ</P></LI><LI><P>When supported, <TTCLASS="FUNCTION">cre_tsk()</TT>: the requested stack size must not be larger than that staticallyconfigured for the task; see the configuration options“Static initializers”, and “Default stack size”.Else E_NOMEM</P></LI><LI><P>When supported, <TTCLASS="FUNCTION">del_tsk()</TT>: the underlying <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> thread must not be running - this would imply either a bug or someprogram bypassing the µITRON compatibility layer and manipulating the thread directly.E_OBJ</P></LI><LI><P><TTCLASS="FUNCTION">sta_tsk()</TT>: the task must be dormant, else E_OBJ</P></LI><LI><P><TTCLASS="FUNCTION">ter_tsk()</TT>: the task must not be dormant, else E_OBJ</P></LI><LI><P><TTCLASS="FUNCTION">chg_pri()</TT>: the task must not be dormant, else E_OBJ</P></LI><LI><P><TTCLASS="FUNCTION">rel_wai()</TT>: the task must be in <TTCLASS="VARNAME">WAIT</TT> or <TTCLASS="VARNAME">WAIT-SUSPEND</TT> state, else E_OBJ</P></LI></UL></DIV></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="compat-uitron-over-ecos.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="compat-uitron-task-dependent-synch-functions.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">µITRON and <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="compat-uitron-microitron-api.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Task-Dependent Synchronization Functions</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -