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

📄 os_core.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
 632          * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When
 633          *              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
 634          *              a new, high-priority task, is ready to run.
 635          *
 636          * Arguments  : none
 637          *
 638          * Returns    : none
 639          *
 640          * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 641          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 642          *                 end of the ISR.
 643          *              2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
 644          *********************************************************************************************************
 645          */
 646          
 647          void  OSIntExit (void) reentrant
 648          {
 649   1      #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 652   1      
 653   1      
 654   1      
 655   1          if (OSRunning == OS_TRUE) {
 656   2              OS_ENTER_CRITICAL();
 657   2              if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping       */
 658   3                  OSIntNesting--;
 659   3              }
 660   2              if (OSIntNesting == 0) {                           /* Reschedule only if all ISRs complete ... */
C51 COMPILER V8.17   OS_CORE                                                               03/26/2009 14:24:24 PAGE 12  

 661   3                  if (OSLockNesting == 0) {                      /* ... and not locked.                      */
 662   4                      OS_SchedNew();
 663   4                      if (OSPrioHighRdy != OSPrioCur) {          /* No Ctx Sw if current task is highest rdy */
 664   5                          OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
 665   5      #if OS_TASK_PROFILE_EN > 0
                                  OSTCBHighRdy->OSTCBCtxSwCtr++;         /* Inc. # of context switches to this task  */
              #endif
 668   5                          OSCtxSwCtr++;                          /* Keep track of the number of ctx switches */
 669   5                          OSIntCtxSw();                          /* Perform interrupt level ctx switch       */
 670   5                      }
 671   4                  }
 672   3              }
 673   2              OS_EXIT_CRITICAL();
 674   2          }
 675   1      }
 676          /*$PAGE*/
 677          /*
 678          *********************************************************************************************************
 679          *                                          PREVENT SCHEDULING
 680          *
 681          * Description: This function is used to prevent rescheduling to take place.  This allows your application
 682          *              to prevent context switches until you are ready to permit context switching.
 683          *
 684          * Arguments  : none
 685          *
 686          * Returns    : none
 687          *
 688          * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every
 689          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 690          *********************************************************************************************************
 691          */
 692          
 693          #if OS_SCHED_LOCK_EN > 0
              void  OSSchedLock (void)  reentrant
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
              
              
              
                  if (OSRunning == OS_TRUE) {                  /* Make sure multitasking is running                  */
                      OS_ENTER_CRITICAL();
                      if (OSIntNesting == 0) {                 /* Can't call from an ISR                             */
                          if (OSLockNesting < 255u) {          /* Prevent OSLockNesting from wrapping back to 0      */
                              OSLockNesting++;                 /* Increment lock nesting level                       */
                          }
                      }
                      OS_EXIT_CRITICAL();
                  }
              }
              #endif
 713          
 714          /*$PAGE*/
 715          /*
 716          *********************************************************************************************************
 717          *                                          ENABLE SCHEDULING
 718          *
 719          * Description: This function is used to re-allow rescheduling.
 720          *
 721          * Arguments  : none
 722          *
C51 COMPILER V8.17   OS_CORE                                                               03/26/2009 14:24:24 PAGE 13  

 723          * Returns    : none
 724          *
 725          * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every
 726          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 727          *********************************************************************************************************
 728          */
 729          
 730          #if OS_SCHED_LOCK_EN > 0
              void  OSSchedUnlock (void)  reentrant
              {
              #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
              
              
              
                  if (OSRunning == OS_TRUE) {                            /* Make sure multitasking is running        */
                      OS_ENTER_CRITICAL();
                      if (OSLockNesting > 0) {                           /* Do not decrement if already 0            */
                          OSLockNesting--;                               /* Decrement lock nesting level             */
                          if (OSLockNesting == 0) {                      /* See if scheduler is enabled and ...      */
                              if (OSIntNesting == 0) {                   /* ... not in an ISR                        */
                                  OS_EXIT_CRITICAL();
                                  OS_Sched();                            /* See if a HPT is ready                    */
                              } else {
                                  OS_EXIT_CRITICAL();
                              }
                          } else {
                              OS_EXIT_CRITICAL();
                          }
                      } else {
                          OS_EXIT_CRITICAL();
                      }
                  }
              }
              #endif
 759          
 760          /*$PAGE*/
 761          /*
 762          *********************************************************************************************************
 763          *                                          START MULTITASKING
 764          *
 765          * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
 766          *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
 767          *              and you MUST have created at least one task.
 768          *
 769          * Arguments  : none
 770          *
 771          * Returns    : none
 772          *
 773          * Note       : OSStartHighRdy() MUST:
 774          *                 a) Call OSTaskSwHook() then,
 775          *                 b) Set OSRunning to OS_TRUE.
 776          *                 c) Load the context of the task pointed to by OSTCBHighRdy.
 777          *                 d_ Execute the task.
 778          *********************************************************************************************************
 779          */
 780          
 781          void  OSStart (void) reentrant
 782          {
 783   1          if (OSRunning == OS_FALSE) {
 784   2              OS_SchedNew();                               /* Find highest priority's task priority number   */
C51 COMPILER V8.17   OS_CORE                                                               03/26/2009 14:24:24 PAGE 14  

 785   2              OSPrioCur     = OSPrioHighRdy;
 786   2              OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
 787   2              OSTCBCur      = OSTCBHighRdy;
 788   2              OSStartHighRdy();                            /* Execute target specific code to start task     */
 789   2          }
 790   1      }
 791          /*$PAGE*/
 792          /*
 793          *********************************************************************************************************
 794          *                                        STATISTICS INITIALIZATION
 795          *
 796          * Description: This function is called by your application to establish CPU usage by first determining
 797          *              how high a 32-bit counter would count to in 1 second if no other tasks were to execute
 798          *              during that time.  CPU usage is then determined by a low priority task which keeps track
 799          *              of this 32-bit counter every second but this time, with other tasks running.  CPU usage is
 800          *              determined by:
 801          *
 802          *                                             OSIdleCtr
 803          *                 CPU Usage (%) = 100 * (1 - ------------)
 804          *                                            OSIdleCtrMax
 805          *
 806          * Arguments  : none
 807          *
 808          * Returns    : none
 809          *********************************************************************************************************
 810          */
 811          
 812          #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 = 0;
              #endif
              
              
              
                  OSTimeDly(2);                                /* Synchronize with clock tick                        */
                  OS_ENTER_CRITICAL();
                  OSIdleCtr    = 0L;                           /* Clear idle counter                                 */
                  OS_EXIT_CRITICAL();
                  OSTimeDly(OS_TICKS_PER_SEC / 10);            /* Determine MAX. idle counter value for 1/10 second  */
                  OS_ENTER_CRITICAL();
                  OSIdleCtrMax = OSIdleCtr;                    /* Store maximum idle counter count in 1/10 second    */
                  OSStatRdy    = OS_TRUE;
                  OS_EXIT_CRITICAL();
              }
              #endif
 832          /*$PAGE*/
 833          /*
 834          *********************************************************************************************************
 835          *                                         PROCESS SYSTEM TICK
 836          *
 837          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 838          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 839          *              called by a high priority task.
 840          *
 841          * Arguments  : none
 842          *
 843          * Returns    : none
 844          *********************************************************************************************************
 845          */
 846          
C51 COMPILER V8.17   OS_CORE                                                               03/26/2009 14:24:24 PAGE 15  

 847          void  OSTimeTick (void) reentrant
 848          {

⌨️ 快捷键说明

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