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

📄 os_task.lst

📁 运行环境是keil。这是一个实现嵌入式TCP/IP的程序
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V6.12  OS_TASK                                                                04/12/2004 19:13:38 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE OS_TASK
OBJECT MODULE PLACED IN .\DEBUG\OS_TASK.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\CORE\SOURCE\OS_TASK.C LARGE OPTIMIZE(6,SPEED) BROWSE DEBUG OBJECTEXTEND P
                    -RINT(.\DEBUG\OS_TASK.lst) OBJECT(.\DEBUG\OS_TASK.obj) 

stmt level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/OS-II
   4          *                                          The Real-Time Kernel
   5          *                                            TASK MANAGEMENT
   6          *
   7          *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
   8          *                                           All Rights Reserved
   9          *
  10          *                                                  V2.00
  11          *
  12          * File : OS_TASK.C
  13          * By   : Jean J. Labrosse
  14          *********************************************************************************************************
  15          */
  16          
  17          #ifndef  OS_MASTER_FILE
  18          #include    <CORE\includes.h> 
  19          #endif
  20          
  21          /*
  22          *********************************************************************************************************
  23          *                                        LOCAL FUNCTION PROTOTYPES
  24          *********************************************************************************************************
  25          */
  26          
  27          
  28          static  void  OSDummy(void) reentrant;
  29          
  30          /*
  31          *********************************************************************************************************
  32          *                                            DUMMY FUNCTION
  33          *
  34          * Description: This function doesn't do anything.  It is called by OSTaskDel() to ensure that interrupts
  35          *              are disabled immediately after they are enabled.
  36          *
  37          * Arguments  : none
  38          *
  39          * Returns    : none
  40          *********************************************************************************************************
  41          */
  42          
  43          static void  OSDummy (void) reentrant
  44          {
  45   1      }
  46          
  47          /*$PAGE*/
  48          /*
  49          *********************************************************************************************************
  50          *                                        CHANGE PRIORITY OF A TASK
  51          *
  52          * Description: This function allows you to change the priority of a task dynamically.  Note that the new
  53          *              priority MUST be available.
  54          *
C51 COMPILER V6.12  OS_TASK                                                                04/12/2004 19:13:38 PAGE 2   

  55          * Arguments  : oldp     is the old priority
  56          *
  57          *              newp     is the new priority
  58          *
  59          * Returns    : OS_NO_ERR        is the call was successful
  60          *              OS_PRIO_INVALID  if the priority you specify is higher that the maximum allowed
  61          *                               (i.e. >= OS_LOWEST_PRIO)
  62          *              OS_PRIO_EXIST    if the new priority already exist.
  63          *              OS_PRIO_ERR      there is no task with the specified OLD priority (i.e. the OLD task does
  64          *                               not exist.
  65          *********************************************************************************************************
  66          */
  67          
  68          #if OS_TASK_CHANGE_PRIO_EN
  69          INT8U OSTaskChangePrio (INT8U oldprio, INT8U newprio) reentrant
  70          {
  71   1          OS_TCB   *ptcb;
  72   1          OS_EVENT *pevent;
  73   1          INT8U     x;
  74   1          INT8U     y;
  75   1          INT8U     bitx;
  76   1          INT8U     bity;
  77   1      
  78   1      
  79   1          if ((oldprio >= OS_LOWEST_PRIO && oldprio != OS_PRIO_SELF)  ||
  80   1               newprio >= OS_LOWEST_PRIO) {
  81   2              return (OS_PRIO_INVALID);
  82   2          }
  83   1          OS_ENTER_CRITICAL();
  84   1          if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) {                 /* New priority must not already exist */
  85   2              OS_EXIT_CRITICAL();
  86   2              return (OS_PRIO_EXIST);
  87   2          } else {
  88   2              OSTCBPrioTbl[newprio] = (OS_TCB *)1;                    /* Reserve the entry to prevent others */
*** WARNING C196 IN LINE 88 OF .\CORE\SOURCE\OS_TASK.C: mspace probably invalid
  89   2              OS_EXIT_CRITICAL();
  90   2              y    = newprio >> 3;                                    /* Precompute to reduce INT. latency   */
  91   2              bity = OSMapTbl[y];
  92   2              x    = newprio & 0x07;
  93   2              bitx = OSMapTbl[x];
  94   2              OS_ENTER_CRITICAL();
  95   2              if (oldprio == OS_PRIO_SELF) {                          /* See if changing self                */
  96   3                  oldprio = OSTCBCur->OSTCBPrio;                      /* Yes, get priority                   */
  97   3              }
  98   2              if ((ptcb = OSTCBPrioTbl[oldprio]) != (OS_TCB *)0) {    /* Task to change must exist           */
  99   3                  OSTCBPrioTbl[oldprio] = (OS_TCB *)0;                /* Remove TCB from old priority        */
 100   3                  if (OSRdyTbl[ptcb->OSTCBY] & ptcb->OSTCBBitX) {     /* If task is ready make it not ready  */
 101   4                      if ((OSRdyTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
 102   5                          OSRdyGrp &= ~ptcb->OSTCBBitY;
 103   5                      }
 104   4                      OSRdyGrp    |= bity;                            /* Make new priority ready to run      */
 105   4                      OSRdyTbl[y] |= bitx;
 106   4                  } else {
 107   4                      if ((pevent = ptcb->OSTCBEventPtr) != (OS_EVENT *)0) { /* Remove from event wait list  */
 108   5                          if ((pevent->OSEventTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
 109   6                              pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
 110   6                          }
 111   5                          pevent->OSEventGrp    |= bity;              /* Add new priority to wait list       */
 112   5                          pevent->OSEventTbl[y] |= bitx;
 113   5                      }
 114   4                  }
 115   3                  OSTCBPrioTbl[newprio] = ptcb;                       /* Place pointer to TCB @ new priority */
C51 COMPILER V6.12  OS_TASK                                                                04/12/2004 19:13:38 PAGE 3   

 116   3                  ptcb->OSTCBPrio       = newprio;                    /* Set new task priority               */
 117   3                  ptcb->OSTCBY          = y;
 118   3                  ptcb->OSTCBX          = x;
 119   3                  ptcb->OSTCBBitY       = bity;
 120   3                  ptcb->OSTCBBitX       = bitx;
 121   3                  OS_EXIT_CRITICAL();
 122   3                  OSSched();                                          /* Run highest priority task ready     */
 123   3                  return (OS_NO_ERR);
 124   3              } else {
 125   3                  OSTCBPrioTbl[newprio] = (OS_TCB *)0;                /* Release the reserved prio.          */
 126   3                  OS_EXIT_CRITICAL();
 127   3                  return (OS_PRIO_ERR);                               /* Task to change didn't exist         */
 128   3              }
 129   2          }
 130   1      }
 131          #endif
 132          /*$PAGE*/
 133          /*
 134          *********************************************************************************************************
 135          *                                            CREATE A TASK
 136          *
 137          * Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can either
 138          *              be created prior to the start of multitasking or by a running task.  A task cannot be
 139          *              created by an ISR.
 140          *
 141          * Arguments  : task     is a pointer to the task's code
 142          *
 143          *              pdata    is a pointer to an optional data area which can be used to pass parameters to
 144          *                       the task when the task first executes.  Where the task is concerned it thinks
 145          *                       it was invoked and passed the argument 'pdata' as follows:
 146          *
 147          *                           void Task (void *pdata)
 148          *                           {
 149          *                               for (;;) {
 150          *                                   Task code;
 151          *                               }
 152          *                           }
 153          *
 154          *              ptos     is a pointer to the task's top of stack.  If the configuration constant
 155          *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
 156          *                       memory to low memory).  'pstk' will thus point to the highest (valid) memory
 157          *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will point to the
 158          *                       lowest memory location of the stack and the stack will grow with increasing
 159          *                       memory locations.
 160          *
 161          *              prio     is the task's priority.  A unique priority MUST be assigned to each task and the
 162          *                       lower the number, the higher the priority.
 163          *
 164          * Returns    : OS_NO_ERR        if the function was successful.
 165          *              OS_PRIO_EXIT     if the task priority already exist
 166          *                               (each task MUST have a unique priority).
 167          *              OS_PRIO_INVALID  if the priority you specify is higher that the maximum allowed
 168          *                               (i.e. >= OS_LOWEST_PRIO)
 169          *********************************************************************************************************
 170          */
 171          
 172          #if OS_TASK_CREATE_EN
 173          INT8U OSTaskCreate (void (*task)(void *pd), void *ppdata, OS_STK *ptos, INT8U prio) reentrant
 174          {
 175   1          void   *psp;
 176   1          INT8U   err;
 177   1      

⌨️ 快捷键说明

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