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

📄 os_core.lst

📁 该程序是ucosii在51单片机上的移置
💻 LST
📖 第 1 页 / 共 4 页
字号:
                      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
 665          /*$PAGE*/
 666          /*
 667          *********************************************************************************************************
 668          *                                            INITIALIZE TCB
 669          *
 670          * Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
C51 COMPILER V7.06   OS_CORE                                                               02/21/2006 13:52:52 PAGE 12  

 671          *              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
 672          *
 673          * Arguments  : prio          is the priority of the task being created
 674          *
 675          *              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
 676          *                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
 677          *                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
 678          *                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
 679          *                            specific.
 680          *
 681          *              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
 682          *                            'OSTaskCreate()'.
 683          *
 684          *              id            is the task's ID (0..65535)
 685          *
 686          *              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
 687          *                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
 688          *                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
 689          *                            units are established by the #define constant OS_STK which is CPU
 690          *                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
 691          *
 692          *              pext          is a pointer to a user supplied memory area that is used to extend the task
 693          *                            control block.  This allows you to store the contents of floating-point
 694          *                            registers, MMU registers or anything else you could find useful during a 
 695          *                            context switch.  You can even assign a name to each task and store this name
 696          *                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
 697          *
 698          *              opt           options as passed to 'OSTaskCreateExt()' or, 
 699          *                            0 if called from 'OSTaskCreate()'.
 700          *
 701          * Returns    : OS_NO_ERR         if the call was successful
 702          *              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
 703          *                                be created.
 704          *
 705          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 706          *********************************************************************************************************
 707          */
 708          static OS_TCB *ptcb11;
 709          INT8U OSTCBInit (INT8U prio, 
 710                           OS_STK *ptos, 
 711                           OS_STK *pbos, 
 712                           INT16U id, 
 713                           INT16U stk_size, 
 714                           void *pext, 
 715                           INT16U opt)reentrant
 716          {
 717   1          OS_ENTER_CRITICAL();
 718   1          ptcb11 = OSTCBFreeList;                                  /* Get a free TCB from the free TCB list    *
             -/
 719   1          if (ptcb11 != (OS_TCB *)0) {
 720   2              OSTCBFreeList        = ptcb11->OSTCBNext;            /* Update pointer to free TCB list          *
             -/
 721   2              OS_EXIT_CRITICAL();
 722   2              ptcb11->OSTCBStkPtr    = ptos;                       /* Load Stack pointer in TCB                *
             -/
 723   2              ptcb11->OSTCBPrio      = (INT8U)prio;                /* Load task priority into TCB              *
             -/
 724   2              ptcb11->OSTCBStat      = OS_STAT_RDY;                /* Task is ready to run                     *
             -/
 725   2              ptcb11->OSTCBDly       = 0;                          /* Task is not delayed                      *
             -/
 726   2      
C51 COMPILER V7.06   OS_CORE                                                               02/21/2006 13:52:52 PAGE 13  

 727   2      #if OS_TASK_CREATE_EXT_EN        
                      ptcb11->OSTCBExtPtr    = pext;                       /* Store pointer to TCB extension           *
             -/
                      ptcb11->OSTCBStkSize   = stk_size;                   /* Store stack size                         *
             -/
                      ptcb11->OSTCBStkBottom = pbos;                       /* Store pointer to bottom of stack         *
             -/
                      ptcb11->OSTCBOpt       = opt;                        /* Store task options                       *
             -/
                      ptcb11->OSTCBId        = id;                         /* Store task ID                            *
             -/
              #else
 734   2              pext                 = pext;                       /* Prevent compiler warning if not used     */
 735   2              stk_size             = stk_size;
 736   2              pbos                 = pbos;
 737   2              opt                  = opt;
 738   2              id                   = id;
 739   2      #endif
 740   2      
 741   2      #if OS_TASK_DEL_EN        
                      ptcb11->OSTCBDelReq    = OS_NO_ERR;
              #endif
 744   2      
 745   2              ptcb11->OSTCBY         = prio >> 3;                  /* Pre-compute X, Y, BitX and BitY          *
             -/
 746   2              ptcb11->OSTCBBitY      = OSMapTbl[ptcb11->OSTCBY];
 747   2              ptcb11->OSTCBX         = prio & 0x07;
 748   2              ptcb11->OSTCBBitX      = OSMapTbl[ptcb11->OSTCBX];
 749   2      
 750   2      #if     OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_Sem_EN
 751   2              ptcb11->OSTCBEventPtr  = (OS_EVENT *)0;              /* Task is not pending on an event          *
             -/
 752   2      #endif
 753   2      
 754   2      #if     OS_MBOX_EN || (OS_Q_EN && (OS_MAX_QS >= 2))
                      ptcb11->OSTCBMsg       = (void *)0;                  /* No message received                      *
             -/
              #endif
 757   2      
 758   2              OS_ENTER_CRITICAL();
 759   2              OSTCBPrioTbl[prio]   = ptcb11;
 760   2              ptcb11->OSTCBNext      = OSTCBList;                  /* Link into TCB chain                      *
             -/
 761   2              ptcb11->OSTCBPrev      = (OS_TCB *)0;
 762   2              if (OSTCBList != (OS_TCB *)0) {
 763   3                  OSTCBList->OSTCBPrev = ptcb11;
 764   3              }
 765   2              OSTCBList               = ptcb11;
 766   2              OSRdyGrp               |= ptcb11->OSTCBBitY;         /* Make task ready to run                   *
             -/
 767   2              OSRdyTbl[ptcb11->OSTCBY] |= ptcb11->OSTCBBitX;
 768   2              OS_EXIT_CRITICAL();
 769   2              return (OS_NO_ERR);
 770   2          } else {
 771   2              OS_EXIT_CRITICAL();
 772   2              return (OS_NO_MORE_TCB);
 773   2          }
 774   1      }
 775          /*$PAGE*/
 776          /*
 777          *********************************************************************************************************
 778          *                                         PROCESS SYSTEM TICK
C51 COMPILER V7.06   OS_CORE                                                               02/21/2006 13:52:52 PAGE 14  

 779          *
 780          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 781          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 782          *              called by a high priority task.
 783          *
 784          * Arguments  : none
 785          *
 786          * Returns    : none
 787          *********************************************************************************************************
 788          */
 789          
 790          void OSTimeTick (void)
 791          {
 792   1          OS_TCB *ptcb;
 793   1      
 794   1      
 795   1          OSTimeTickHook();                                      /* Call user definable hook                 */
 796   1          ptcb = OSTCBList;                                      /* Point at first TCB in TCB list           */
 797   1          while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {              /* Go through all TCBs in TCB list          */
 798   2              OS_ENTER_CRITICAL();
 799   2              if (ptcb->OSTCBDly != 0) {                         /* Delayed or waiting for event with TO     */
 800   3                  if (--ptcb->OSTCBDly == 0) {                   /* Decrement nbr of ticks to end of delay   */
 801   4                      if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {    /* Is task suspended?                   */
 802   5                          OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task Rdy to Run (timed out)*/
 803   5                          OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 804   5                      } else {                                       /* Yes, Leave 1 tick to prevent ...     */
 805   5                          ptcb->OSTCBDly = 1;                        /* ... loosing the task when the ...    */
 806   5                      }                                              /* ... suspension is removed.           */
 807   4                  }
 808   3              }
 809   2              ptcb = ptcb->OSTCBNext;                            /* Point at next TCB in TCB list            */
 810   2              OS_EXIT_CRITICAL();
 811   2          }
 812   1          OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter           */
 813   1          OSTime++;
 814   1          OS_EXIT_CRITICAL();
 815   1      }
 816          /*$PAGE*/
 817          /*
 818          *********************************************************************************************************
 819          *                                             GET VERSION
 820          *
 821          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 822          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 823          *              would be returned as 200.
 824          *
 825          * Arguments  : none
 826          *
 827          * Returns    : the version number of uC/OS-II multiplied by 100.
 828          *********************************************************************************************************
 829          */
 830          #if  OS_VERSION_CHK_EN
              INT16U OSVersion (void)reentrant
              {
                  return (OS_VERSION);
              }
              #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2802    ----
   CONSTANT SIZE    =    264    ----
C51 COMPILER V7.06   OS_CORE                                                               02/21/2006 13:52:52 PAGE 15  

   XDATA SIZE       =    245       5
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3    ----
   IDATA SIZE       =      9    ----
   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 + -