📄 os_task.lst
字号:
ANSI-C/cC++ Compiler for HC08 V-5.0.12 ICG, Oct 6 2000
1: /*
2: *********************************************************************************************************
3: * uC/OS-II
4: * The Real-Time Kernel
5: * TASK MANAGEMENT
6: *
7: * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
8: * All Rights Reserved
9: *
10: * V2.00
11: *
12: * File : OS_TASK.C
13: * By : Jean J. Labrosse
14: *********************************************************************************************************
15: */
16:
17:
18: #include "includes.h"
19:
20:
21: /*
22: *********************************************************************************************************
23: * LOCAL FUNCTION PROTOTYPES
24: *********************************************************************************************************
25: */
26:
27:
28: static void OSDummy(void);
29:
30: /*
31: *********************************************************************************************************
32: * DUMMY FUNCTION
33: *
34: * Description: This function doesn't do anything. It is called by OSTaskDel() to ensure that interrupts
35: * are disabled immediately after they are enabled.
36: *
37: * Arguments : none
38: *
39: * Returns : none
40: *********************************************************************************************************
41: */
42:
43: static void OSDummy (void)
44: {
Function: OSDummy
Source : C:\motoctest\ucos1\sources\os_task.c
Options : -Cc -EnvGENPATH=C:\motoctest\ucos1;C:\motoctest\ucos1\bin;C:\motoctest\ucos1\cmd;C:\motoctest\ucos1\prm;C:\motoctest\ucos1\sources;C:\Metrowerks\lib\HC08c\LIB;C:\Metrowerks\lib\HC08c\src;C:\Metrowerks\lib\HC08c\INCLUDE -EnvLIBPATH=C:\Metrowerks\lib\HC08c\INCLUDE -EnvOBJPATH=C:\motoctest\ucos1\bin -EnvTEXTPATH=C:\motoctest\ucos1\bin -La=%f.inc -Lasm=%n.lst -ObjN=C:\motoctest\ucos1\ucos1_Data\MMDS-MMEVS\ObjectCode\os_task.c.o
45: }
0000 81 RTS
46:
47: /*$PAGE*/
48: /*
49: *********************************************************************************************************
50: * CHANGE PRIORITY OF A TASK
51: *
52: * Description: This function allows you to change the priority of a task dynamically. Note that the new
53: * priority MUST be available.
54: *
55: * Arguments : oldp is the old priority
56: *
57: * newp is the new priority
58: *
59: * Returns : OS_NO_ERR is the call was successful
60: * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
61: * (i.e. >= OS_LOWEST_PRIO)
62: * OS_PRIO_EXIST if the new priority already exist.
63: * OS_PRIO_ERR there is no task with the specified OLD priority (i.e. the OLD task does
64: * not exist.
65: *********************************************************************************************************
66: */
67:
68: #if OS_TASK_CHANGE_PRIO_EN
69: INT8U OSTaskChangePrio (INT8U oldprio, INT8U newprio)
70: {
71: OS_TCB *ptcb;
72: OS_EVENT *pevent;
73: INT8U x;
74: INT8U y;
75: INT8U bitx;
76: INT8U bity;
77:
78:
79: if ((oldprio >= OS_LOWEST_PRIO && oldprio != OS_PRIO_SELF) ||
80: newprio >= OS_LOWEST_PRIO) {
81: return (OS_PRIO_INVALID);
82: }
83: OS_ENTER_CRITICAL();
84: if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) { /* New priority must not already exist */
85: OS_EXIT_CRITICAL();
86: return (OS_PRIO_EXIST);
87: } else {
88: OSTCBPrioTbl[newprio] = (OS_TCB *)1; /* Reserve the entry to prevent others */
89: OS_EXIT_CRITICAL();
90: y = newprio >> 3; /* Precompute to reduce INT. latency */
91: bity = OSMapTbl[y];
92: x = newprio & 0x07;
93: bitx = OSMapTbl[x];
94: OS_ENTER_CRITICAL();
95: if (oldprio == OS_PRIO_SELF) { /* See if changing self */
96: oldprio = OSTCBCur->OSTCBPrio; /* Yes, get priority */
97: }
98: if ((ptcb = OSTCBPrioTbl[oldprio]) != (OS_TCB *)0) { /* Task to change must exist */
99: OSTCBPrioTbl[oldprio] = (OS_TCB *)0; /* Remove TCB from old priority */
100: if (OSRdyTbl[ptcb->OSTCBY] & ptcb->OSTCBBitX) { /* If task is ready make it not ready */
101: if ((OSRdyTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
102: OSRdyGrp &= ~ptcb->OSTCBBitY;
103: }
104: OSRdyGrp |= bity; /* Make new priority ready to run */
105: OSRdyTbl[y] |= bitx;
106: } else {
107: if ((pevent = ptcb->OSTCBEventPtr) != (OS_EVENT *)0) { /* Remove from event wait list */
108: if ((pevent->OSEventTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
109: pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
110: }
111: pevent->OSEventGrp |= bity; /* Add new priority to wait list */
112: pevent->OSEventTbl[y] |= bitx;
113: }
114: }
115: OSTCBPrioTbl[newprio] = ptcb; /* Place pointer to TCB @ new priority */
116: ptcb->OSTCBPrio = newprio; /* Set new task priority */
117: ptcb->OSTCBY = y;
118: ptcb->OSTCBX = x;
119: ptcb->OSTCBBitY = bity;
120: ptcb->OSTCBBitX = bitx;
121: OS_EXIT_CRITICAL();
122: OSSched(); /* Run highest priority task ready */
123: return (OS_NO_ERR);
124: } else {
125: OSTCBPrioTbl[newprio] = (OS_TCB *)0; /* Release the reserved prio. */
126: OS_EXIT_CRITICAL();
127: return (OS_PRIO_ERR); /* Task to change didn't exist */
128: }
129: }
130: }
131: #endif
132: /*$PAGE*/
133: /*
134: *********************************************************************************************************
135: * CREATE A TASK
136: *
137: * Description: This function is used to have uC/OS-II manage the execution of a task. Tasks can either
138: * be created prior to the start of multitasking or by a running task. A task cannot be
139: * created by an ISR.
140: *
141: * Arguments : task is a pointer to the task's code
142: *
143: * pdata is a pointer to an optional data area which can be used to pass parameters to
144: * the task when the task first executes. Where the task is concerned it thinks
145: * it was invoked and passed the argument 'pdata' as follows:
146: *
147: * void Task (void *pdata)
148: * {
149: * for (;;) {
150: * Task code;
151: * }
152: * }
153: *
154: * ptos is a pointer to the task's top of stack. If the configuration constant
155: * OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
156: * memory to low memory). 'pstk' will thus point to the highest (valid) memory
157: * location of the stack. If OS_STK_GROWTH is set to 0, 'pstk' will point to the
158: * lowest memory location of the stack and the stack will grow with increasing
159: * memory locations.
160: *
161: * prio is the task's priority. A unique priority MUST be assigned to each task and the
162: * lower the number, the higher the priority.
163: *
164: * Returns : OS_NO_ERR if the function was successful.
165: * OS_PRIO_EXIT if the task priority already exist
166: * (each task MUST have a unique priority).
167: * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
168: * (i.e. >= OS_LOWEST_PRIO)
169: *********************************************************************************************************
170: */
171:
172: #if OS_TASK_CREATE_EN
173: INT8U OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio)
174: {
Function: OSTaskCreate
Source : C:\motoctest\ucos1\sources\os_task.c
Options : -Cc -EnvGENPATH=C:\motoctest\ucos1;C:\motoctest\ucos1\bin;C:\motoctest\ucos1\cmd;C:\motoctest\ucos1\prm;C:\motoctest\ucos1\sources;C:\Metrowerks\lib\HC08c\LIB;C:\Metrowerks\lib\HC08c\src;C:\Metrowerks\lib\HC08c\INCLUDE -EnvLIBPATH=C:\Metrowerks\lib\HC08c\INCLUDE -EnvOBJPATH=C:\motoctest\ucos1\bin -EnvTEXTPATH=C:\motoctest\ucos1\bin -La=%f.inc -Lasm=%n.lst -ObjN=C:\motoctest\ucos1\ucos1_Data\MMDS-MMEVS\ObjectCode\os_task.c.o
0000 87 PSHA
0001 a7fc AIS #-4
175: void *psp;
176: INT8U err;
177:
178:
179: if (prio > OS_LOWEST_PRIO) { /* Make sure priority is within allowable range */
0003 a103 CMP #3
0005 2305 BLS LC ;abs = 000c
180: return (OS_PRIO_INVALID);
0007 a62a LDA #42
0009 cc0096 JMP L96 ;abs = 0096
000c LC:
181: }
182: OS_ENTER_CRITICAL();
000c 9b SEI
183: if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
000d 9eee05 LDX 5,SP
0010 58 LSLX
0011 8c CLRH
0012 6d00 TST @OSTCBPrioTbl,X
0014 2610 BNE L26 ;abs = 0026
0016 9ee605 LDA 5,SP
0019 48 LSLA
001a 87 PSHA
001b 8b PSHH
001c 86 PULA
001d 9eef02 STX 2,SP
0020 86 PULA
0021 ab00 ADD @OSTCBPrioTbl
0023 97 TAX
0024 6d01 TST 1,X
0026 L26:
0026 2670 BNE L98 ;abs = 0098
184: OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -