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

📄 os_core.lst

📁 在C8051F120内移植uCOS-II
💻 LST
📖 第 1 页 / 共 4 页
字号:
                      OSIdleCtr    = 0L;                       /* Reset the idle counter for the next second         */
                      OS_EXIT_CRITICAL();
                      if (OSIdleCtrMax > 0L) {
                          usage = (INT8S)(100L - 100L * run / OSIdleCtrMax);
                          if (usage > 100) {
                              OSCPUUsage = 100;
                          } else if (usage < 0) {
                              OSCPUUsage =   0;
                          } else {
                              OSCPUUsage = usage;
                          }
                      } else {
                          OSCPUUsage = 0;
                      }
                      OSTaskStatHook();                        /* Invoke user definable hook                         */
                      OSTimeDly(OS_TICKS_PER_SEC);             /* Accumulate OSIdleCtr for the next second           */
                  }
              }
              #endif
 695          /*$PAGE*/
 696          /*
 697          *********************************************************************************************************
 698          *                                            INITIALIZE TCB
 699          *
 700          * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
 701          *              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
 702          *
 703          * Arguments  : prio          is the priority of the task being created
 704          *
 705          *              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
 706          *                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
 707          *                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
 708          *                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
 709          *                            specific.
 710          *
 711          *              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
 712          *                            'OSTaskCreate()'.
 713          *
 714          *              id            is the task's ID (0..65535)
 715          *
 716          *              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
 717          *                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
 718          *                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
 719          *                            units are established by the #define constant OS_STK which is CPU
 720          *                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
 721          *
 722          *              pext          is a pointer to a user supplied memory area that is used to extend the task
 723          *                            control block.  This allows you to store the contents of floating-point
 724          *                            registers, MMU registers or anything else you could find useful during a 
 725          *                            context switch.  You can even assign a name to each task and store this name
 726          *                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
 727          *
 728          *              opt           options as passed to 'OSTaskCreateExt()' or, 
 729          *                            0 if called from 'OSTaskCreate()'.
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 13  

 730          *
 731          * Returns    : OS_NO_ERR         if the call was successful
 732          *              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
 733          *                                be created.
 734          *
 735          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 736          *********************************************************************************************************
 737          */
 738          static OS_TCB *ptcb11;
 739          INT8U OSTCBInit (INT8U prio, 
 740                           OS_STK *pbos, 
 741                           OS_STK *ptos, 
 742                           INT16U id, 
 743                           INT16U stk_size, 
 744                           void *pext, 
 745                           INT16U opt)reentrant
 746          {
 747   1              #if OS_CRITICAL_METHOD == 2
 748   1              unsigned DTYPE int_ss;
 749   1              #endif 
 750   1      
 751   1          OS_ENTER_CRITICAL();
 752   1          ptcb11 = OSTCBFreeList;                                  /* Get a free TCB from the free TCB list    *
             -/
 753   1          if (ptcb11 != (OS_TCB *)0) {
 754   2              OSTCBFreeList        = ptcb11->OSTCBNext;            /* Update pointer to free TCB list          *
             -/
 755   2              OS_EXIT_CRITICAL();
 756   2              ptcb11->OSTCBStkPtr    = pbos;                       /* Load Stack pointer in TCB                *
             -/
 757   2              ptcb11->OSTCBPrio      = (INT8U)prio;                /* Load task priority into TCB              *
             -/
 758   2              ptcb11->OSTCBStat      = OS_STAT_RDY;                /* Task is ready to run                     *
             -/
 759   2              ptcb11->OSTCBDly       = 0;                          /* Task is not delayed                      *
             -/
 760   2      
 761   2      #if OS_TASK_CREATE_EXT_EN        
 762   2              ptcb11->OSTCBExtPtr    = pext;                       /* Store pointer to TCB extension           *
             -/
 763   2              ptcb11->OSTCBStkSize   = stk_size;                   /* Store stack size                         *
             -/
 764   2              ptcb11->OSTCBStkTop    = ptos;                       /* Store pointer to bottom of stack         *
             -/
 765   2              ptcb11->OSTCBOpt       = opt;                        /* Store task options                       *
             -/
 766   2              ptcb11->OSTCBId        = id;                         /* Store task ID                            *
             -/
 767   2      #else
                      pext                 = pext;                       /* Prevent compiler warning if not used     */
                      stk_size             = stk_size;
                      pbos                 = pbos;
                      opt                  = opt;
                      id                   = id;
              #endif
 774   2      
 775   2      #if OS_TASK_DEL_EN        
                      ptcb11->OSTCBDelReq    = OS_NO_ERR;
              #endif
 778   2      
 779   2              ptcb11->OSTCBY         = prio >> 3;                  /* Pre-compute X, Y, BitX and BitY          *
             -/
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 14  

 780   2              ptcb11->OSTCBBitY      = OSMapTbl[ptcb11->OSTCBY];
 781   2              ptcb11->OSTCBX         = prio & 0x07;
 782   2              ptcb11->OSTCBBitX      = OSMapTbl[ptcb11->OSTCBX];
 783   2      
 784   2      #if     OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_Sem_EN
 785   2              ptcb11->OSTCBEventPtr  = (OS_EVENT *)0;              /* Task is not pending on an event          *
             -/
 786   2      #endif
 787   2      
 788   2      #if     OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2))
                      ptcb11->OSTCBMsg       = (void *)0;                  /* No message received                      *
             -/
              #endif
 791   2      
 792   2              OS_ENTER_CRITICAL();
 793   2              OSTCBPrioTbl[prio]   = ptcb11;
 794   2              ptcb11->OSTCBNext      = OSTCBList;                  /* Link into TCB chain                      *
             -/
 795   2              ptcb11->OSTCBPrev      = (OS_TCB *)0;
 796   2              if (OSTCBList != (OS_TCB *)0) {
 797   3                  OSTCBList->OSTCBPrev = ptcb11;
 798   3              }
 799   2              OSTCBList               = ptcb11;
 800   2              OSRdyGrp               |= ptcb11->OSTCBBitY;         /* Make task ready to run                   *
             -/
 801   2              OSRdyTbl[ptcb11->OSTCBY] |= ptcb11->OSTCBBitX;
 802   2              OS_EXIT_CRITICAL();
 803   2              return (OS_NO_ERR);
 804   2          } else {
 805   2              OS_EXIT_CRITICAL();
 806   2              return (OS_NO_MORE_TCB);
 807   2          }
 808   1      }
 809          /*$PAGE*/
 810          /*
 811          *********************************************************************************************************
 812          *                                         PROCESS SYSTEM TICK
 813          *
 814          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 815          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 816          *              called by a high priority task.
 817          *
 818          * Arguments  : none
 819          *
 820          * Returns    : none
 821          *********************************************************************************************************
 822          */
 823          
 824          void OSTimeTick (void)
 825          {
 826   1          #if OS_CRITICAL_METHOD == 2
 827   1              unsigned DTYPE int_ss;
 828   1              #endif 
 829   1      
 830   1              OS_TCB *ptcb;
 831   1      
 832   1      
 833   1          OSTimeTickHook();                                      /* Call user definable hook                 */
 834   1          ptcb = OSTCBList;                                      /* Point at first TCB in TCB list           */
 835   1          while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {              /* Go through all TCBs in TCB list          */
 836   2              OS_ENTER_CRITICAL();
 837   2              if (ptcb->OSTCBDly != 0) {                         /* Delayed or waiting for event with TO     */
C51 COMPILER V8.08   OS_CORE                                                               04/13/2009 13:31:21 PAGE 15  

 838   3                  if (--ptcb->OSTCBDly == 0) {                   /* Decrement nbr of ticks to end of delay   */
 839   4                      if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {    /* Is task suspended?                   */
 840   5                          OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task Rdy to Run (timed out)*/
 841   5                          OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 842   5                      } else {                                       /* Yes, Leave 1 tick to prevent ...     */
 843   5                          ptcb->OSTCBDly = 1;                        /* ... loosing the task when the ...    */
 844   5                      }                                              /* ... suspension is removed.           */
 845   4                  }
 846   3              }
 847   2              ptcb = ptcb->OSTCBNext;                            /* Point at next TCB in TCB list            */
 848   2              OS_EXIT_CRITICAL();
 849   2          }
 850   1          OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter           */
 851   1          OSTime++;
 852   1          OS_EXIT_CRITICAL();
 853   1      }
 854          /*$PAGE*/
 855          /*
 856          *********************************************************************************************************
 857          *                                             GET VERSION
 858          *
 859          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 860          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 861          *              would be returned as 200.
 862          *
 863          * Arguments  : none
 864          *
 865          * Returns    : the version number of uC/OS-II multiplied by 100.
 866          *********************************************************************************************************
 867          */
 868          #if  OS_VERSION_CHK_EN
              INT16U OSVersion (void)reentrant
              {
                  return (OS_VERSION);
              }
              #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2405    ----
   CONSTANT SIZE    =    264    ----
   XDATA SIZE       =    259    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3      11
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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