?? os_task.lst
字號:
615 void OSTaskNameSet (INT8U prio, char *pname, INT8U *err) reentrant //using 0
616 {
617 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
618 1 OS_CPU_SR cpu_sr;
619 1 #endif
620 1 INT8U len;
621 1 OS_TCB *ptcb;
622 1
623 1
624 1 OS_ENTER_CRITICAL();
625 1 #if OS_ARG_CHK_EN > 0
626 1 if (prio > OS_LOWEST_PRIO) { /* Task priority valid ? */
627 2 if (prio != OS_PRIO_SELF) {
628 3 *err = OS_PRIO_INVALID; /* No */
629 3 return;
630 3 }
631 2 }
632 1 if (pname == (char *)0) { /* Is 'pname' a NULL pointer? */
633 2 OS_EXIT_CRITICAL(); /* Yes */
634 2 *err = OS_ERR_PNAME_NULL;
635 2 return;
636 2 }
637 1 #endif
638 1 if (prio == OS_PRIO_SELF) { /* See if caller desires to set it's own name */
639 2 prio = OSTCBCur->OSTCBPrio;
640 2 }
641 1 ptcb = OSTCBPrioTbl[prio];
642 1 if (ptcb == (OS_TCB *)0) { /* Does task exist? */
643 2 OS_EXIT_CRITICAL(); /* No */
644 2 *err = OS_TASK_NOT_EXIST;
645 2 return;
646 2 }
647 1 len = strlen(pname); /* Yes, Can we fit the string in the TCB? */
648 1 if (len > (OS_TASK_NAME_SIZE - 1)) { /* No */
649 2 OS_EXIT_CRITICAL();
650 2 *err = OS_ERR_TASK_NAME_TOO_LONG;
651 2 return;
652 2 }
653 1 (void)strcpy(ptcb->OSTCBTaskName, pname); /* Yes, copy to TCB */
654 1 OS_EXIT_CRITICAL();
655 1 *err = OS_NO_ERR;
656 1 }
657 #endif
658
659 /*$PAGE*/
660 /*
661 *********************************************************************************************************
662 * RESUME A SUSPENDED TASK
663 *
664 * Description: This function is called to resume a previously suspended task. This is the only call that
665 * will remove an explicit task suspension.
666 *
667 * Arguments : prio is the priority of the task to resume.
668 *
669 * Returns : OS_NO_ERR if the requested task is resumed
670 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
671 * (i.e. >= OS_LOWEST_PRIO)
672 * OS_TASK_RESUME_PRIO if the task to resume does not exist
673 * OS_TASK_NOT_SUSPENDED if the task to resume has not been suspended
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 12
674 *********************************************************************************************************
675 */
676 #if 0//#Lin
#if OS_TASK_SUSPEND_EN > 0
INT8U OSTaskResume (INT8U prio)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_TCB *ptcb;
#if OS_ARG_CHK_EN > 0
if (prio >= OS_LOWEST_PRIO) { /* Make sure task priority is valid */
return (OS_PRIO_INVALID);
}
#endif
OS_ENTER_CRITICAL();
ptcb = OSTCBPrioTbl[prio];
if (ptcb == (OS_TCB *)0) { /* Task to suspend must exist */
OS_EXIT_CRITICAL();
return (OS_TASK_RESUME_PRIO);
}
if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) != OS_STAT_RDY) { /* Task must be suspended */
ptcb->OSTCBStat &= ~OS_STAT_SUSPEND; /* Remove suspension */
if (ptcb->OSTCBStat == OS_STAT_RDY) {
if (ptcb->OSTCBDly == 0) { /* Must not be delayed */
OSRdyGrp |= ptcb->OSTCBBitY; /* Make task ready to run */
OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
OS_EXIT_CRITICAL();
OS_Sched();
} else {
OS_EXIT_CRITICAL();
}
} else {
OS_EXIT_CRITICAL();
}
return (OS_NO_ERR);
}
OS_EXIT_CRITICAL();
return (OS_TASK_NOT_SUSPENDED);
}
#endif
#endif
719 /*$PAGE*/
720 /*
721 *********************************************************************************************************
722 * STACK CHECKING
723 *
724 * Description: This function is called to check the amount of free memory left on the specified task's
725 * stack.
726 *
727 * Arguments : prio is the task priority
728 *
729 * pdata is a pointer to a data structure of type OS_STK_DATA.
730 *
731 * Returns : OS_NO_ERR upon success
732 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
733 * (i.e. > OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
734 * OS_TASK_NOT_EXIST if the desired task has not been created
735 * OS_TASK_OPT_ERR if you did NOT specified OS_TASK_OPT_STK_CHK when the task was created
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 13
736 *********************************************************************************************************
737 */
738 #if OS_TASK_CREATE_EXT_EN > 0
739 INT8U OSTaskStkChk (INT8U prio, OS_STK_DATA *pndata) reentrant //using 0
740 {
741 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
742 1 OS_CPU_SR cpu_sr;
743 1 #endif
744 1 OS_TCB *ptcb;
745 1 OS_STK *pchk;
746 1 INT32U free;
747 1 INT32U size;
748 1
749 1
750 1 #if OS_ARG_CHK_EN > 0
751 1 if (prio > OS_LOWEST_PRIO) { /* Make sure task priority is valid */
752 2 if (prio != OS_PRIO_SELF) {
753 3 return (OS_PRIO_INVALID);
754 3 }
755 2 }
756 1 #endif
757 1 pndata->OSFree = 0; /* Assume failure, set to 0 size */
758 1 pndata->OSUsed = 0;
759 1 OS_ENTER_CRITICAL();
760 1 if (prio == OS_PRIO_SELF) { /* See if check for SELF */
761 2 prio = OSTCBCur->OSTCBPrio;
762 2 }
763 1 ptcb = OSTCBPrioTbl[prio];
764 1 if (ptcb == (OS_TCB *)0) { /* Make sure task exist */
765 2 OS_EXIT_CRITICAL();
766 2 return (OS_TASK_NOT_EXIST);
767 2 }
768 1 if (ptcb == (OS_TCB *)1) {
769 2 OS_EXIT_CRITICAL();
770 2 return (OS_TASK_NOT_EXIST);
771 2 }
772 1 if ((ptcb->OSTCBOpt & OS_TASK_OPT_STK_CHK) == 0) { /* Make sure stack checking option is set */
773 2 OS_EXIT_CRITICAL();
774 2 return (OS_TASK_OPT_ERR);
775 2 }
776 1 free = 0;
777 1 size = ptcb->OSTCBStkSize;
778 1 pchk = ptcb->OSTCBStkBottom;
779 1 OS_EXIT_CRITICAL();
780 1 #if OS_STK_GROWTH == 1
while (*pchk++ == (OS_STK)0) { /* Compute the number of zero entries on the stk */
free++;
}
#else
785 1 while (*pchk-- == (OS_STK)0) {
786 2 free++;
787 2 }
788 1 #endif
789 1 pndata->OSFree = free * sizeof(OS_STK); /* Compute number of free bytes on the stack */
790 1 pndata->OSUsed = (size - free) * sizeof(OS_STK); /* Compute number of bytes used on the stack */
791 1 return (OS_NO_ERR);
792 1 }
793 #endif
794 /*$PAGE*/
795 /*
796 *********************************************************************************************************
797 * SUSPEND A TASK
C51 COMPILER V7.06 OS_TASK 07/18/2003 11:06:04 PAGE 14
798 *
799 * Description: This function is called to suspend a task. The task can be the calling task if the
800 * priority passed to OSTaskSuspend() is the priority of the calling task or OS_PRIO_SELF.
801 *
802 * Arguments : prio is the priority of the task to suspend. If you specify OS_PRIO_SELF, the
803 * calling task will suspend itself and rescheduling will occur.
804 *
805 * Returns : OS_NO_ERR if the requested task is suspended
806 * OS_TASK_SUSPEND_IDLE if you attempted to suspend the idle task which is not allowed.
807 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
808 * (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
809 * OS_TASK_SUSPEND_PRIO if the task to suspend does not exist
810 *
811 * Note : You should use this function with great care. If you suspend a task that is waiting for
812 * an event (i.e. a message, a semaphore, a queue ...) you will prevent this task from
813 * running when the event arrives.
814 *********************************************************************************************************
815 */
816
817 #if OS_TASK_SUSPEND_EN > 0
818 INT8U OSTaskSuspend (INT8U prio) reentrant //using 0
819 {
820 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
821 1 OS_CPU_SR cpu_sr;
822 1 #endif
823 1 BOOLEAN self;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -