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

📄 os_core.lst

📁 实施操作系统的设计和开发
💻 LST
📖 第 1 页 / 共 5 页
字号:
 571          *
 572          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 573          *********************************************************************************************************
 574          */
 575          #if OS_EVENT_EN > 0
              INT8U  OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) reentrant
              {
                  OS_TCB *ptcb;
                  INT8U   x;
                  INT8U   y;
                  INT8U   bitx;
                  INT8U   bity;
                  INT8U   prio;
              
              
                  y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting for message   */
                  bity = OSMapTbl[y];
                  x    = OSUnMapTbl[pevent->OSEventTbl[y]];
                  bitx = OSMapTbl[x];
                  prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting the msg         */
                  if ((pevent->OSEventTbl[y] &= ~bitx) == 0x00) {   /* Remove this task from the waiting list        */
                      pevent->OSEventGrp &= ~bity;                  /* Clr group bit if this was only task pending   */
                  }
                  ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB                   */
                  ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
                  ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task                     */
              #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
                  ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting task         */
              #else
                  msg                  = msg;                       /* Prevent compiler warning if not used          */
              #endif
                  ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
                  if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be susp'd)        */
                      OSRdyGrp        |=  bity;                     /* Put task in the ready to run list             */
                      OSRdyTbl[y]     |=  bitx;
                  }
                  return (prio);
              }
              #endif
 610          /*$PAGE*/
 611          /*
 612          *********************************************************************************************************
 613          *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 614          *
 615          * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 616          *              not occurred.
 617          *
 618          * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 619          *
 620          * Returns    : none
 621          *
 622          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 623          *********************************************************************************************************
C51 COMPILER V7.02b   OS_CORE                                                              11/29/2006 14:48:11 PAGE 12  

 624          */
 625          #if OS_EVENT_EN > 0
              void  OS_EventTaskWait (OS_EVENT *pevent) reentrant
              {
                  OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block in TCB        */
                  if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {   /* Task no longer ready      */
                      OSRdyGrp &= ~OSTCBCur->OSTCBBitY;        /* Clear event grp bit if this was only task pending  */
                  }
                  pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
                  pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
              }
              #endif
 636          /*$PAGE*/
 637          /*
 638          *********************************************************************************************************
 639          *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 640          *
 641          * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 642          *              timeout occurred.
 643          *
 644          * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 645          *
 646          * Returns    : none
 647          *
 648          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 649          *********************************************************************************************************
 650          */
 651          #if OS_EVENT_EN > 0
              void  OS_EventTO (OS_EVENT *pevent) reentrant
              {
                  if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {
                      pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
                  }
                  OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
                  OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;     /* No longer waiting for event                        */
              }
              #endif
 661          /*$PAGE*/
 662          /*
 663          *********************************************************************************************************
 664          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 665          *
 666          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 667          *
 668          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 669          *
 670          * Returns    : none
 671          *
 672          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 673          *********************************************************************************************************
 674          */
 675          #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)
              void  OS_EventWaitListInit (OS_EVENT *pevent) reentrant
              {
                  INT8U  *ptbl;
              
              
                  pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
                  ptbl               = &pevent->OSEventTbl[0];
              
              #if OS_EVENT_TBL_SIZE > 0
                  *ptbl++            = 0x00;
C51 COMPILER V7.02b   OS_CORE                                                              11/29/2006 14:48:11 PAGE 13  

              #endif
              
              #if OS_EVENT_TBL_SIZE > 1
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 2
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 3
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 4
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 5
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 6
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 7
                  *ptbl              = 0x00;
              #endif
              }
              #endif
 717          /*$PAGE*/
 718          /*
 719          *********************************************************************************************************
 720          *                                              SCHEDULER
 721          *
 722          * Description: This function is called by other uC/OS-II services to determine whether a new, high
 723          *              priority task has been made ready to run.  This function is invoked by TASK level code
 724          *              and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
 725          *
 726          * Arguments  : none
 727          *
 728          * Returns    : none
 729          *
 730          * Notes      : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
 731          *              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
 732          *********************************************************************************************************
 733          */
 734          
 735          void  OS_Sched (void) reentrant
 736          {
 737   1      #if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
                  OS_CPU_SR  cpu_sr;
              #endif    
 740   1          INT8U      y;
 741   1      
 742   1      
 743   1          OS_ENTER_CRITICAL();
 744   1          if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Sched. only if all ISRs done & not locked    */
 745   2              y             = OSUnMapTbl[OSRdyGrp];          /* Get pointer to HPT ready to run              */
 746   2              OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
 747   2              if (OSPrioHighRdy != OSPrioCur) {              /* No Ctx Sw if current task is highest rdy     */
C51 COMPILER V7.02b   OS_CORE                                                              11/29/2006 14:48:11 PAGE 14  

 748   3                  OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
 749   3                  OSCtxSwCtr++;                              /* Increment context switch counter             */
 750   3                  OS_TASK_SW();                              /* Perform a context switch                     */
 751   3              }
 752   2          }
 753   1          OS_EXIT_CRITICAL();
 754   1      }
 755          /*$PAGE*/
 756          /*
 757          *********************************************************************************************************
 758          *                                              IDLE TASK
 759          *
 760          * Description: This task is internal to uC/OS-II and executes whenever no other higher priority tasks
 761          *              executes because they are ALL waiting for event(s) to occur.
 762          *
 763          * Arguments  : none
 764          *
 765          * Returns    : none
 766          *
 767          * Note(s)    : 1) OSTaskIdleHook() is called after the critical section to ensure that interrupts will be
 768          *                 enabled for at least a few instructions.  On some processors (ex. Philips XA), enabling
 769          *                 and then disabling interrupts didn't allow the processor enough time to have interrupts
 770          *                 enabled before they were disabled again.  uC/OS-II would thus never recognize
 771          *                 interrupts.
 772          *              2) This hook has been added to allow you to do such things as STOP the CPU to conserve 
 773          *                 power.
 774          *********************************************************************************************************
 775          */
 776          
 777          void  OS_TaskIdle (void *ppdata) reentrant
 778          {
 779   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    

⌨️ 快捷键说明

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