source: UsbWattMeter/trunk/asp_dcre/kernel/task_manage.c@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 11.6 KB
Line 
1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
9 * Graduate School of Information Science, Nagoya Univ., JAPAN
10 *
11 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
12 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
13 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
14 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
15 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
16 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
17 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
18 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
19ƒƒ“ƒgi—˜—p
20 * ŽÒƒ}ƒjƒ…
21ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
22 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
23 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
24 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
25 * ‚ƁD
26 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
27ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
28ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
29 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
30 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
31 * •ñ‚·‚邱‚ƁD
32 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
33 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
34 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
35 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
36 * –Ɛӂ·‚邱‚ƁD
37 *
38 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
40 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
41 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
42 * ‚̐ӔC‚𕉂í‚È‚¢D
43 *
44 * @(#) $Id: task_manage.c 164 2016-03-07 11:33:50Z coas-nagasima $
45 */
46
47/*
48 * ƒ^ƒXƒNŠÇ—‹@”\
49 */
50
51#include "kernel_impl.h"
52#include "check.h"
53#include "task.h"
54#include "wait.h"
55
56/*
57 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
58 */
59#ifndef LOG_ACRE_TSK_ENTER
60#define LOG_ACRE_TSK_ENTER(pk_ctsk)
61#endif /* LOG_ACRE_TSK_ENTER */
62
63#ifndef LOG_ACRE_TSK_LEAVE
64#define LOG_ACRE_TSK_LEAVE(ercd)
65#endif /* LOG_ACRE_TSK_LEAVE */
66
67#ifndef LOG_DEL_TSK_ENTER
68#define LOG_DEL_TSK_ENTER(tskid)
69#endif /* LOG_DEL_TSK_ENTER */
70
71#ifndef LOG_DEL_TSK_LEAVE
72#define LOG_DEL_TSK_LEAVE(ercd)
73#endif /* LOG_DEL_TSK_LEAVE */
74
75#ifndef LOG_ACT_TSK_ENTER
76#define LOG_ACT_TSK_ENTER(tskid)
77#endif /* LOG_ACT_TSK_ENTER */
78
79#ifndef LOG_ACT_TSK_LEAVE
80#define LOG_ACT_TSK_LEAVE(ercd)
81#endif /* LOG_ACT_TSK_LEAVE */
82
83#ifndef LOG_IACT_TSK_ENTER
84#define LOG_IACT_TSK_ENTER(tskid)
85#endif /* LOG_IACT_TSK_ENTER */
86
87#ifndef LOG_IACT_TSK_LEAVE
88#define LOG_IACT_TSK_LEAVE(ercd)
89#endif /* LOG_IACT_TSK_LEAVE */
90
91#ifndef LOG_CAN_ACT_ENTER
92#define LOG_CAN_ACT_ENTER(tskid)
93#endif /* LOG_CAN_ACT_ENTER */
94
95#ifndef LOG_CAN_ACT_LEAVE
96#define LOG_CAN_ACT_LEAVE(ercd)
97#endif /* LOG_CAN_ACT_LEAVE */
98
99#ifndef LOG_EXT_TSK_ENTER
100#define LOG_EXT_TSK_ENTER()
101#endif /* LOG_EXT_TSK_ENTER */
102
103#ifndef LOG_EXT_TSK_LEAVE
104#define LOG_EXT_TSK_LEAVE(ercd)
105#endif /* LOG_EXT_TSK_LEAVE */
106
107#ifndef LOG_TER_TSK_ENTER
108#define LOG_TER_TSK_ENTER(tskid)
109#endif /* LOG_TER_TSK_ENTER */
110
111#ifndef LOG_TER_TSK_LEAVE
112#define LOG_TER_TSK_LEAVE(ercd)
113#endif /* LOG_TER_TSK_LEAVE */
114
115#ifndef LOG_CHG_PRI_ENTER
116#define LOG_CHG_PRI_ENTER(tskid, tskpri)
117#endif /* LOG_CHG_PRI_ENTER */
118
119#ifndef LOG_CHG_PRI_LEAVE
120#define LOG_CHG_PRI_LEAVE(ercd)
121#endif /* LOG_CHG_PRI_LEAVE */
122
123#ifndef LOG_GET_PRI_ENTER
124#define LOG_GET_PRI_ENTER(tskid, p_tskpri)
125#endif /* LOG_GET_PRI_ENTER */
126
127#ifndef LOG_GET_PRI_LEAVE
128#define LOG_GET_PRI_LEAVE(ercd, tskpri)
129#endif /* LOG_GET_PRI_LEAVE */
130
131#ifndef LOG_GET_INF_ENTER
132#define LOG_GET_INF_ENTER(p_exinf)
133#endif /* LOG_GET_INF_ENTER */
134
135#ifndef LOG_GET_INF_LEAVE
136#define LOG_GET_INF_LEAVE(ercd, exinf)
137#endif /* LOG_GET_INF_LEAVE */
138
139/*
140 * ƒ^ƒXƒN‚̐¶¬
141 */
142#ifdef TOPPERS_acre_tsk
143
144#ifndef TARGET_MIN_STKSZ
145#define TARGET_MIN_STKSZ 1U /* –¢’è‹`‚̏ꍇ‚Í0‚Å‚È‚¢‚±‚Æ‚ðƒ`ƒFƒbƒN */
146#endif /* TARGET_MIN_STKSZ */
147
148ER_UINT
149acre_tsk(const T_CTSK *pk_ctsk)
150{
151 TCB *p_tcb;
152 TINIB *p_tinib;
153 ATR tskatr;
154 void *stk;
155 ER ercd;
156
157 LOG_ACRE_TSK_ENTER(pk_ctsk);
158 CHECK_TSKCTX_UNL();
159 CHECK_RSATR(pk_ctsk->tskatr, TA_ACT|TARGET_TSKATR);
160 CHECK_ALIGN_FUNC(pk_ctsk->task);
161 CHECK_NONNULL_FUNC(pk_ctsk->task);
162 CHECK_TPRI(pk_ctsk->itskpri);
163 CHECK_PAR(pk_ctsk->stksz >= TARGET_MIN_STKSZ);
164 if (pk_ctsk->stk != NULL) {
165 CHECK_ALIGN_STKSZ(pk_ctsk->stksz);
166 CHECK_ALIGN_STACK(pk_ctsk->stk);
167 }
168 tskatr = pk_ctsk->tskatr;
169 stk = pk_ctsk->stk;
170
171 t_lock_cpu();
172 if (queue_empty(&free_tcb)) {
173 ercd = E_NOID;
174 }
175 else {
176 if (stk == NULL) {
177 stk = kernel_malloc(ROUND_STK_T(pk_ctsk->stksz));
178 tskatr |= TA_MEMALLOC;
179 }
180 if (stk == NULL) {
181 ercd = E_NOMEM;
182 }
183 else {
184 p_tcb = ((TCB *) queue_delete_next(&free_tcb));
185 p_tinib = (TINIB *)(p_tcb->p_tinib);
186 p_tinib->tskatr = tskatr;
187 p_tinib->exinf = pk_ctsk->exinf;
188 p_tinib->task = pk_ctsk->task;
189 p_tinib->ipriority = INT_PRIORITY(pk_ctsk->itskpri);
190#ifdef USE_TSKINICTXB
191 init_tskinictxb(&(p_tinib->tskinictxb), stk, pk_ctsk);
192#else /* USE_TSKINICTXB */
193 p_tinib->stksz = pk_ctsk->stksz;
194 p_tinib->stk = stk;
195#endif /* USE_TSKINICTXB */
196 p_tinib->texatr = TA_NULL;
197 p_tinib->texrtn = NULL;
198
199 p_tcb->actque = false;
200 make_dormant(p_tcb);
201 if ((p_tcb->p_tinib->tskatr & TA_ACT) != 0U) {
202 make_active(p_tcb);
203 }
204 ercd = TSKID(p_tcb);
205 }
206 }
207 t_unlock_cpu();
208
209 error_exit:
210 LOG_ACRE_TSK_LEAVE(ercd);
211 return(ercd);
212}
213
214#endif /* TOPPERS_acre_tsk */
215
216/*
217 * ƒ^ƒXƒN‚̍폜
218 */
219#ifdef TOPPERS_del_tsk
220
221ER
222del_tsk(ID tskid)
223{
224 TCB *p_tcb;
225 TINIB *p_tinib;
226 ER ercd;
227
228 LOG_DEL_TSK_ENTER(tskid);
229 CHECK_TSKCTX_UNL();
230 CHECK_TSKID(tskid);
231 p_tcb = get_tcb(tskid);
232
233 t_lock_cpu();
234 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
235 ercd = E_NOEXS;
236 }
237 else if (TSKID(p_tcb) > tmax_stskid && TSTAT_DORMANT(p_tcb->tstat)) {
238 p_tinib = (TINIB *)(p_tcb->p_tinib);
239#ifdef USE_TSKINICTXB
240 term_tskinictxb(&(p_tinib->tskinictxb));
241#else /* USE_TSKINICTXB */
242 if ((p_tinib->tskatr & TA_MEMALLOC) != 0U) {
243 kernel_free(p_tinib->stk);
244 }
245#endif /* USE_TSKINICTXB */
246 p_tinib->tskatr = TA_NOEXS;
247 queue_insert_prev(&free_tcb, &(p_tcb->task_queue));
248 ercd = E_OK;
249 }
250 else {
251 ercd = E_OBJ;
252 }
253 t_unlock_cpu();
254
255 error_exit:
256 LOG_DEL_TSK_LEAVE(ercd);
257 return(ercd);
258}
259
260#endif /* TOPPERS_del_tsk */
261
262/*
263 * ƒ^ƒXƒN‚Ì‹N“®
264 */
265#ifdef TOPPERS_act_tsk
266
267ER
268act_tsk(ID tskid)
269{
270 TCB *p_tcb;
271 ER ercd;
272
273 LOG_ACT_TSK_ENTER(tskid);
274 CHECK_TSKCTX_UNL();
275 CHECK_TSKID_SELF(tskid);
276 p_tcb = get_tcb_self(tskid);
277
278 t_lock_cpu();
279 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
280 ercd = E_NOEXS;
281 }
282 else if (TSTAT_DORMANT(p_tcb->tstat)) {
283 if (make_active(p_tcb)) {
284 dispatch();
285 }
286 ercd = E_OK;
287 }
288 else if (!(p_tcb->actque)) {
289 p_tcb->actque = true;
290 ercd = E_OK;
291 }
292 else {
293 ercd = E_QOVR;
294 }
295 t_unlock_cpu();
296
297 error_exit:
298 LOG_ACT_TSK_LEAVE(ercd);
299 return(ercd);
300}
301
302#endif /* TOPPERS_act_tsk */
303
304/*
305 * ƒ^ƒXƒN‚Ì‹N“®i”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—pj
306 */
307#ifdef TOPPERS_iact_tsk
308
309ER
310iact_tsk(ID tskid)
311{
312 TCB *p_tcb;
313 ER ercd;
314
315 LOG_IACT_TSK_ENTER(tskid);
316 CHECK_INTCTX_UNL();
317 CHECK_TSKID(tskid);
318 p_tcb = get_tcb(tskid);
319
320 i_lock_cpu();
321 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
322 ercd = E_NOEXS;
323 }
324 else if (TSTAT_DORMANT(p_tcb->tstat)) {
325 if (make_active(p_tcb)) {
326 reqflg = true;
327 }
328 ercd = E_OK;
329 }
330 else if (!(p_tcb->actque)) {
331 p_tcb->actque = true;
332 ercd = E_OK;
333 }
334 else {
335 ercd = E_QOVR;
336 }
337 i_unlock_cpu();
338
339 error_exit:
340 LOG_IACT_TSK_LEAVE(ercd);
341 return(ercd);
342}
343
344#endif /* TOPPERS_iact_tsk */
345
346/*
347 * ƒ^ƒXƒN‹N“®—v‹‚̃Lƒƒƒ“ƒZƒ‹
348 */
349#ifdef TOPPERS_can_act
350
351ER_UINT
352can_act(ID tskid)
353{
354 TCB *p_tcb;
355 ER_UINT ercd;
356
357 LOG_CAN_ACT_ENTER(tskid);
358 CHECK_TSKCTX_UNL();
359 CHECK_TSKID_SELF(tskid);
360 p_tcb = get_tcb_self(tskid);
361
362 t_lock_cpu();
363 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
364 ercd = E_NOEXS;
365 }
366 else {
367 ercd = p_tcb->actque ? 1 : 0;
368 p_tcb->actque = false;
369 }
370 t_unlock_cpu();
371
372 error_exit:
373 LOG_CAN_ACT_LEAVE(ercd);
374 return(ercd);
375}
376
377#endif /* TOPPERS_can_act */
378
379/*
380 * Ž©ƒ^ƒXƒN‚̏I—¹
381 */
382#ifdef TOPPERS_ext_tsk
383
384ER
385ext_tsk(void)
386{
387 ER ercd;
388
389 LOG_EXT_TSK_ENTER();
390 CHECK_TSKCTX();
391
392 if (t_sense_lock()) {
393 /*
394 * CPUƒƒbƒNó‘Ô‚Åext_tsk‚ªŒÄ‚΂ꂽê‡‚́CCPUƒƒbƒN‚ð‰ðœ‚µ
395 * ‚Ä‚©‚çƒ^ƒXƒN‚ðI—¹‚·‚éDŽÀ‘•ã‚́CƒT[ƒrƒXƒR[ƒ‹“à‚Å‚ÌCPU
396 * ƒƒbƒN‚ðÈ—ª‚·‚ê‚΂悢‚¾‚¯D
397 */
398 }
399 else {
400 t_lock_cpu();
401 }
402 if (disdsp) {
403 /*
404 * ƒfƒBƒXƒpƒbƒ`‹ÖŽ~ó‘Ô‚Åext_tsk‚ªŒÄ‚΂ꂽê‡‚́CƒfƒBƒXƒpƒb
405 * ƒ`‹–‰Âó‘Ô‚É‚µ‚Ä‚©‚çƒ^ƒXƒN‚ðI—¹‚·‚éD
406 */
407 disdsp = false;
408 }
409 if (!ipmflg) {
410 /*
411 * Š„ž‚Ý—Dæ“xƒ}ƒXƒNiIPMj‚ªTIPM_ENAALLˆÈŠO‚̏ó‘Ô‚Åext_tsk
412 * ‚ªŒÄ‚΂ꂽê‡‚́CIPM‚ðTIPM_ENAALL‚É‚µ‚Ä‚©‚çƒ^ƒXƒN‚ðI—¹‚·
413 * ‚éD
414 */
415 t_set_ipm(TIPM_ENAALL);
416 ipmflg = true;
417 }
418 dspflg = true;
419
420 (void) make_non_runnable(p_runtsk);
421 make_dormant(p_runtsk);
422 if (p_runtsk->actque) {
423 p_runtsk->actque = false;
424 (void) make_active(p_runtsk);
425 }
426 exit_and_dispatch();
427 ercd = E_SYS;
428
429 error_exit:
430 LOG_EXT_TSK_LEAVE(ercd);
431 return(ercd);
432}
433
434#endif /* TOPPERS_ext_tsk */
435
436/*
437 * ƒ^ƒXƒN‚Ì‹­§I—¹
438 */
439#ifdef TOPPERS_ter_tsk
440
441ER
442ter_tsk(ID tskid)
443{
444 TCB *p_tcb;
445 ER ercd;
446
447 LOG_TER_TSK_ENTER(tskid);
448 CHECK_TSKCTX_UNL();
449 CHECK_TSKID(tskid);
450 p_tcb = get_tcb(tskid);
451 CHECK_NONSELF(p_tcb);
452
453 t_lock_cpu();
454 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
455 ercd = E_NOEXS;
456 }
457 else if (TSTAT_DORMANT(p_tcb->tstat)) {
458 ercd = E_OBJ;
459 }
460 else {
461 if (TSTAT_RUNNABLE(p_tcb->tstat)) {
462 /*
463 * p_tcb‚ÍŽ©ƒ^ƒXƒN‚Å‚È‚¢‚½‚߁CiƒVƒ“ƒOƒ‹ƒvƒƒZƒbƒT‚ł́jŽÀ
464 * só‘Ô‚Å‚È‚­Cmake_non_runnable(p_tcb)‚Ń^ƒXƒNƒfƒBƒXƒpƒb
465 * ƒ`‚ª•K—v‚ɂȂ邱‚Æ‚Í‚È‚¢D
466 */
467 (void) make_non_runnable(p_tcb);
468 }
469 else if (TSTAT_WAITING(p_tcb->tstat)) {
470 wait_dequeue_wobj(p_tcb);
471 wait_dequeue_tmevtb(p_tcb);
472 }
473 make_dormant(p_tcb);
474 if (p_tcb->actque) {
475 p_tcb->actque = false;
476 if (make_active(p_tcb)) {
477 dispatch();
478 }
479 }
480 ercd = E_OK;
481 }
482 t_unlock_cpu();
483
484 error_exit:
485 LOG_TER_TSK_LEAVE(ercd);
486 return(ercd);
487}
488
489#endif /* TOPPERS_ter_tsk */
490
491/*
492 * ƒ^ƒXƒN‚̃x[ƒX—Dæ“x‚̕ύX
493 */
494#ifdef TOPPERS_chg_pri
495
496ER
497chg_pri(ID tskid, PRI tskpri)
498{
499 TCB *p_tcb;
500 uint_t newpri;
501 ER ercd;
502
503 LOG_CHG_PRI_ENTER(tskid, tskpri);
504 CHECK_TSKCTX_UNL();
505 CHECK_TSKID_SELF(tskid);
506 CHECK_TPRI_INI(tskpri);
507 p_tcb = get_tcb_self(tskid);
508
509 t_lock_cpu();
510 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
511 ercd = E_NOEXS;
512 }
513 else if (TSTAT_DORMANT(p_tcb->tstat)) {
514 ercd = E_OBJ;
515 }
516 else {
517 newpri = (tskpri == TPRI_INI) ? p_tcb->p_tinib->ipriority
518 : INT_PRIORITY(tskpri);
519 if (change_priority(p_tcb, newpri)) {
520 dispatch();
521 }
522 ercd = E_OK;
523 }
524 t_unlock_cpu();
525
526 error_exit:
527 LOG_CHG_PRI_LEAVE(ercd);
528 return(ercd);
529}
530
531#endif /* TOPPERS_chg_pri */
532
533/*
534 * ƒ^ƒXƒN—Dæ“x‚ÌŽQÆ
535 */
536#ifdef TOPPERS_get_pri
537
538ER
539get_pri(ID tskid, PRI *p_tskpri)
540{
541 TCB *p_tcb;
542 ER ercd;
543
544 LOG_GET_PRI_ENTER(tskid, p_tskpri);
545 CHECK_TSKCTX_UNL();
546 CHECK_TSKID_SELF(tskid);
547 p_tcb = get_tcb_self(tskid);
548
549 t_lock_cpu();
550 if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
551 ercd = E_NOEXS;
552 }
553 else if (TSTAT_DORMANT(p_tcb->tstat)) {
554 ercd = E_OBJ;
555 }
556 else {
557 *p_tskpri = EXT_TSKPRI(p_tcb->priority);
558 ercd = E_OK;
559 }
560 t_unlock_cpu();
561
562 error_exit:
563 LOG_GET_PRI_LEAVE(ercd, *p_tskpri);
564 return(ercd);
565}
566
567#endif /* TOPPERS_get_pri */
568
569/*
570 * Ž©ƒ^ƒXƒN‚ÌŠg’£î•ñ‚ÌŽQÆ
571 */
572#ifdef TOPPERS_get_inf
573
574ER
575get_inf(intptr_t *p_exinf)
576{
577 ER ercd;
578
579 LOG_GET_INF_ENTER(p_exinf);
580 CHECK_TSKCTX_UNL();
581
582 t_lock_cpu();
583 *p_exinf = p_runtsk->p_tinib->exinf;
584 ercd = E_OK;
585 t_unlock_cpu();
586
587 error_exit:
588 LOG_GET_INF_LEAVE(ercd, *p_exinf);
589 return(ercd);
590}
591
592#endif /* TOPPERS_get_inf */
Note: See TracBrowser for help on using the repository browser.