?? os_task.lst
字號:
824 1 OS_TCB *ptcb;
825 1 INT8U y;
826 1
827 1
828 1 #if OS_ARG_CHK_EN > 0
829 1 if (prio == OS_IDLE_PRIO) { /* Not allowed to suspend idle task */
830 2 return (OS_TASK_SUSPEND_IDLE);
831 2 }
832 1 if (prio >= OS_LOWEST_PRIO) { /* Task priority valid ? */
833 2 if (prio != OS_PRIO_SELF) {
834 3 return (OS_PRIO_INVALID);
835 3 }
836 2 }
837 1 #endif
838 1 OS_ENTER_CRITICAL();
839 1 if (prio == OS_PRIO_SELF) { /* See if suspend SELF */
840 2 prio = OSTCBCur->OSTCBPrio;
841 2 self = TRUE;
842 2 } else if (prio == OSTCBCur->OSTCBPrio) { /* See if suspending self */
843 2 self = TRUE;
844 2 } else {
845 2 self = FALSE; /* No suspending another task */
846 2 }
847 1 ptcb = OSTCBPrioTbl[prio];
848 1 if (ptcb == (OS_TCB *)0) { /* Task to suspend must exist */
849 2 OS_EXIT_CRITICAL();
850 2 return (OS_TASK_SUSPEND_PRIO);
851 2 }
852 1 y = ptcb->OSTCBY;
853 1 OSRdyTbl[y] &= ~ptcb->OSTCBBitX; /* Make task not ready */
854 1 if (OSRdyTbl[y] == 0x00) {
855 2 OSRdyGrp &= ~ptcb->OSTCBBitY;
856 2 }
857 1 ptcb->OSTCBStat |= OS_STAT_SUSPEND; /* Status of task is 'SUSPENDED' */
858 1 OS_EXIT_CRITICAL();
859 1 if (self == TRUE) { /* Context switch only if SELF */
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 15
860 2 OS_Sched();
861 2 }
862 1 return (OS_NO_ERR);
863 1 }
864 #endif
865 /*$PAGE*/
866 /*
867 *********************************************************************************************************
868 * QUERY A TASK
869 *
870 * Description: This function is called to obtain a copy of the desired task's TCB.
871 *
872 * Arguments : prio is the priority of the task to obtain information from.
873 *
874 * Returns : OS_NO_ERR if the requested task is suspended
875 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
876 * (i.e. > OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
877 * OS_PRIO_ERR if the desired task has not been created
878 *********************************************************************************************************
879 */
880
881 #if OS_TASK_QUERY_EN > 0
882 INT8U OSTaskQuery (INT8U prio, OS_TCB *pndata) reentrant //using 0
883 {
884 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
885 1 OS_CPU_SR cpu_sr;
886 1 #endif
887 1 OS_TCB *ptcb;
888 1
889 1
890 1 #if OS_ARG_CHK_EN > 0
891 1 if (prio > OS_LOWEST_PRIO) { /* Task priority valid ? */
892 2 if (prio != OS_PRIO_SELF) {
893 3 return (OS_PRIO_INVALID);
894 3 }
895 2 }
896 1 #endif
897 1 OS_ENTER_CRITICAL();
898 1 if (prio == OS_PRIO_SELF) { /* See if suspend SELF */
899 2 prio = OSTCBCur->OSTCBPrio;
900 2 }
901 1 ptcb = OSTCBPrioTbl[prio];
902 1 if (ptcb == (OS_TCB *)0) { /* Task to query must exist */
903 2 OS_EXIT_CRITICAL();
904 2 return (OS_PRIO_ERR);
905 2 }
906 1 memcpy(pndata, ptcb, sizeof(OS_TCB)); /* Copy TCB into user storage area */
907 1 OS_EXIT_CRITICAL();
908 1 return (OS_NO_ERR);
909 1 }
910 #endif
911 /*$PAGE*/
912 /*
913 *********************************************************************************************************
914 * CLEAR TASK STACK
915 *
916 * Description: This function is used to clear the stack of a task (i.e. write all zeros)
917 *
918 * Arguments : pbos is a pointer to the task's bottom of stack. If the configuration constant
919 * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
920 * memory to low memory). 'pbos' will thus point to the lowest (valid) memory
921 * location of the stack. If OS_STK_GROWTH is set to 0, 'pbos' will point to the
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 16
922 * highest memory location of the stack and the stack will grow with increasing
923 * memory locations. 'pbos' MUST point to a valid 'free' data item.
924 *
925 * size is the number of 'stack elements' to clear.
926 *
927 * opt contains additional information (or options) about the behavior of the task. The
928 * LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
929 * specific. See OS_TASK_OPT_??? in uCOS-II.H.
930 *
931 * Returns : none
932 *********************************************************************************************************
933 */
934 #if OS_TASK_CREATE_EXT_EN > 0
935 void OS_TaskStkClr (OS_STK *pbos, INT32U size, INT16U opt) reentrant //using 0
936 {
937 1 if ((opt & OS_TASK_OPT_STK_CHK) != 0x0000) { /* See if stack checking has been enabled */
938 2 if ((opt & OS_TASK_OPT_STK_CLR) != 0x0000) { /* See if stack needs to be cleared */
939 3 #if OS_STK_GROWTH == 1
while (size > 0) { /* Stack grows from HIGH to LOW memory */
size--;
*pbos++ = (OS_STK)0; /* Clear from bottom of stack and up! */
}
#else
945 3 while (size > 0) { /* Stack grows from LOW to HIGH memory */
946 4 size--;
947 4 *pbos-- = (OS_STK)0; /* Clear from bottom of stack and down */
948 4 }
949 3 #endif
950 3 }
951 2 }
952 1 }
953
954 #endif
955
956 /*
957 *********************************************************************************************************
958 * PROCESS SYSTEM TICK
959 *
960 * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
961 * as a 'clock tick'). This function should be called by the ticker ISR but, can also be
962 * called by a high priority task.
963 *
964 * Arguments : none
965 *
966 * Returns : none
967 *********************************************************************************************************
968 */
969 #if 0//#Lin
void OSTimeTick (void)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register
- */
OS_CPU_SR cpu_sr;
#endif
OS_TCB *ptcb;
BOOLEAN step;
#if OS_TIME_TICK_HOOK_EN > 0
OSTimeTickHook(); /* Call user definable hook
- */
#endif
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 17
#if OS_TIME_GET_SET_EN > 0
OS_ENTER_CRITICAL(); /* Update the 32-bit tick counter
- */
OSTime++;
OS_EXIT_CRITICAL();
#endif
if (OSRunning == TRUE) {
#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 = TRUE;
break;
case OS_TICK_STEP_WAIT: /* No, waiting for uC/OS-View to set ...
- */
step = FALSE; /* .. OSTickStepState to OS_TICK_STEP_ONCE
- */
break;
case OS_TICK_STEP_ONCE: /* Yes, process tick once and wait for next ...
- */
step = TRUE; /* ... step command from uC/OS-View
- */
OSTickStepState = OS_TICK_STEP_WAIT;
break;
default: /* Invalid case, correct situation
- */
step = TRUE;
OSTickStepState = OS_TICK_STEP_DIS;
break;
}
#else
step = TRUE;
#endif
if (step == TRUE) {
ptcb = OSTCBList; /* Point at first TCB in TCB list
- */
while (ptcb->OSTCBPrio != OS_IDLE_PRIO) { /* Go through all TCBs in TCB list
- */
OS_ENTER_CRITICAL();
if (ptcb->OSTCBDly != 0) { /* Delayed or waiting for event with TO
- */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -