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

📄 c-basic3.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90540"> </a><b class="library">bLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90542"> </a>All routines&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90544"> </a><b class="library">fppArchLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90546"> </a><b class="routine"><i class="routine">fppSave</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">fppRestore</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90548"> </a><b class="library">intLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90550"> </a><b class="routine"><i class="routine">intContext</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intCount</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intVecSet</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intVecGet</i></b><b>(&nbsp;)</b>,<b> </b><b class="routine"><i class="routine">intLock</i></b><b>(&nbsp;)</b>,<b> </b><b class="routine"><i class="routine">intUnlock</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90552"> </a><b class="library">lstLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90554"> </a>All routines except <b class="routine"><i class="routine">lstFree</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90556"> </a><b class="library">mathALib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90558"> </a>All are callable if <b class="routine"><i class="routine">fppSave</i></b><b>(&nbsp;)</b>/<b class="routine"><i class="routine">fppRestore</i></b><b>(&nbsp;)</b> are used&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90560"> </a><b class="library">rngLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90562"> </a>All routines except <b class="routine"><i class="routine">rngCreate</i></b><b>(&nbsp;)</b> and <b class="routine"><i class="routine">roundlet</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90564"> </a><b class="library">taskLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90566"> </a><b class="routine"><i class="routine">taskIdVerify</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">taskIdDefault</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">taskIsReady</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">taskIsSuspended</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">taskTcb</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="90568"> </a><b class="library">vxLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="90571"> </a><b class="routine"><i class="routine">vxTas</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84431">2.3.6  &nbsp;&nbsp;POSIX Scheduling Interface</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84433"> </a>The POSIX 1003.1b scheduling routines, provided by <b class="library">schedPxLib</b>, are shown in <a href="c-basic3.html#84461">Table&nbsp;2-12</a>. These routines let you use a portable interface to get and set task priority, get the scheduling policy, get the maximum and minimum priority for tasks, and if round-robin scheduling is in effect, get the length of a time slice. To understand how to use the routines in this alternative interface, be aware of the minor differences between the POSIX and Wind methods of scheduling.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84438">Differences Between POSIX and Wind Scheduling</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84439"> </a>POSIX and Wind scheduling routines differ in the following ways:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84441"> </a>POSIX scheduling is based on <i class="term">processes</i>, while Wind<i class="i"> </i>scheduling is based on <i class="term">tasks</i>. Tasks and processes differ in several ways. Most notably, tasks can address memory directly while processes cannot; and processes inherit only some specific attributes from their parent process, while tasks operate in exactly the same environment as the parent task. </li></ul></p><dl class="margin"><dd><div class="Indent"><a name="84442"> </a>Tasks and processes are alike in that they can be scheduled independently.</div><br></dl><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84443"> </a>VxWorks documentation uses the term <i class="term">preemptive priority </i>scheduling, while the POSIX standard uses the term <i class="term">FIFO</i>. This difference is purely one of nomenclature: both describe the same priority-based policy.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84446"> </a>The POSIX scheduling algorithms are applied on a process-by-process basis. The Wind methodology, on the other hand, applies scheduling algorithms on a system-wide basis--either all tasks use a round-robin scheme, or all use a preemptive priority scheme.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84448"> </a>The POSIX priority numbering scheme is the inverse of the Wind scheme. In POSIX, the higher the number, the higher the priority; in the Wind<i class="i"> </i>scheme, the <i class="emphasis">lower</i> the number, the higher the priority, where 0 is the highest priority. Accordingly, the priority numbers used with the POSIX scheduling library (<b class="file">schedPxLib</b>) do not match those used and reported by all other components of VxWorks. You can override this default by setting the global variable <b class="symbol_lc">posixPriorityNumbering</b> to FALSE. If you do this, the Wind numbering scheme (smaller number = higher priority) is used by <b class="file">schedPxLib</b>, and its priority numbers match those used by the other components of VxWorks.</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="84453"> </a>The POSIX scheduling routines are included when <b class="symbol_UC">INCLUDE_POSIX_SCHED </b>is selected for inclusion in the project facility VxWorks view; see <i class="title">Tornado User's Guide: Projects</i> for information on configuring VxWorks.<p class="table"><h4 class="EntityTitle"><a name="84461"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 2-12:&nbsp;&nbsp;POSIX Scheduling Calls</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84465"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Call</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84467"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84474"> </a><b class="routine"><i class="routine">sched_setparam</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84476"> </a>Set a task's priority.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84479"> </a><b class="routine"><i class="routine">sched_getparam</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84481"> </a>Get the scheduling parameters for a specified task.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84484"> </a><b class="routine"><i class="routine">sched_setscheduler</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84486"> </a>Set scheduling policy and parameters for a task.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84489"> </a><b class="routine"><i class="routine">sched_yield</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84491"> </a>Relinquish the CPU.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84494"> </a><b class="routine"><i class="routine">sched_getscheduler</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84496"> </a>Get the current scheduling policy.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84499"> </a><b class="routine"><i class="routine">sched_get_priority_max</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84501"> </a>Get the maximum priority.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84504"> </a><b class="routine"><i class="routine">sched_get_priority_min</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84506"> </a>Get the minimum priority.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84509"> </a><b class="routine"><i class="routine">sched_rr_get_interval</i></b><b>(&nbsp;)</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="84511"> </a>If round-robin scheduling, get the time slice length.&nbsp;</div></td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84517">Getting and Setting POSIX Task Priorities</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84518"> </a>The routines <b class="routine"><i class="routine">sched_setparam</i></b><b>(&nbsp;)</b> and <b class="routine"><i class="routine">sched_getparam</i></b><b>(&nbsp;)</b> set and get a task's priority, respectively. Both routines take a task ID and a <b class="symbol_lc">sched_param</b> structure (defined in <i class="textVariable">installDir</i><b class="file">/target/h/sched.h</b>). A task ID of 0 sets or gets the priority for the calling task. The <b class="symbol_lc">sched_priority</b> member of the <b class="symbol_lc">sched_param</b> structure specifies the new task priority when <b class="routine"><i class="routine">sched_setparam</i></b><b>(&nbsp;)</b> is called. The routine <b class="routine"><i class="routine">sched_getparam</i></b><b>(&nbsp;)</b> fills in the <b class="symbol_lc">sched_priority</b> with the specified task's current priority.</p></dl></dl><h4 class="EntityTitle"><a name="84519"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 2-1:&nbsp;&nbsp;Getting and Setting POSIX Task Priorities</font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="84520">/* This example sets the calling task's priority to 150, then verifies &nbsp;* that priority. To run from the shell, spawn as a task:  * &nbsp;&nbsp;-&gt; sp priorityTest &nbsp;*/</a></b><dd> <b><a name="84524">/* includes */ #include "vxWorks.h" #include "sched.h"</a></b><dd> <b><a name="84526">/* defines */ #define PX_NEW_PRIORITY 150</a></b><dd> <b><a name="90575">STATUS priorityTest (void)     {     struct sched_param myParam;      /* initialize param structure to desired priority */</a></b><dd> <b><a name="90576">    myParam.sched_priority = PX_NEW_PRIORITY;     if (sched_setparam (0, &amp;myParam) == ERROR)         {         printf ("error setting priority\n");         return (ERROR);         }</a></b><dd> <b><a name="84530">    /* demonstrate getting a task priority as a sanity check; ensure it      * is the same value that we just set.      */</a></b><dd> <b><a name="84532">    if (sched_getparam (0, &amp;myParam) == ERROR)         {         printf ("error getting priority\n");         return (ERROR);         }</a></b><dd> <b

⌨️ 快捷键说明

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