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

📄 os_core.lst

📁 uCOS-II_2.52在51上的移植程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 207          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 208          *********************************************************************************************************
 209          */
 210          
 211          #if OS_SCHED_LOCK_EN > 0
 212          void  OSSchedLock (void) reentrant
 213          {
 214   1      
 215   1          
 216   1          
 217   1          if (OSRunning == TRUE) {                     /* Make sure multitasking is running                  */
 218   2              OS_ENTER_CRITICAL();
 219   2              if (OSLockNesting < 255) {               /* Prevent OSLockNesting from wrapping back to 0      */
 220   3                  OSLockNesting++;                     /* Increment lock nesting level                       */
 221   3              }
 222   2              OS_EXIT_CRITICAL();
 223   2          }
 224   1      }
 225          #endif    
 226          
 227          /*$PAGE*/
 228          /*
 229          *********************************************************************************************************
 230          *                                          ENABLE SCHEDULING
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 5   

 231          *
 232          * Description: This function is used to re-allow rescheduling.
 233          *
 234          * Arguments  : none
 235          *
 236          * Returns    : none
 237          *
 238          * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every
 239          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 240          *********************************************************************************************************
 241          */
 242          
 243          #if OS_SCHED_LOCK_EN > 0
 244          void  OSSchedUnlock (void) reentrant
 245          {
 246   1      
 247   1          
 248   1          if (OSRunning == TRUE) {                                   /* Make sure multitasking is running    */
 249   2              OS_ENTER_CRITICAL();
 250   2              if (OSLockNesting > 0) {                               /* Do not decrement if already 0        */
 251   3                  OSLockNesting--;                                   /* Decrement lock nesting level         */
 252   3                  if ((OSLockNesting == 0) && (OSIntNesting == 0)) { /* See if sched. enabled and not an ISR */
 253   4                      OS_EXIT_CRITICAL();
 254   4                      OS_Sched();                                    /* See if a HPT is ready                */
 255   4                  } else {
 256   4                      OS_EXIT_CRITICAL();
 257   4                  }
 258   3              } else {
 259   3                  OS_EXIT_CRITICAL();
 260   3              }
 261   2          }
 262   1      }
 263          #endif    
 264          
 265          /*$PAGE*/
 266          /*
 267          *********************************************************************************************************
 268          *                                          START MULTITASKING
 269          *
 270          * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
 271          *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
 272          *              and you MUST have created at least one task.
 273          *
 274          * Arguments  : none
 275          *
 276          * Returns    : none
 277          *
 278          * Note       : OSStartHighRdy() MUST:
 279          *                 a) Call OSTaskSwHook() then,
 280          *                 b) Set OSRunning to TRUE.
 281          *                 c) Load the context of the task pointed to by OSTCBHighRdy.
 282          *                 d_ Execute the task.
 283          *********************************************************************************************************
 284          */
 285          
 286          void  OSStart (void) reentrant
 287          {
 288   1          INT8U y;
 289   1          INT8U x;
 290   1      
 291   1      
 292   1          if (OSRunning == FALSE) {
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 6   

 293   2              y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
 294   2              x             = OSUnMapTbl[OSRdyTbl[y]];
 295   2              OSPrioHighRdy = (INT8U)((y << 3) + x);
 296   2              OSPrioCur     = OSPrioHighRdy;
 297   2              OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
 298   2              OSTCBCur      = OSTCBHighRdy;
 299   2              OSStartHighRdy();                            /* Execute target specific code to start task     */
 300   2          }
 301   1      }
 302          /*$PAGE*/
 303          /*
 304          *********************************************************************************************************
 305          *                                        STATISTICS INITIALIZATION
 306          *
 307          * Description: This function is called by your application to establish CPU usage by first determining
 308          *              how high a 32-bit counter would count to in 1 second if no other tasks were to execute
 309          *              during that time.  CPU usage is then determined by a low priority task which keeps track
 310          *              of this 32-bit counter every second but this time, with other tasks running.  CPU usage is
 311          *              determined by:
 312          *
 313          *                                             OSIdleCtr
 314          *                 CPU Usage (%) = 100 * (1 - ------------)
 315          *                                            OSIdleCtrMax
 316          *
 317          * Arguments  : none
 318          *
 319          * Returns    : none
 320          *********************************************************************************************************
 321          */
 322          
 323          #if OS_TASK_STAT_EN > 0
              void  OSStatInit (void) reentrant
              {
              
                  
                  
                  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
 340          /*$PAGE*/
 341          /*
 342          *********************************************************************************************************
 343          *                                         PROCESS SYSTEM TICK
 344          *
 345          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 346          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 347          *              called by a high priority task.
 348          *
 349          * Arguments  : none
 350          *
 351          * Returns    : none
 352          *********************************************************************************************************
 353          */
 354          
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 7   

 355          void  OSTimeTick (void) reentrant
 356          {
 357   1        
 358   1          OS_TCB    *ptcb;
 359   1      
 360   1      
 361   1          OSTimeTickHook();                                      /* Call user definable hook                 */
 362   1      #if OS_TIME_GET_SET_EN > 0   
 363   1          OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter           */
 364   1          OSTime++;
 365   1          OS_EXIT_CRITICAL();
 366   1      #endif
 367   1          if (OSRunning == TRUE) {    
 368   2              ptcb = OSTCBList;                                  /* Point at first TCB in TCB list           */
 369   2              while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {          /* Go through all TCBs in TCB list          */
 370   3                  OS_ENTER_CRITICAL();
 371   3                  if (ptcb->OSTCBDly != 0) {                     /* Delayed or waiting for event with TO     */
 372   4                      if (--ptcb->OSTCBDly == 0) {               /* Decrement nbr of ticks to end of delay   */
 373   5                          if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?    */
 374   6                              OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task R-to-R (timed out)*/
 375   6                              OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 376   6                          } else {                               /* Yes, Leave 1 tick to prevent ...         */
 377   6                              ptcb->OSTCBDly = 1;                /* ... loosing the task when the ...        */
 378   6                          }                                      /* ... suspension is removed.               */
 379   5                      }
 380   4                  }
 381   3                  ptcb = ptcb->OSTCBNext;                        /* Point at next TCB in TCB list            */
 382   3                  OS_EXIT_CRITICAL();
 383   3              }
 384   2          }
 385   1      }
 386          /*$PAGE*/
 387          /*
 388          *********************************************************************************************************
 389          *                                             GET VERSION
 390          *
 391          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 392          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 393          *              would be returned as 200.
 394          *
 395          * Arguments  : none
 396          *
 397          * Returns    : the version number of uC/OS-II multiplied by 100.
 398          *********************************************************************************************************
 399          */
 400          
 401          INT16U  OSVersion (void) reentrant
 402          {
 403   1          return (OS_VERSION);
 404   1      }
 405          
 406          /*$PAGE*/
 407          /*
 408          *********************************************************************************************************
 409          *                                            DUMMY FUNCTION
 410          *
 411          * Description: This function doesn't do anything.  It is called by OSTaskDel().
 412          *
 413          * Arguments  : none
 414          *
 415          * Returns    : none
 416          *********************************************************************************************************
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 8   

 417          */
 418          
 419          #if OS_TASK_DEL_EN > 0
              void  OS_Dummy (void)
              {
              }
              #endif
 424          
 425          /*$PAGE*/
 426          /*
 427          *********************************************************************************************************
 428          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
 429          *
 430          * Description: This function is called by other uC/OS-II services and is used to ready a task that was

⌨️ 快捷键说明

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