📄 os_task.lst
字号:
400 * Description: This function allows you to delete a task. The calling task can delete itself by
401 * its own priority number. The deleted task is returned to the dormant state and can be
402 * re-activated by creating the deleted task again.
403 *
404 * Arguments : prio is the priority of the task to delete. Note that you can explicitely delete
405 * the current task without knowing its priority level by setting 'prio' to
406 * OS_PRIO_SELF.
407 *
408 * Returns : OS_ERR_NONE if the call is successful
409 * OS_ERR_TASK_DEL_IDLE if you attempted to delete uC/OS-II's idle task
410 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the maximum allowed
411 * (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
412 * OS_ERR_TASK_DEL if the task is assigned to a Mutex PIP.
413 * OS_ERR_TASK_NOT_EXIST if the task you want to delete does not exist.
414 * OS_ERR_TASK_DEL_ISR if you tried to delete a task from an ISR
415 *
416 * Notes : 1) To reduce interrupt latency, OSTaskDel() 'disables' the task:
417 * a) by making it not ready
418 * b) by removing it from any wait lists
419 * c) by preventing OSTimeTick() from making the task ready to run.
420 * The task can then be 'unlinked' from the miscellaneous structures in uC/OS-II.
421 * 2) The function OS_Dummy() is called after OS_EXIT_CRITICAL() because, on most processors,
422 * the next instruction following the enable interrupt instruction is ignored.
423 * 3) An ISR cannot delete a task.
424 * 4) The lock nesting counter is incremented because, for a brief instant, if the current
425 * task is being deleted, the current task would not be able to be rescheduled because it
426 * is removed from the ready list. Incrementing the nesting counter prevents another task
427 * from being schedule. This means that an ISR would return to the current task which is
428 * being deleted. The rest of the deletion would thus be able to be completed.
429 *********************************************************************************************************
430 */
431
432 #if OS_TASK_DEL_EN > 0u
\ In section .text, align 2, keep-with-next
433 INT8U OSTaskDel (INT8U prio)
434 {
\ OSTaskDel:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
435 #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
436 OS_FLAG_NODE *pnode;
437 #endif
438 OS_TCB *ptcb;
439 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
440 OS_CPU_SR cpu_sr = 0u;
\ 00000004 0027 MOVS R7,#+0
441 #endif
442
443
444
445 if (OSIntNesting > 0u) { /* See if trying to delete from ISR */
\ 00000006 ........ LDR.W R0,??DataTable14_5
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 0028 CMP R0,#+0
\ 0000000E 01D0 BEQ.N ??OSTaskDel_0
446 return (OS_ERR_TASK_DEL_ISR);
\ 00000010 4020 MOVS R0,#+64
\ 00000012 B3E0 B.N ??OSTaskDel_1
447 }
448 if (prio == OS_TASK_IDLE_PRIO) { /* Not allowed to delete idle task */
\ ??OSTaskDel_0:
\ 00000014 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000016 3F2C CMP R4,#+63
\ 00000018 01D1 BNE.N ??OSTaskDel_2
449 return (OS_ERR_TASK_DEL_IDLE);
\ 0000001A 3E20 MOVS R0,#+62
\ 0000001C AEE0 B.N ??OSTaskDel_1
450 }
451 #if OS_ARG_CHK_EN > 0u
452 if (prio >= OS_LOWEST_PRIO) { /* Task priority valid ? */
453 if (prio != OS_PRIO_SELF) {
454 return (OS_ERR_PRIO_INVALID);
455 }
456 }
457 #endif
458
459 /*$PAGE*/
460 OS_ENTER_CRITICAL();
\ ??OSTaskDel_2:
\ 0000001E ........ BL OS_CPU_SR_Save
\ 00000022 0700 MOVS R7,R0
461 if (prio == OS_PRIO_SELF) { /* See if requesting to delete self */
\ 00000024 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000026 FF2C CMP R4,#+255
\ 00000028 05D1 BNE.N ??OSTaskDel_3
462 prio = OSTCBCur->OSTCBPrio; /* Set priority to delete to current */
\ 0000002A ........ LDR.W R0,??DataTable14_1
\ 0000002E 0068 LDR R0,[R0, #+0]
\ 00000030 90F83600 LDRB R0,[R0, #+54]
\ 00000034 0400 MOVS R4,R0
463 }
464 ptcb = OSTCBPrioTbl[prio];
\ ??OSTaskDel_3:
\ 00000036 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000038 ........ LDR.W R0,??DataTable14
\ 0000003C 50F82400 LDR R0,[R0, R4, LSL #+2]
\ 00000040 0600 MOVS R6,R0
465 if (ptcb == (OS_TCB *)0) { /* Task to delete must exist */
\ 00000042 002E CMP R6,#+0
\ 00000044 04D1 BNE.N ??OSTaskDel_4
466 OS_EXIT_CRITICAL();
\ 00000046 3800 MOVS R0,R7
\ 00000048 ........ BL OS_CPU_SR_Restore
467 return (OS_ERR_TASK_NOT_EXIST);
\ 0000004C 4320 MOVS R0,#+67
\ 0000004E 95E0 B.N ??OSTaskDel_1
468 }
469 if (ptcb == OS_TCB_RESERVED) { /* Must not be assigned to Mutex */
\ ??OSTaskDel_4:
\ 00000050 012E CMP R6,#+1
\ 00000052 04D1 BNE.N ??OSTaskDel_5
470 OS_EXIT_CRITICAL();
\ 00000054 3800 MOVS R0,R7
\ 00000056 ........ BL OS_CPU_SR_Restore
471 return (OS_ERR_TASK_DEL);
\ 0000005A 3D20 MOVS R0,#+61
\ 0000005C 8EE0 B.N ??OSTaskDel_1
472 }
473
474 OSRdyTbl[ptcb->OSTCBY] &= (OS_PRIO)~ptcb->OSTCBBitX;
\ ??OSTaskDel_5:
\ 0000005E 96F83800 LDRB R0,[R6, #+56]
\ 00000062 ........ LDR.W R1,??DataTable14_2
\ 00000066 405C LDRB R0,[R0, R1]
\ 00000068 96F83910 LDRB R1,[R6, #+57]
\ 0000006C 8843 BICS R0,R0,R1
\ 0000006E 96F83810 LDRB R1,[R6, #+56]
\ 00000072 ........ LDR.W R2,??DataTable14_2
\ 00000076 8854 STRB R0,[R1, R2]
475 if (OSRdyTbl[ptcb->OSTCBY] == 0u) { /* Make task not ready */
\ 00000078 96F83800 LDRB R0,[R6, #+56]
\ 0000007C ........ LDR.W R1,??DataTable14_2
\ 00000080 405C LDRB R0,[R0, R1]
\ 00000082 0028 CMP R0,#+0
\ 00000084 08D1 BNE.N ??OSTaskDel_6
476 OSRdyGrp &= (OS_PRIO)~ptcb->OSTCBBitY;
\ 00000086 ........ LDR.W R0,??DataTable14_3
\ 0000008A 0078 LDRB R0,[R0, #+0]
\ 0000008C 96F83A10 LDRB R1,[R6, #+58]
\ 00000090 8843 BICS R0,R0,R1
\ 00000092 ........ LDR.W R1,??DataTable14_3
\ 00000096 0870 STRB R0,[R1, #+0]
477 }
478
479 #if (OS_EVENT_EN)
480 if (ptcb->OSTCBEventPtr != (OS_EVENT *)0) {
\ ??OSTaskDel_6:
\ 00000098 F069 LDR R0,[R6, #+28]
\ 0000009A 0028 CMP R0,#+0
\ 0000009C 03D0 BEQ.N ??OSTaskDel_7
481 OS_EventTaskRemove(ptcb, ptcb->OSTCBEventPtr); /* Remove this task from any event wait list */
\ 0000009E F169 LDR R1,[R6, #+28]
\ 000000A0 3000 MOVS R0,R6
\ 000000A2 ........ BL OS_EventTaskRemove
482 }
483 #if (OS_EVENT_MULTI_EN > 0u)
484 if (ptcb->OSTCBEventMultiPtr != (OS_EVENT **)0) { /* Remove this task from any events' wait lists*/
\ ??OSTaskDel_7:
\ 000000A6 306A LDR R0,[R6, #+32]
\ 000000A8 0028 CMP R0,#+0
\ 000000AA 03D0 BEQ.N ??OSTaskDel_8
485 OS_EventTaskRemoveMulti(ptcb, ptcb->OSTCBEventMultiPtr);
\ 000000AC 316A LDR R1,[R6, #+32]
\ 000000AE 3000 MOVS R0,R6
\ 000000B0 ........ BL OS_EventTaskRemoveMulti
486 }
487 #endif
488 #endif
489
490 #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
491 pnode = ptcb->OSTCBFlagNode;
\ ??OSTaskDel_8:
\ 000000B4 B06A LDR R0,[R6, #+40]
\ 000000B6 0500 MOVS R5,R0
492 if (pnode != (OS_FLAG_NODE *)0) { /* If task is waiting on event flag */
\ 000000B8 002D CMP R5,#+0
\ 000000BA 02D0 BEQ.N ??OSTaskDel_9
493 OS_FlagUnlink(pnode); /* Remove from wait list */
\ 000000BC 2800 MOVS R0,R5
\ 000000BE ........ BL OS_FlagUnlink
494 }
495 #endif
496
497 ptcb->OSTCBDly = 0u; /* Prevent OSTimeTick() from updating */
\ ??OSTaskDel_9:
\ 000000C2 0020 MOVS R0,#+0
\ 000000C4 3063 STR R0,[R6, #+48]
498 ptcb->OSTCBStat = OS_STAT_RDY; /* Prevent task from being resumed */
\ 000000C6 0020 MOVS R0,#+0
\ 000000C8 86F83400 STRB R0,[R6, #+52]
499 ptcb->OSTCBStatPend = OS_STAT_PEND_OK;
\ 000000CC 0020 MOVS R0,#+0
\ 000000CE 86F83500 STRB R0,[R6, #+53]
500 if (OSLockNesting < 255u) { /* Make sure we don't context switch */
\ 000000D2 ........ LDR.W R0,??DataTable14_6
\ 000000D6 0078 LDRB R0,[R0, #+0]
\ 000000D8 FF28 CMP R0,#+255
\ 000000DA 06D0 BEQ.N ??OSTaskDel_10
501 OSLockNesting++;
\ 000000DC ........ LDR.W R0,??DataTable14_6
\ 000000E0 0078 LDRB R0,[R0, #+0]
\ 000000E2 401C ADDS R0,R0,#+1
\ 000000E4 ........ LDR.W R1,??DataTable14_6
\ 000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -