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

📄 os_task.lst

📁 称植到lpc2124上的UCOS2.85版 是本人初学移植和ARM的成果 可能已有人上传类似的了
💻 LST
📖 第 1 页 / 共 5 页
字号:
 416:../OSsrc/os_task.c ****     if (prio >= OS_LOWEST_PRIO) {                               /* Task priority valid ?           
 417:../OSsrc/os_task.c ****         if (prio != OS_PRIO_SELF) {
 418:../OSsrc/os_task.c ****             return (OS_ERR_PRIO_INVALID);
 419:../OSsrc/os_task.c ****         }
 420:../OSsrc/os_task.c ****     }
 421:../OSsrc/os_task.c **** #endif
 422:../OSsrc/os_task.c **** 
 423:../OSsrc/os_task.c ****     OS_ENTER_CRITICAL();
 424:../OSsrc/os_task.c ****     if (prio == OS_PRIO_SELF) {                                 /* See if requesting to delete self
 425:../OSsrc/os_task.c ****         prio = OSTCBCur->OSTCBPrio;                             /* Set priority to delete to curren
 426:../OSsrc/os_task.c ****     }
 427:../OSsrc/os_task.c ****     ptcb = OSTCBPrioTbl[prio];
 428:../OSsrc/os_task.c ****     if (ptcb == (OS_TCB *)0) {                                  /* Task to delete must exist       
 429:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
 430:../OSsrc/os_task.c ****         return (OS_ERR_TASK_NOT_EXIST);
 431:../OSsrc/os_task.c ****     }
 432:../OSsrc/os_task.c ****     if (ptcb == OS_TCB_RESERVED) {                              /* Must not be assigned to Mutex   
 433:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
 434:../OSsrc/os_task.c ****         return (OS_ERR_TASK_DEL);
 435:../OSsrc/os_task.c ****     }
 436:../OSsrc/os_task.c ****     y            =  ptcb->OSTCBY;
 437:../OSsrc/os_task.c ****     OSRdyTbl[y] &= ~ptcb->OSTCBBitX;
 438:../OSsrc/os_task.c ****     if (OSRdyTbl[y] == 0) {                                     /* Make task not ready             
 439:../OSsrc/os_task.c ****         OSRdyGrp &= ~ptcb->OSTCBBitY;
 440:../OSsrc/os_task.c ****     }
 441:../OSsrc/os_task.c ****     
 442:../OSsrc/os_task.c **** #if OS_EVENT_EN
 443:../OSsrc/os_task.c ****     pevent = ptcb->OSTCBEventPtr;
 444:../OSsrc/os_task.c ****     if (pevent != (OS_EVENT *)0) {                              /* If task is waiting on event     
 445:../OSsrc/os_task.c ****         pevent->OSEventTbl[y] &= ~ptcb->OSTCBBitX;
 446:../OSsrc/os_task.c ****         if (pevent->OSEventTbl[y] == 0) {                       /* ... remove task from ...        
 447:../OSsrc/os_task.c ****             pevent->OSEventGrp &= ~ptcb->OSTCBBitY;             /* ... event ctrl block            
 448:../OSsrc/os_task.c ****         }
 449:../OSsrc/os_task.c ****     }
 450:../OSsrc/os_task.c **** #endif
 451:../OSsrc/os_task.c **** 
 452:../OSsrc/os_task.c **** #if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
 453:../OSsrc/os_task.c ****     pnode = ptcb->OSTCBFlagNode;
 454:../OSsrc/os_task.c ****     if (pnode != (OS_FLAG_NODE *)0) {                           /* If task is waiting on event flag
 455:../OSsrc/os_task.c ****         OS_FlagUnlink(pnode);                                   /* Remove from wait list           
 456:../OSsrc/os_task.c ****     }
 457:../OSsrc/os_task.c **** #endif
 458:../OSsrc/os_task.c **** 
 459:../OSsrc/os_task.c ****     ptcb->OSTCBDly      = 0;                                    /* Prevent OSTimeTick() from updati
 460:../OSsrc/os_task.c ****     ptcb->OSTCBStat     = OS_STAT_RDY;                          /* Prevent task from being resumed 
 461:../OSsrc/os_task.c ****     ptcb->OSTCBStatPend = OS_STAT_PEND_OK;
 462:../OSsrc/os_task.c ****     if (OSLockNesting < 255u) {                                 /* Make sure we don't context switc
 463:../OSsrc/os_task.c ****         OSLockNesting++;
 464:../OSsrc/os_task.c ****     }
 465:../OSsrc/os_task.c ****     OS_EXIT_CRITICAL();                                         /* Enabling INT. ignores next instr
 466:../OSsrc/os_task.c ****     OS_Dummy();                                                 /* ... Dummy ensures that INTs will
 467:../OSsrc/os_task.c ****     OS_ENTER_CRITICAL();                                        /* ... disabled HERE!              
 468:../OSsrc/os_task.c ****     if (OSLockNesting > 0) {                                    /* Remove context switch lock      
 469:../OSsrc/os_task.c ****         OSLockNesting--;
 470:../OSsrc/os_task.c ****     }
 471:../OSsrc/os_task.c ****     OSTaskDelHook(ptcb);                                        /* Call user defined hook          
 472:../OSsrc/os_task.c ****     OSTaskCtr--;                                                /* One less task being managed     
 473:../OSsrc/os_task.c ****     OSTCBPrioTbl[prio] = (OS_TCB *)0;                           /* Clear old priority entry        
 474:../OSsrc/os_task.c ****     if (ptcb->OSTCBPrev == (OS_TCB *)0) {                       /* Remove from TCB chain           
 475:../OSsrc/os_task.c ****         ptcb->OSTCBNext->OSTCBPrev = (OS_TCB *)0;
 476:../OSsrc/os_task.c ****         OSTCBList                  = ptcb->OSTCBNext;
 477:../OSsrc/os_task.c ****     } else {
 478:../OSsrc/os_task.c ****         ptcb->OSTCBPrev->OSTCBNext = ptcb->OSTCBNext;
 479:../OSsrc/os_task.c ****         ptcb->OSTCBNext->OSTCBPrev = ptcb->OSTCBPrev;
 480:../OSsrc/os_task.c ****     }
 481:../OSsrc/os_task.c ****     ptcb->OSTCBNext   = OSTCBFreeList;                          /* Return TCB to free TCB list     
 482:../OSsrc/os_task.c ****     OSTCBFreeList     = ptcb;
 483:../OSsrc/os_task.c **** #if OS_TASK_NAME_SIZE > 1
 484:../OSsrc/os_task.c ****     ptcb->OSTCBTaskName[0] = '?';                               /* Unknown name                    
 485:../OSsrc/os_task.c ****     ptcb->OSTCBTaskName[1] = OS_ASCII_NUL;
 486:../OSsrc/os_task.c **** #endif
 487:../OSsrc/os_task.c ****     OS_EXIT_CRITICAL();
 488:../OSsrc/os_task.c ****     if (OSRunning == OS_TRUE) {
 489:../OSsrc/os_task.c ****         OS_Sched();                                             /* Find new highest priority task  
 490:../OSsrc/os_task.c ****     }
 491:../OSsrc/os_task.c ****     return (OS_ERR_NONE);
 492:../OSsrc/os_task.c **** }
 493:../OSsrc/os_task.c **** #endif
 494:../OSsrc/os_task.c **** /*$PAGE*/
 495:../OSsrc/os_task.c **** /*
 496:../OSsrc/os_task.c **** ***************************************************************************************************
 497:../OSsrc/os_task.c **** *                                    REQUEST THAT A TASK DELETE ITSELF
 498:../OSsrc/os_task.c **** *
 499:../OSsrc/os_task.c **** * Description: This function is used to:
 500:../OSsrc/os_task.c **** *                   a) notify a task to delete itself.
 501:../OSsrc/os_task.c **** *                   b) to see if a task requested that the current task delete itself.
 502:../OSsrc/os_task.c **** *              This function is a little tricky to understand.  Basically, you have a task that nee
 503:../OSsrc/os_task.c **** *              to be deleted however, this task has resources that it has allocated (memory buffers
 504:../OSsrc/os_task.c **** *              semaphores, mailboxes, queues etc.).  The task cannot be deleted otherwise these
 505:../OSsrc/os_task.c **** *              resources would not be freed.  The requesting task calls OSTaskDelReq() to indicate 
 506:../OSsrc/os_task.c **** *              the task needs to be deleted.  Deleting of the task is however, deferred to the task
 507:../OSsrc/os_task.c **** *              be deleted.  For example, suppose that task #10 needs to be deleted.  The requesting
 508:../OSsrc/os_task.c **** *              example, task #5, would call OSTaskDelReq(10).  When task #10 gets to execute, it ca
 509:../OSsrc/os_task.c **** *              this function by specifying OS_PRIO_SELF and monitors the returned value.  If the re
 510:../OSsrc/os_task.c **** *              value is OS_ERR_TASK_DEL_REQ, another task requested a task delete.  Task #10 would 
 511:../OSsrc/os_task.c **** *              this:
 512:../OSsrc/os_task.c **** *
 513:../OSsrc/os_task.c **** *                   void Task(void *p_arg)
 514:../OSsrc/os_task.c **** *                   {
 515:../OSsrc/os_task.c **** *                       .
 516:../OSsrc/os_task.c **** *                       .
 517:../OSsrc/os_task.c **** *                       while (1) {
 518:../OSsrc/os_task.c **** *                           OSTimeDly(1);
 519:../OSsrc/os_task.c **** *                           if (OSTaskDelReq(OS_PRIO_SELF) == OS_ERR_TASK_DEL_REQ) {
 520:../OSsrc/os_task.c **** *                               Release any owned resources;
 521:../OSsrc/os_task.c **** *                               De-allocate any dynamic memory;
 522:../OSsrc/os_task.c **** *                               OSTaskDel(OS_PRIO_SELF);
 523:../OSsrc/os_task.c **** *                           }
 524:../OSsrc/os_task.c **** *                       }
 525:../OSsrc/os_task.c **** *                   }
 526:../OSsrc/os_task.c **** *
 527:../OSsrc/os_task.c **** * Arguments  : prio    is the priority of the task to request the delete from
 528:../OSsrc/os_task.c **** *
 529:../OSsrc/os_task.c **** * Returns    : OS_ERR_NONE            if the task exist and the request has been registered
 530:../OSsrc/os_task.c **** *              OS_ERR_TASK_NOT_EXIST  if the task has been deleted.  This allows the caller to know
 531:../OSsrc/os_task.c **** *                                     the request has been executed.
 532:../OSsrc/os_task.c **** *              OS_ERR_TASK_DEL        if the task is assigned to a Mutex.
 533:../OSsrc/os_task.c **** *              OS_ERR_TASK_DEL_IDLE   if you requested to delete uC/OS-II's idle task
 534:../OSsrc/os_task.c **** *              OS_ERR_PRIO_INVALID    if the priority you specify is higher that the maximum allowe
 535:../OSsrc/os_task.c **** *                                     (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_S
 536:../OSsrc/os_task.c **** *              OS_ERR_TASK_DEL_REQ    if a task (possibly another task) requested that the running 
 537:../OSsrc/os_task.c **** *                                     deleted.
 538:../OSsrc/os_task.c **** ***************************************************************************************************
 539:../OSsrc/os_task.c **** */
 540:../OSsrc/os_task.c **** /*$PAGE*/
 541:../OSsrc/os_task.c **** #if OS_TASK_DEL_EN > 0
 542:../OSsrc/os_task.c **** INT8U  OSTaskDelReq (INT8U prio)
 543:../OSsrc/os_task.c **** {
 544:../OSsrc/os_task.c ****     INT8U      stat;
 545:../OSsrc/os_task.c ****     OS_TCB    *ptcb;
 546:../OSsrc/os_task.c **** #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register       
 547:../OSsrc/os_task.c ****     OS_CPU_SR  cpu_sr = 0;
 548:../OSsrc/os_task.c **** #endif
 549:../OSsrc/os_task.c **** 
 550:../OSsrc/os_task.c **** 
 551:../OSsrc/os_task.c **** 
 552:../OSsrc/os_task.c ****     if (prio == OS_TASK_IDLE_PRIO) {                            /* Not allowed to delete idle task 
 553:../OSsrc/os_task.c ****         return (OS_ERR_TASK_DEL_IDLE);
 554:../OSsrc/os_task.c ****     }
 555:../OSsrc/os_task.c **** #if OS_ARG_CHK_EN > 0
 556:../OSsrc/os_task.c ****     if (prio >= OS_LOWEST_PRIO) {                               /* Task priority valid ?           
 557:../OSsrc/os_task.c ****         if (prio != OS_PRIO_SELF) {
 558:../OSsrc/os_task.c ****             return (OS_ERR_PRIO_INVALID);
 559:../OSsrc/os_task.c ****         }
 560:../OSsrc/os_task.c ****     }
 561:../OSsrc/os_task.c **** #endif
 562:../OSsrc/os_task.c ****     if (prio == OS_PRIO_SELF) {                                 /* See if a task is requesting to .
 563:../OSsrc/os_task.c ****         OS_ENTER_CRITICAL();                                    /* ... this task to delete itself  
 564:../OSsrc/os_task.c ****         stat = OSTCBCur->OSTCBDelReq;                           /* Return request status to caller 
 565:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
 566:../OSsrc/os_task.c ****         return (stat);
 567:../OSsrc/os_task.c ****     }
 568:../OSsrc/os_task.c ****     OS_ENTER_CRITICAL();
 569:../OSsrc/os_task.c ****     ptcb = OSTCBPrioTbl[prio];
 570:../OSsrc/os_task.c ****     if (ptcb == (OS_TCB *)0) {                                  /* Task to delete must exist       
 571:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
 572:../OSsrc/os_task.c ****         return (OS_ERR_TASK_NOT_EXIST);                         /* Task must already be deleted    
 573:../OSsrc/os_task.c ****     }
 574:../OSsrc/os_task.c ****     if (ptcb == OS_TCB_RESERVED) {                              /* Must NOT be assigned to a Mutex 
 575:../OSsrc/os_task.c ****         OS_EXIT_CRITICAL();
 576:../OSsrc/os_task.c ****         return (OS_ERR_TASK_DEL);
 577:../OSsrc/os_task.c ****     }
 578:../OSsrc/os_task.c ****     ptcb->OSTCBDelReq = OS_ERR_TASK_DEL_REQ;                    /* Set flag indicating task to be D
 579:../OSsrc/os_task.c ****     OS_EXIT_CRITICAL();
 580:../OSsrc/os_task.c ****     return (OS_ERR_NONE);
 581:../OSsrc/os_task.c **** }
 582:../OSsrc/os_task.c **** #endif
 583:../OSsrc/os_task.c **** /*$PAGE*/
 584:../OSsrc/os_task.c **** /*
 585:../OSsrc/os_task.c **** ***************************************************************************************************
 586:../OSsrc/os_task.c **** *                                        GET THE NAME OF A TASK
 587:../OSsrc/os_task.c **** *
 588:../OSsrc/os_task.c **** * Description: This function is called to obtain the name of a task.
 589:../OSsrc/os_task.c **** *
 590:../OSsrc/os_task.c **** * Arguments  : prio      is the priority of the task that you want to obtain the name from.
 591:../OSsrc/os_task.c **** *
 592:../OSsrc/os_task.c **** *              pname     is a pointer to an ASCII string that will receive the name of the task.  T
 593:../OSsrc/os_task.c **** *                        string must be able to hold at least OS_TASK_NAME_SIZE characters.
 594:../OSsrc/os_task.c **** *
 595:../OSsrc/os_task.c **** *              perr      is a pointer to an error code that can contain one of the following values
 596:../OSsrc/os_task.c **** *
 597:../OSsrc/os_task.c **** *                        OS_ERR_NONE                if the requested task is resumed
 598:../OSsrc/os_task.c **** *                        OS_ERR_TASK_NOT_EXIST      if the task has not been created or is assigned
 599:../OSsrc/os_task.c **** *                        OS_ERR_PRIO_INVALID        if you specified an invalid priority:
 600:../OSsrc/os_task.c **** *                                                   A higher value than the idle task or not OS_PRI
 601:../OSsrc/os_task.c **** *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 602:../OSsrc/os_task.c **** *                        OS_ERR_NAME_GET_ISR        You called this function from an ISR
 603:../OSsrc/os_task.c **** *                        
 604:../OSsrc/os_task.c **** *

⌨️ 快捷键说明

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