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

📄 tasklib.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/taskLib.html - generated by refgen from taskLib.c --> <title> taskLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>taskLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>taskLib</strong> - task management library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>  -  spawn a task<br><b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b>  -  initialize a task with a stack at a specified address<br><b><i><a href="./taskLib.html#taskActivate">taskActivate</a></i>(&nbsp;)</b>  -  activate a task that has been initialized<br><b><i><a href="./taskLib.html#exit">exit</a></i>(&nbsp;)</b>  -  exit a task  (ANSI)<br><b><i><a href="./taskLib.html#taskDelete">taskDelete</a></i>(&nbsp;)</b>  -  delete a task<br><b><i><a href="./taskLib.html#taskDeleteForce">taskDeleteForce</a></i>(&nbsp;)</b>  -  delete a task without restriction<br><b><i><a href="./taskLib.html#taskSuspend">taskSuspend</a></i>(&nbsp;)</b>  -  suspend a task<br><b><i><a href="./taskLib.html#taskResume">taskResume</a></i>(&nbsp;)</b>  -  resume a task<br><b><i><a href="./taskLib.html#taskRestart">taskRestart</a></i>(&nbsp;)</b>  -  restart a task<br><b><i><a href="./taskLib.html#taskPrioritySet">taskPrioritySet</a></i>(&nbsp;)</b>  -  change the priority of a task<br><b><i><a href="./taskLib.html#taskPriorityGet">taskPriorityGet</a></i>(&nbsp;)</b>  -  examine the priority of a task<br><b><i><a href="./taskLib.html#taskLock">taskLock</a></i>(&nbsp;)</b>  -  disable task rescheduling<br><b><i><a href="./taskLib.html#taskUnlock">taskUnlock</a></i>(&nbsp;)</b>  -  enable task rescheduling<br><b><i><a href="./taskLib.html#taskSafe">taskSafe</a></i>(&nbsp;)</b>  -  make the calling task safe from deletion<br><b><i><a href="./taskLib.html#taskUnsafe">taskUnsafe</a></i>(&nbsp;)</b>  -  make the calling task unsafe from deletion<br><b><i><a href="./taskLib.html#taskDelay">taskDelay</a></i>(&nbsp;)</b>  -  delay a task from executing<br><b><i><a href="./taskLib.html#taskIdSelf">taskIdSelf</a></i>(&nbsp;)</b>  -  get the task ID of a running task<br><b><i><a href="./taskLib.html#taskIdVerify">taskIdVerify</a></i>(&nbsp;)</b>  -  verify the existence of a task<br><b><i><a href="./taskLib.html#taskTcb">taskTcb</a></i>(&nbsp;)</b>  -  get the task control block for a task ID<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides the interface to the VxWorks task management facilities.Task control services are provided by the VxWorks kernel, which is comprisedof <b><a href="./kernelLib.html#top">kernelLib</a></b>, <b><a href="./taskLib.html#top">taskLib</a></b>, <b><a href="./semLib.html#top">semLib</a></b>, <b><a href="./tickLib.html#top">tickLib</a></b>, <b><a href="./msgQLib.html#top">msgQLib</a></b>, and <b><a href="./wdLib.html#top">wdLib</a></b>.  Programmaticaccess to task information and debugging features is provided by <b><a href="./taskInfo.html#top">taskInfo</a></b>.Higher-level task information display routines are provided by <b><a href="./taskShow.html#top">taskShow</a></b>.<p></blockquote><h4>TASK CREATION</h4><blockquote><p>Tasks are created with the general-purpose routine <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>.  Taskcreation consists of the following:  allocation of memory for the stackand task control block (<b>WIND_TCB</b>), initialization of the <b>WIND_TCB</b>, andactivation of the <b>WIND_TCB</b>.  Special needs may require the use of thelower-level routines <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b> and <b><i><a href="./taskLib.html#taskActivate">taskActivate</a></i>(&nbsp;)</b>, which are the underlyingprimitives of <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>.<p>Tasks in VxWorks execute in the most privileged state of the underlyingarchitecture.  In a shared address space, processor privilege offers noprotection advantages and actually hinders performance.<p>There is no limit to the number of tasks created in VxWorks, as long assufficient memory is available to satisfy allocation requirements.<p>The routine <b><i><a href="./usrLib.html#sp">sp</a></i>(&nbsp;)</b> is provided in <b><a href="./usrLib.html#top">usrLib</a></b> as a convenient abbreviation forspawning tasks.  It calls <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b> with default parameters.<p></blockquote><h4>TASK DELETION</h4><blockquote><p>If a task exits its "main" routine, specified during task creation, thekernel implicitly calls <b><i><a href="./taskLib.html#exit">exit</a></i>(&nbsp;)</b> to delete the task.  Tasks can beexplicitly deleted with the <b><i><a href="./taskLib.html#taskDelete">taskDelete</a></i>(&nbsp;)</b> or <b><i><a href="./taskLib.html#exit">exit</a></i>(&nbsp;)</b> routine.<p>Task deletion must be handled with extreme care, due to the inherentdifficulties of resource reclamation.  Deleting a task that owns acritical resource can cripple the system, since the resource may no longerbe available.  Simply returning a resource to an available state is not aviable solution, since the system can make no assumption as to the stateof a particular resource at the time a task is deleted.<p>The solution to the task deletion problem lies in deletion protection,rather than overly complex deletion facilities.  Tasks may be protectedfrom unexpected deletion using <b><i><a href="./taskLib.html#taskSafe">taskSafe</a></i>(&nbsp;)</b> and <b><i><a href="./taskLib.html#taskUnsafe">taskUnsafe</a></i>(&nbsp;)</b>.  While a taskis safe from deletion, deleters will block until it is safe to proceed.Also, a task can protect itself from deletion by taking a mutual-exclusionsemaphore created with the <b>SEM_DELETE_SAFE</b> option, which enables an implicit<b><i><a href="./taskLib.html#taskSafe">taskSafe</a></i>(&nbsp;)</b> with each <b><i><a href="./semLib.html#semTake">semTake</a></i>(&nbsp;)</b>, and a <b><i><a href="./taskLib.html#taskUnsafe">taskUnsafe</a></i>(&nbsp;)</b> with each <b><i><a href="./semLib.html#semGive">semGive</a></i>(&nbsp;)</b>(see <b><a href="./semMLib.html#top">semMLib</a></b> for more information).Many VxWorks system resources are protected in this manner, andapplication designers may wish to consider this facility where dynamictask deletion is a possibility.<p>The <b><a href="./sigLib.html#top">sigLib</a></b> facility may also be used to allow a task toexecute clean-up code before actually expiring.<p></blockquote><h4>TASK CONTROL</h4><blockquote><p>Tasks are manipulated by means of an ID that is returned when a task iscreated.  VxWorks uses the convention that specifying a task ID of NULLin a task control function signifies the calling task.<p>The following routines control task state:  <b><i><a href="./taskLib.html#taskResume">taskResume</a></i>(&nbsp;)</b>, <b><i><a href="./taskLib.html#taskSuspend">taskSuspend</a></i>(&nbsp;)</b>,<b><i><a href="./taskLib.html#taskDelay">taskDelay</a></i>(&nbsp;)</b>, <b><i><a href="./taskLib.html#taskRestart">taskRestart</a></i>(&nbsp;)</b>, <b><i><a href="./taskLib.html#taskPrioritySet">taskPrioritySet</a></i>(&nbsp;)</b>, and <b><i><a href="./taskInfo.html#taskRegsSet">taskRegsSet</a></i>(&nbsp;)</b>.<p></blockquote><h4>TASK SCHEDULING</h4><blockquote><p>VxWorks schedules tasks on the basis of priority.  Tasks may havepriorities ranging from 0, the highest priority, to 255, the lowestpriority.  The priority of a task in VxWorks is dynamic, and an existingtask's priority can be changed using <b><i><a href="./taskLib.html#taskPrioritySet">taskPrioritySet</a></i>(&nbsp;)</b>.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>taskLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./taskLib.html#top">taskLib</a></b>, <b><a href="./taskInfo.html#top">taskInfo</a></b>, <b><a href="./taskShow.html#top">taskShow</a></b>, <b><a href="./taskHookLib.html#top">taskHookLib</a></b>, <b><a href="./taskVarLib.html#top">taskVarLib</a></b>, <b><a href="./semLib.html#top">semLib</a></b>, <b><a href="./semMLib.html#top">semMLib</a></b>,  <b><a href="./kernelLib.html#top">kernelLib</a></b>,  <i>VxWorks Programmer's Guide: Basic OS</i><hr><a name="taskSpawn"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>taskSpawn</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>taskSpawn</i>(&nbsp;)</strong> - spawn a task</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int taskSpawn    (    char *  name,      /* name of new task (stored at pStackBase) */    int     priority,  /* priority of new task */    int     options,   /* task option word */    int     stackSize, /* size (bytes) of stack needed plus name */    FUNCPTR entryPt,   /* entry point of new task */    int     arg1,      /* 1st of 10 req'd task args to pass to func */    int     arg2,    int     arg3,    int     arg4,    int     arg5,    int     arg6,    int     arg7,    int     arg8,    int     arg9,    int     arg10    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates and activates a new task with a specified priorityand options and returns a system-assigned ID.  See <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b> and<b><i><a href="./taskLib.html#taskActivate">taskActivate</a></i>(&nbsp;)</b> for the building blocks of this routine.<p>A task may be assigned a name as a debugging aid.  This name will appearin displays generated by various system information facilities such as<b><i><a href="./usrLib.html#i">i</a></i>(&nbsp;)</b>.  The name may be of arbitrary length and content, but the currentVxWorks convention is to limit task names to ten characters and prefixthem with a "t".  If <i>name</i> is specified as NULL, an ASCII name will beassigned to the task of the form "t<i>n</i>" where <i>n</i> is an integer whichincrements as new tasks are spawned.<p>The only resource allocated to a spawned task is a stack of a specifiedsize <i>stackSize</i>, which is allocated from the system memory partition.Stack size should be an even integer.  A task control block (TCB) iscarved from the stack, as well as any memory required by the task name.The remaining memory is the task's stack and every byte is filled with thevalue 0xEE for the <b><i><a href="./usrLib.html#checkStack">checkStack</a></i>(&nbsp;)</b> facility.  See the manual entry for<b><i><a href="./usrLib.html#checkStack">checkStack</a></i>(&nbsp;)</b> for stack-size checking aids.<p>The entry address <i>entryPt</i> is the address of the "main" routine of the task.The routine will be called once the C environment has been set up.The specified routine will be called with the ten given arguments.Should the specified main routine return, a call to <b><i><a href="./taskLib.html#exit">exit</a></i>(&nbsp;)</b> willautomatically be made.<p>Note that ten (and only ten) arguments must be passed for thespawned function.<p>Bits in the options argument may be set to run with the following modes:<dl><dt><b>VX_FP_TASK</b>  (0x0008)<dd>execute with floating-point coprocessor support.<p><dt><b>VX_PRIVATE_ENV</b>  (0x0080)<dd>include private environment support (see <b><a href="./envLib.html#top">envLib</a></b>).<p><dt><b>VX_NO_STACK_FILL</b>  (0x0100)<dd>do not fill the stack for use by <b><i><a href="./usrLib.html#checkStack">checkStack</a></i>(&nbsp;)</b>.<p><dt><b>VX_UNBREAKABLE</b>  (0x0002)<dd> do not allow breakpoint debugging. </dl><p>See the definitions in <b>taskLib.h</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>The task ID, or ERROR if memory is insufficient or the taskcannot be created.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_intLib_NOT_ISR_CALLABLE, S_objLib_OBJ_ID_ERROR,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S_smObjLib_NOT_INITIALIZED,&nbsp;S_memLib_NOT_ENOUGH_MEMORY,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S_memLib_BLOCK_ERROR<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./taskLib.html#top">taskLib</a></b>, <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b>, <b><i><a href="./taskLib.html#taskActivate">taskActivate</a></i>(&nbsp;)</b>, <b><i><a href="./usrLib.html#sp">sp</a></i>(&nbsp;)</b>,  <i>VxWorks Programmer's Guide: Basic OS</i><p>VARARGS5<hr><a name="taskInit"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>taskInit</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>taskInit</i>(&nbsp;)</strong> - initialize a task with a stack at a specified address</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS taskInit    (    WIND_TCB * pTcb,       /* address of new task's TCB */    char *     name,       /* name of new task (stored at pStackBase) */    int        priority,   /* priority of new task */    int        options,    /* task option word */    char *     pStackBase, /* base of new task's stack */    int        stackSize,  /* size (bytes) of stack needed */    FUNCPTR    entryPt,    /* entry point of new task */    int        arg1,       /* first of ten task args to pass to func */    int        arg2,    int        arg3,    int        arg4,    int        arg5,    int        arg6,    int        arg7,    int        arg8,    int        arg9,    int        arg10    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes user-specified regions of memory for a task stackand control block instead of allocating them from memory as <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>does.  This routine will utilize the specified pointers to the <b>WIND_TCB</b>and stack as the components of the task.  This allows, for example, theinitialization of a static <b>WIND_TCB</b> variable.  It also allows for specialstack positioning as a debugging aid.<p>As in <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>, a task may be given a name.  While <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>automatically names unnamed tasks, <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b> permits the existence oftasks without names.  The task ID required by other task routinesis simply the address <i>pTcb</i>, cast to an integer.<p>Note that the task stack may grow up or down from pStackBase, depending onthe target architecture.<p>Other arguments are the same as in <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>.  Unlike <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b>,<b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b> does not activate the task.  This must be done by calling<b><i><a href="./taskLib.html#taskActivate">taskActivate</a></i>(&nbsp;)</b> after calling <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b>.<p>Normally, tasks should be started using <b><i><a href="./taskLib.html#taskSpawn">taskSpawn</a></i>(&nbsp;)</b> rather than <b><i><a href="./taskLib.html#taskInit">taskInit</a></i>(&nbsp;)</b>,except when additional control is required for task memory allocation ora separate task activation is desired.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the task cannot be initialized.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_intLib_NOT_ISR_CALLABLE, S_objLib_OBJ_ID_ERROR

⌨️ 快捷键说明

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