📄 os_core.lst
字号:
849 1 OS_TCB *ptcb;
850 1 #if OS_TICK_STEP_EN > 0
BOOLEAN step;
#endif
853 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register
- */
OS_CPU_SR cpu_sr = 0;
#endif
856 1
857 1
858 1
859 1 #if OS_TIME_TICK_HOOK_EN > 0
860 1 OSTimeTickHook(); /* Call user definable hook
- */
861 1 #endif
862 1 #if OS_TIME_GET_SET_EN > 0
OS_ENTER_CRITICAL(); /* Update the 32-bit tick counter
- */
OSTime++;
OS_EXIT_CRITICAL();
#endif
867 1 if (OSRunning == OS_TRUE) {
868 2 #if OS_TICK_STEP_EN > 0
switch (OSTickStepState) { /* Determine whether we need to process a tick
- */
case OS_TICK_STEP_DIS: /* Yes, stepping is disabled
- */
step = OS_TRUE;
break;
case OS_TICK_STEP_WAIT: /* No, waiting for uC/OS-View to set ...
- */
step = OS_FALSE; /* .. OSTickStepState to OS_TICK_STEP_ONCE
- */
break;
case OS_TICK_STEP_ONCE: /* Yes, process tick once and wait for next ...
- */
step = OS_TRUE; /* ... step command from uC/OS-View
- */
OSTickStepState = OS_TICK_STEP_WAIT;
break;
default: /* Invalid case, correct situation
- */
step = OS_TRUE;
OSTickStepState = OS_TICK_STEP_DIS;
break;
}
if (step == OS_FALSE) { /* Return if waiting for step command
- */
return;
}
#endif
892 2 ptcb = OSTCBList; /* Point at first TCB in TCB list
- */
893 2 while (ptcb->OSTCBPrio != OS_TASK_IDLE_PRIO) { /* Go through all TCBs in TCB list
- */
894 3 OS_ENTER_CRITICAL();
895 3 if (ptcb->OSTCBDly != 0) { /* No, Delayed or waiting for event with TO
C51 COMPILER V8.17 OS_CORE 03/26/2009 14:24:24 PAGE 16
- */
896 4 if (--ptcb->OSTCBDly == 0) { /* Decrement nbr of ticks to end of delay
- */
897 5 /* Check for timeout
- */
898 5 if ((ptcb->OSTCBStat & OS_STAT_PEND_ANY) != OS_STAT_RDY) {
899 6 ptcb->OSTCBStat &= ~(INT8U)OS_STAT_PEND_ANY; /* Yes, Clear status flag
- */
900 6 ptcb->OSTCBStatPend = OS_STAT_PEND_TO; /* Indicate PEND timeout
- */
901 6 } else {
902 6 ptcb->OSTCBStatPend = OS_STAT_PEND_OK;
903 6 }
904 5
905 5 if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?
- */
906 6 OSRdyGrp |= ptcb->OSTCBBitY; /* No, Make ready
- */
907 6 OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
908 6 }
909 5 }
910 4 }
911 3 ptcb = ptcb->OSTCBNext; /* Point at next TCB in TCB list
- */
912 3 OS_EXIT_CRITICAL();
913 3 }
914 2 }
915 1 }
916
917 /*$PAGE*/
918 /*
919 *********************************************************************************************************
920 * GET VERSION
921 *
922 * Description: This function is used to return the version number of uC/OS-II. The returned value
923 * corresponds to uC/OS-II's version number multiplied by 100. In other words, version 2.00
924 * would be returned as 200.
925 *
926 * Arguments : none
927 *
928 * Returns : the version number of uC/OS-II multiplied by 100.
929 *********************************************************************************************************
930 */
931
932 #if OS_GER_VERSION>0
933
934 INT16U OSVersion (void) reentrant
935 {
936 1 return (OS_VERSION);
937 1 }
938
939 #endif
940
941 /*$PAGE*/
942 /*
943 *********************************************************************************************************
944 * DUMMY FUNCTION
945 *
946 * Description: This function doesn't do anything. It is called by OSTaskDel().
947 *
948 * Arguments : none
949 *
C51 COMPILER V8.17 OS_CORE 03/26/2009 14:24:24 PAGE 17
950 * Returns : none
951 *********************************************************************************************************
952 */
953
954 #if OS_TASK_DEL_EN > 0
void OS_Dummy (void)
{
}
#endif
959
960 /*$PAGE*/
961 /*
962 *********************************************************************************************************
963 * MAKE TASK READY TO RUN BASED ON EVENT OCCURING
964 *
965 * Description: This function is called by other uC/OS-II services and is used to ready a task that was
966 * waiting for an event to occur.
967 *
968 * Arguments : pevent is a pointer to the event control block corresponding to the event.
969 *
970 * pmsg is a pointer to a message. This pointer is used by message oriented services
971 * such as MAILBOXEs and QUEUEs. The pointer is not used when called by other
972 * service functions.
973 *
974 * msk is a mask that is used to clear the status byte of the TCB. For example,
975 * OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
976 *
977 * pend_stat is used to indicate the readied task's pending status:
978 *
979 * OS_STAT_PEND_OK Task ready due to a post (or delete), not a timeout or
980 * an abort.
981 * OS_STAT_PEND_ABORT Task ready due to an abort.
982 *
983 * Returns : none
984 *
985 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
986 *********************************************************************************************************
987 */
988 #if (OS_EVENT_EN)
989 INT8U OS_EventTaskRdy (OS_EVENT *pevent, void *pmsg, INT8U msk, INT8U pend_stat) reentrant
990 {
991 1 OS_TCB *ptcb;
992 1 INT8U y;
993 1 INT8U x;
994 1 INT8U prio;
995 1 #if OS_LOWEST_PRIO > 63
INT16U *ptbl;
#endif
998 1
999 1
1000 1 #if OS_LOWEST_PRIO <= 63
1001 1 y = OSUnMapTbl[pevent->OSEventGrp]; /* Find HPT waiting for message */
1002 1 x = OSUnMapTbl[pevent->OSEventTbl[y]];
1003 1 prio = (INT8U)((y << 3) + x); /* Find priority of task getting the msg */
1004 1 #else
if ((pevent->OSEventGrp & 0xFF) != 0) { /* Find HPT waiting for message */
y = OSUnMapTbl[ pevent->OSEventGrp & 0xFF];
} else {
y = OSUnMapTbl[(pevent->OSEventGrp >> 8) & 0xFF] + 8;
}
ptbl = &pevent->OSEventTbl[y];
if ((*ptbl & 0xFF) != 0) {
C51 COMPILER V8.17 OS_CORE 03/26/2009 14:24:24 PAGE 18
x = OSUnMapTbl[*ptbl & 0xFF];
} else {
x = OSUnMapTbl[(*ptbl >> 8) & 0xFF] + 8;
}
prio = (INT8U)((y << 4) + x); /* Find priority of task getting the msg */
#endif
1018 1
1019 1 ptcb = OSTCBPrioTbl[prio]; /* Point to this task's OS_TCB */
1020 1 ptcb->OSTCBDly = 0; /* Prevent OSTimeTick() from readying task */
1021 1 #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
ptcb->OSTCBMsg = pmsg; /* Send message directly to waiting task */
#else
1024 1 pmsg = pmsg; /* Prevent compiler warning if not used */
1025 1 #endif
1026 1 ptcb->OSTCBStat &= ~msk; /* Clear bit associated with event type */
1027 1 ptcb->OSTCBStatPend = pend_stat; /* Set pend status of post or abort */
1028 1 /* See if task is ready (could be susp'd) */
1029 1 if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) {
1030 2 OSRdyGrp |= ptcb->OSTCBBitY; /* Put task in the ready to run list */
1031 2 OSRdyTbl[y] |= ptcb->OSTCBBitX;
1032 2 }
1033 1
1034 1 OS_EventTaskRemove(ptcb, pevent); /* Remove this task from event wait list */
1035 1 #if (OS_EVENT_MULTI_EN > 0)
if (ptcb->OSTCBEventMultiPtr != (OS_EVENT **)0) { /* Remove this task from events' wait lists */
OS_EventTaskRemoveMulti(ptcb, ptcb->OSTCBEventMultiPtr);
ptcb->OSTCBEventPtr = (OS_EVENT *)pevent;/* Return event as first multi-pend event ready*/
}
#endif
1041 1
1042 1 return (prio);
1043 1 }
1044
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -