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

📄 os_core.lst

📁 ucos v2.62 安装程序 附带已移植到C8051F020的UCOS源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
 442          *                 a) Call OSTaskSwHook() then,
 443          *                 b) Set OSRunning to TRUE.
 444          *                 c) Load the context of the task pointed to by OSTCBHighRdy.
 445          *                 d_ Execute the task.
 446          *********************************************************************************************************
 447          */
 448          
 449          void  OSStart (void) KCREENTRANT        
 450          {
 451   1          INT8U y;
 452   1          INT8U x;
 453   1      
 454   1      
 455   1          if (OSRunning == FALSE) {
 456   2              y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
 457   2              x             = OSUnMapTbl[OSRdyTbl[y]];
 458   2              OSPrioHighRdy = (INT8U)((y << 3) + x);
 459   2              OSPrioCur     = OSPrioHighRdy;
 460   2              OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
 461   2              OSTCBCur      = OSTCBHighRdy;
 462   2              OSStartHighRdy();                            /* Execute target specific code to start task     */
 463   2          }
 464   1      }
 465          /*$PAGE*/
 466          /*
 467          *********************************************************************************************************
 468          *                                        STATISTICS INITIALIZATION
 469          *
 470          * Description: This function is called by your application to establish CPU usage by first determining
 471          *              how high a 32-bit counter would count to in 1 second if no other tasks were to execute
 472          *              during that time.  CPU usage is then determined by a low priority task which keeps track
 473          *              of this 32-bit counter every second but this time, with other tasks running.  CPU usage is
 474          *              determined by:
 475          *
 476          *                                             OSIdleCtr
 477          *                 CPU Usage (%) = 100 * (1 - ------------)
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 9   

 478          *                                            OSIdleCtrMax
 479          *
 480          * Arguments  : none
 481          *
 482          * Returns    : none
 483          *********************************************************************************************************
 484          */
 485          
 486          #if OS_TASK_STAT_EN > 0
              void  OSStatInit (void)
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
                  
                  
                  OSTimeDly(2);                                /* Synchronize with clock tick                        */
                  OS_ENTER_CRITICAL();
                  OSIdleCtr    = 0L;                           /* Clear idle counter                                 */
                  OS_EXIT_CRITICAL();
                  OSTimeDly(OS_TICKS_PER_SEC);                 /* Determine MAX. idle counter value for 1 second     */
                  OS_ENTER_CRITICAL();
                  OSIdleCtrMax = OSIdleCtr;                    /* Store maximum idle counter count in 1 second       */
                  OSStatRdy    = TRUE;
                  OS_EXIT_CRITICAL();
              }
              #endif
 505          /*$PAGE*/
 506          /*
 507          *********************************************************************************************************
 508          *                                         PROCESS SYSTEM TICK
 509          *
 510          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 511          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 512          *              called by a high priority task.
 513          *
 514          * Arguments  : none
 515          *
 516          * Returns    : none
 517          *********************************************************************************************************
 518          */
 519          
 520          void  OSTimeTick (void) KCREENTRANT
 521          {
 522   1      #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register    
             - */
                  OS_CPU_SR  cpu_sr;
              #endif    
 525   1          OS_TCB    *ptcb;
 526   1          BOOLEAN    step;
 527   1      
 528   1              
 529   1      #if OS_TIME_TICK_HOOK_EN > 0
 530   1          OSTimeTickHook();                                      /* Call user definable hook                    
             - */
 531   1      #endif    
 532   1      #if OS_TIME_GET_SET_EN > 0   
 533   1          OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter              
             - */
 534   1          OSTime++;
 535   1          OS_EXIT_CRITICAL();
 536   1      #endif
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 10  

 537   1          if (OSRunning == TRUE) {    
 538   2      #if OS_TICK_STEP_EN > 0
 539   2              switch (OSTickStepState) {                         /* Determine whether we need to process a tick 
             - */
 540   3                  case OS_TICK_STEP_DIS:                         /* Yes, stepping is disabled                   
             - */
 541   3                       step = TRUE;
 542   3                       break;
 543   3              
 544   3                  case OS_TICK_STEP_WAIT:                        /* No,  waiting for uC/OS-View to set ...      
             - */
 545   3                       step = FALSE;                             /*      .. OSTickStepState to OS_TICK_STEP_ONCE
             - */
 546   3                       break;
 547   3      
 548   3                  case OS_TICK_STEP_ONCE:                        /* Yes, process tick once and wait for next ...
             - */
 549   3                       step            = TRUE;                   /*      ... step command from uC/OS-View       
             - */
 550   3                       OSTickStepState = OS_TICK_STEP_WAIT;
 551   3                       break;  
 552   3      
 553   3                  default:                                       /* Invalid case, correct situation             
             - */
 554   3                       step            = TRUE;
 555   3                       OSTickStepState = OS_TICK_STEP_DIS;
 556   3                       break;
 557   3              }
 558   2      #else
                      step = TRUE;
              #endif
 561   2              if (step == TRUE) {
 562   3                  ptcb = OSTCBList;
 563   3                              P3=0xff;                              /* Point at first TCB in TCB list               */
 564   3                  while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {      /* Go through all TCBs in TCB list             
             - */
 565   4                      OS_ENTER_CRITICAL();
 566   4                      if (ptcb->OSTCBDly != 0) {                 /* Delayed or waiting for event with TO        
             - */
 567   5                          if (--ptcb->OSTCBDly == 0) {           /* Decrement nbr of ticks to end of delay      
             - */
 568   6                              if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?   
             - */
 569   7                                  OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task R-to-R (timed out
             -)*/
 570   7                                  OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 571   7                              } else {                           /* Yes, Leave 1 tick to prevent loosing the ...
             - */
 572   7                                  ptcb->OSTCBDly = 1;            /* ... task when the suspension is removed.    
             - */
 573   7                              }
 574   6                          }
 575   5                      }
 576   4                      ptcb = ptcb->OSTCBNext;                    /* Point at next TCB in TCB list               
             - */
 577   4                      OS_EXIT_CRITICAL();
 578   4                  }
 579   3                              P3=0x00;
 580   3              }
 581   2          }
 582   1      }
 583          /*$PAGE*/
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 11  

 584          /*
 585          *********************************************************************************************************
 586          *                                             GET VERSION
 587          *
 588          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 589          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 590          *              would be returned as 200.
 591          *
 592          * Arguments  : none
 593          *
 594          * Returns    : the version number of uC/OS-II multiplied by 100.
 595          *********************************************************************************************************
 596          */
 597          
 598          INT16U  OSVersion (void)KCREENTRANT     
 599          {
 600   1          return (OS_VERSION);
 601   1      }
 602          
 603          /*$PAGE*/
 604          /*
 605          *********************************************************************************************************
 606          *                                            DUMMY FUNCTION
 607          *
 608          * Description: This function doesn't do anything.  It is called by OSTaskDel().
 609          *
 610          * Arguments  : none
 611          *
 612          * Returns    : none
 613          *********************************************************************************************************
 614          */
 615          
 616          #if OS_TASK_DEL_EN > 0
 617          void  OS_Dummy (void) KCREENTRANT       
 618          {
 619   1      }
 620          #endif
 621          
 622          /*$PAGE*/
 623          /*
 624          *********************************************************************************************************
 625          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
 626          *
 627          * Description: This function is called by other uC/OS-II services and is used to ready a task that was
 628          *              waiting for an event to occur.
 629          *
 630          * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
 631          *
 632          *              msg       is a pointer to a message.  This pointer is used by message oriented services
 633          *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
 634          *                        service functions.
 635          *
 636          *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
 637          *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
 638          *
 639          * Returns    : none
 640          *
 641          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 642          *********************************************************************************************************
 643          */
 644          #if OS_EVENT_EN > 0
              INT8U  OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) KCREENTRANT     
C51 COMPILER V8.05a   OS_CORE                                                              04/11/2007 16:19:49 PAGE 12  

              {
                  OS_TCB *ptcb;
                  INT8U   x;
                  INT8U   y;
                  INT8U   bitx;
                  INT8U   bity;
                  INT8U   prio;
              

⌨️ 快捷键说明

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