1 | /** |
---|
2 | * @file itronsys/task.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 1989-1999. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef _ITRONSYS_TASK_H |
---|
17 | #define _ITRONSYS_TASK_H |
---|
18 | |
---|
19 | #ifdef __cplusplus |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | /* |
---|
24 | * Create Task (cre_tsk) Structure |
---|
25 | */ |
---|
26 | |
---|
27 | typedef struct t_ctsk { |
---|
28 | VP exinf; /* extended information */ |
---|
29 | ATR tskatr; /* task attributes */ |
---|
30 | FP task; /* task start address */ |
---|
31 | PRI itskpri; /* initial task priority */ |
---|
32 | INT stksz; /* stack size */ |
---|
33 | /* additional information may be included depending on the implementation */ |
---|
34 | } T_CTSK; |
---|
35 | |
---|
36 | /* |
---|
37 | * Values for the tskatr field |
---|
38 | */ |
---|
39 | |
---|
40 | #define TA_ASM 0x00 /* program written in assembly language */ |
---|
41 | #define TA_HLNG 0x01 /* program written in high-level language */ |
---|
42 | #define TA_COP0 0x8000 /* uses coprocessor having ID = 0 */ |
---|
43 | #define TA_COP1 0x4000 /* uses coprocessor having ID = 1 */ |
---|
44 | #define TA_COP2 0x2000 /* uses coprocessor having ID = 2 */ |
---|
45 | #define TA_COP3 0x1000 /* uses coprocessor having ID = 3 */ |
---|
46 | #define TA_COP4 0x0800 /* uses coprocessor having ID = 4 */ |
---|
47 | #define TA_COP5 0x0400 /* uses coprocessor having ID = 5 */ |
---|
48 | #define TA_COP6 0x0200 /* uses coprocessor having ID = 6 */ |
---|
49 | #define TA_COP7 0x0100 /* uses coprocessor having ID = 7 */ |
---|
50 | |
---|
51 | /* |
---|
52 | * Values for the tskid field |
---|
53 | */ |
---|
54 | |
---|
55 | #define TSK_SELF 0 /* task specifies itself */ |
---|
56 | |
---|
57 | /* XXX is this a mistake in ITRON? FALSE was here and in the types list */ |
---|
58 | #if 0 |
---|
59 | |
---|
60 | #define FALSE 0 /* indicates a task-independent portion (return */ |
---|
61 | /* parameters only) */ |
---|
62 | #endif |
---|
63 | |
---|
64 | /* |
---|
65 | * Values for the tskpri field |
---|
66 | */ |
---|
67 | |
---|
68 | #define TPRI_INI 0 /* specifies the initial priority on */ |
---|
69 | /* task startup (chg_pri) */ |
---|
70 | #define TPRI_RUN 0 /* specifies the highest priority during */ |
---|
71 | /* execution (rot_rdq) */ |
---|
72 | |
---|
73 | |
---|
74 | /* |
---|
75 | * Reference Task (ref_tsk) Structure |
---|
76 | */ |
---|
77 | |
---|
78 | typedef struct t_rtsk { |
---|
79 | VP exinf; /* extended information */ |
---|
80 | PRI tskpri; /* current priority */ |
---|
81 | UINT tskstat; /* task state */ |
---|
82 | /* |
---|
83 | * The following are represent extended features of support |
---|
84 | * [level X] (implementation-dependent). |
---|
85 | */ |
---|
86 | UINT tskwait; /* cause of wait */ |
---|
87 | ID wid; /* ID of object being waited for */ |
---|
88 | INT wupcnt; /* wakeup request count */ |
---|
89 | INT suscnt; /* SUSPEND request count */ |
---|
90 | ATR tskatr; /* task attributes */ |
---|
91 | FP task; /* task start address */ |
---|
92 | PRI itskpri; /* initial task priority */ |
---|
93 | INT stksz; /* stack size */ |
---|
94 | } T_RTSK; |
---|
95 | |
---|
96 | /* |
---|
97 | * Values for the tskstat field |
---|
98 | */ |
---|
99 | |
---|
100 | |
---|
101 | #define TTS_RUN 0x01 /* RUN */ |
---|
102 | #define TTS_RDY 0x02 /* READY */ |
---|
103 | #define TTS_WAI 0x04 /* WAIT */ |
---|
104 | #define TTS_SUS 0x08 /* SUSPEND */ |
---|
105 | #define TTS_WAS 0x0C /* WAIT-SUSPEND */ |
---|
106 | #define TTS_DMT 0x10 /* DORMANT */ |
---|
107 | |
---|
108 | /* |
---|
109 | * Values for the tskwait field |
---|
110 | */ |
---|
111 | |
---|
112 | #define TTW_SLP 0x0001 /* wait due to slp_tsk or tslp_tsk */ |
---|
113 | #define TTW_DLY 0x0002 /* wait due to dly_tsk */ |
---|
114 | #define TTW_NOD 0x0008 /* connection function response wait */ |
---|
115 | #define TTW_FLG 0x0010 /* wait due to wai_flg or twai_flg */ |
---|
116 | #define TTW_SEM 0x0020 /* wait due to wai_sem or twai_sem */ |
---|
117 | #define TTW_MBX 0x0040 /* wait due to rcv_msg or trcv_msg */ |
---|
118 | #define TTW_SMBF 0x0080 /* wait due to snd_mbf or tsnd_mbf */ |
---|
119 | #define TTW_MBF 0x0100 /* wait due to rcv_mbf or trcv_mbf */ |
---|
120 | #define TTW_CAL 0x0200 /* wait for rendezvous call */ |
---|
121 | #define TTW_ACP 0x0400 /* wait for rendezvous accept */ |
---|
122 | #define TTW_RDV 0x0800 /* wait for rendezvous completion */ |
---|
123 | #define TTW_MPL 0x1000 /* wait due to get_blk or tget_blk */ |
---|
124 | #define TTW_MPF 0x2000 /* wait due to get_blf or tget_blf */ |
---|
125 | |
---|
126 | /* |
---|
127 | * Since the task states given by tskstat and tskwait are expressed |
---|
128 | * by bit correspondences, they are convenient when looking for OR |
---|
129 | * conditions (such as whether a task is in WAIT or READY state). |
---|
130 | */ |
---|
131 | |
---|
132 | /* |
---|
133 | * Task Management Functions |
---|
134 | */ |
---|
135 | |
---|
136 | /* |
---|
137 | * cre_tsk - Create Task |
---|
138 | */ |
---|
139 | |
---|
140 | ER cre_tsk( |
---|
141 | ID tskid, |
---|
142 | T_CTSK *pk_ctsk |
---|
143 | ); |
---|
144 | |
---|
145 | /* |
---|
146 | * del_tsk - Delete Task |
---|
147 | */ |
---|
148 | |
---|
149 | ER del_tsk( |
---|
150 | ID tskid |
---|
151 | ); |
---|
152 | |
---|
153 | /* |
---|
154 | * sta_tsk - Start Task |
---|
155 | */ |
---|
156 | |
---|
157 | ER sta_tsk( |
---|
158 | ID tskid, |
---|
159 | INT stacd |
---|
160 | ); |
---|
161 | |
---|
162 | /* |
---|
163 | * ext_tsk - Exit Issuing Task |
---|
164 | */ |
---|
165 | |
---|
166 | void ext_tsk( void ); |
---|
167 | |
---|
168 | /* |
---|
169 | * exd_tsk - Exit and Delete Task |
---|
170 | */ |
---|
171 | |
---|
172 | void exd_tsk( void ); |
---|
173 | |
---|
174 | /* |
---|
175 | * ter_tsk - Terminate Other Task |
---|
176 | */ |
---|
177 | |
---|
178 | ER ter_tsk( |
---|
179 | ID tskid |
---|
180 | ); |
---|
181 | |
---|
182 | /* |
---|
183 | * dis_dsp - Disable Dispatch |
---|
184 | */ |
---|
185 | |
---|
186 | ER dis_dsp( void ); |
---|
187 | |
---|
188 | /* |
---|
189 | * ena_dsp - Enable Dispatch |
---|
190 | */ |
---|
191 | |
---|
192 | ER ena_dsp( void ); |
---|
193 | |
---|
194 | /* |
---|
195 | * chg_pri - Change Task Priority |
---|
196 | */ |
---|
197 | |
---|
198 | ER chg_pri( |
---|
199 | ID tskid, |
---|
200 | PRI tskpri |
---|
201 | ); |
---|
202 | |
---|
203 | /* |
---|
204 | * rot_rdq - Rotate Tasks on the Ready Queue |
---|
205 | */ |
---|
206 | |
---|
207 | ER rot_rdq( |
---|
208 | PRI tskpri |
---|
209 | ); |
---|
210 | |
---|
211 | /* |
---|
212 | * rel_wai - Release Wait of Other Task |
---|
213 | */ |
---|
214 | |
---|
215 | ER rel_wai( |
---|
216 | ID tskid |
---|
217 | ); |
---|
218 | |
---|
219 | /* |
---|
220 | * get_tid - Get Task Identifier |
---|
221 | */ |
---|
222 | |
---|
223 | ER get_tid( |
---|
224 | ID *p_tskid |
---|
225 | ); |
---|
226 | |
---|
227 | /* |
---|
228 | * ref_tsk - Reference Task Status |
---|
229 | */ |
---|
230 | |
---|
231 | ER ref_tsk( |
---|
232 | T_RTSK *pk_rtsk, |
---|
233 | ID tskid |
---|
234 | ); |
---|
235 | |
---|
236 | |
---|
237 | /* |
---|
238 | * Task-Dependent Synchronization Functions |
---|
239 | */ |
---|
240 | |
---|
241 | /* |
---|
242 | * sus_tsk - Suspend Other Task |
---|
243 | */ |
---|
244 | |
---|
245 | ER sus_tsk( |
---|
246 | ID tskid |
---|
247 | ); |
---|
248 | |
---|
249 | /* |
---|
250 | * rsm_tsk - Resume Suspended Task |
---|
251 | */ |
---|
252 | |
---|
253 | ER rsm_tsk( |
---|
254 | ID tskid |
---|
255 | ); |
---|
256 | |
---|
257 | /* |
---|
258 | * frsm_tsk - Forcibly Resume Suspended Task |
---|
259 | */ |
---|
260 | |
---|
261 | ER frsm_tsk( |
---|
262 | ID tskid |
---|
263 | ); |
---|
264 | |
---|
265 | /* |
---|
266 | * slp_tsk - Sleep Task Sleep Task with Timeout |
---|
267 | */ |
---|
268 | |
---|
269 | ER slp_tsk( void ); |
---|
270 | |
---|
271 | /* |
---|
272 | * tslp_tsk - Sleep Task with Timeout |
---|
273 | */ |
---|
274 | |
---|
275 | ER tslp_tsk( |
---|
276 | TMO tmout |
---|
277 | ); |
---|
278 | |
---|
279 | /* |
---|
280 | * wup_tsk - Wakeup Other Task |
---|
281 | */ |
---|
282 | |
---|
283 | ER wup_tsk( |
---|
284 | ID tskid |
---|
285 | ); |
---|
286 | |
---|
287 | /* |
---|
288 | * can_wup - Cancel Wakeup Request |
---|
289 | */ |
---|
290 | |
---|
291 | ER can_wup( |
---|
292 | INT *p_wupcnt, |
---|
293 | ID tskid |
---|
294 | ); |
---|
295 | |
---|
296 | #ifdef __cplusplus |
---|
297 | } |
---|
298 | #endif |
---|
299 | |
---|
300 | #endif |
---|
301 | /* end of include file */ |
---|