📄 os_core.lst
字号:
568 *
569 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
570 *********************************************************************************************************
571 */
572 #if OS_EVENT_EN > 0
INT8U OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) KCREENTRANT
{
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
607 /*$PAGE*/
608 /*
609 *********************************************************************************************************
610 * MAKE TASK WAIT FOR EVENT TO OCCUR
611 *
612 * Description: This function is called by other uC/OS-II services to suspend a task because an event has
613 * not occurred.
614 *
615 * Arguments : pevent is a pointer to the event control block for which the task will be waiting for.
616 *
617 * Returns : none
618 *
619 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
620 *********************************************************************************************************
621 */
622 #if OS_EVENT_EN > 0
void OS_EventTaskWait (OS_EVENT *pevent) KCREENTRANT
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 12
{
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
633 /*$PAGE*/
634 /*
635 *********************************************************************************************************
636 * MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
637 *
638 * Description: This function is called by other uC/OS-II services to make a task ready to run because a
639 * timeout occurred.
640 *
641 * Arguments : pevent is a pointer to the event control block which is readying a task.
642 *
643 * Returns : none
644 *
645 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
646 *********************************************************************************************************
647 */
648 #if OS_EVENT_EN > 0
void OS_EventTO (OS_EVENT *pevent) KCREENTRANT
{
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
658 /*$PAGE*/
659 /*
660 *********************************************************************************************************
661 * INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
662 *
663 * Description: This function is called by other uC/OS-II services to initialize the event wait list.
664 *
665 * Arguments : pevent is a pointer to the event control block allocated to the event.
666 *
667 * Returns : none
668 *
669 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
670 *********************************************************************************************************
671 */
672 #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) KCREENTRANT
{
INT8U *ptbl;
pevent->OSEventGrp = 0x00; /* No task waiting on event */
ptbl = &pevent->OSEventTbl[0];
#if OS_EVENT_TBL_SIZE > 0
*ptbl++ = 0x00;
#endif
#if OS_EVENT_TBL_SIZE > 1
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 13
*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
714 /*$PAGE*/
715 /*
716 *********************************************************************************************************
717 * SCHEDULER
718 *
719 * Description: This function is called by other uC/OS-II services to determine whether a new, high
720 * priority task has been made ready to run. This function is invoked by TASK level code
721 * and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
722 *
723 * Arguments : none
724 *
725 * Returns : none
726 *
727 * Notes : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
728 * 2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
729 *********************************************************************************************************
730 */
731
732 void OS_Sched (void) KCREENTRANT
733 {
734 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
737 1 INT8U y;
738 1
739 1 OS_ENTER_CRITICAL();
740 1 if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Sched. only if all ISRs done & not locked */
741 2 y = OSUnMapTbl[OSRdyGrp]; /* Get pointer to HPT ready to run */
742 2 OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
743 2 if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
744 3 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
745 3 OSCtxSwCtr++; /* Increment context switch counter */
746 3 OS_TASK_SW(); /* Perform a context switch */
747 3 }
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 14
748 2 }
749 1 OS_EXIT_CRITICAL();
750 1 }
751 /*$PAGE*/
752 /*
753 *********************************************************************************************************
754 * IDLE TASK
755 *
756 * Description: This task is internal to uC/OS-II and executes whenever no other higher priority tasks
757 * executes because they are ALL waiting for event(s) to occur.
758 *
759 * Arguments : none
760 *
761 * Returns : none
762 *
763 * Note(s) : 1) OSTaskIdleHook() is called after the critical section to ensure that interrupts will be
764 * enabled for at least a few instructions. On some processors (ex. Philips XA), enabling
765 * and then disabling interrupts didn't allow the processor enough time to have interrupts
766 * enabled before they were disabled again. uC/OS-II would thus never recognize
767 * interrupts.
768 * 2) This hook has been added to allow you to do such things as STOP the CPU to conserve
769 * power.
770 *********************************************************************************************************
771 */
772
773 void OS_TaskIdle (void *pdat) KCREENTRANT
774 {
775 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 + -