source: UsbWattMeter/trunk/asp_dcre/kernel/wait.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: 5.0 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-2010 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: wait.c 164 2016-03-07 11:33:50Z coas-nagasima $
45 */
46
47/*
48 * ‘Ò‚¿ó‘ÔŠÇ—ƒ‚ƒWƒ…
49[ƒ‹
50 */
51
52#include "kernel_impl.h"
53#include "wait.h"
54
55/*
56 * ‘Ò‚¿ó‘Ô‚Ö‚Ì‘JˆÚiƒ^ƒCƒ€ƒAƒEƒgŽw’èj
57 */
58#ifdef TOPPERS_waimake
59
60void
61make_wait_tmout(WINFO *p_winfo, TMEVTB *p_tmevtb, TMO tmout)
62{
63 (void) make_non_runnable(p_runtsk);
64 p_runtsk->p_winfo = p_winfo;
65 if (tmout > 0) {
66 p_winfo->p_tmevtb = p_tmevtb;
67 tmevtb_enqueue(p_tmevtb, (RELTIM) tmout,
68 (CBACK) wait_tmout, (void *) p_runtsk);
69 }
70 else {
71 assert(tmout == TMO_FEVR);
72 p_winfo->p_tmevtb = NULL;
73 }
74}
75
76#endif /* TOPPERS_waimake */
77
78/*
79 * ‘Ò‚¿‰ðœ
80 */
81#ifdef TOPPERS_waicmp
82
83bool_t
84wait_complete(TCB *p_tcb)
85{
86 wait_dequeue_tmevtb(p_tcb);
87 p_tcb->p_winfo->wercd = E_OK;
88 return(make_non_wait(p_tcb));
89}
90
91#endif /* TOPPERS_waicmp */
92
93/*
94 * ƒ^ƒCƒ€ƒAƒEƒg‚É”º‚¤‘Ò‚¿‰ðœ
95 */
96#ifdef TOPPERS_waitmo
97
98void
99wait_tmout(TCB *p_tcb)
100{
101 wait_dequeue_wobj(p_tcb);
102 p_tcb->p_winfo->wercd = E_TMOUT;
103 if (make_non_wait(p_tcb)) {
104 reqflg = true;
105 }
106
107 /*
108 * ‚±‚±‚Å—Dæ“x‚̍‚‚¢Š„ž‚Ý‚ðŽó‚¯•t‚¯‚éD
109 */
110 i_unlock_cpu();
111 i_lock_cpu();
112}
113
114#endif /* TOPPERS_waitmo */
115#ifdef TOPPERS_waitmook
116
117void
118wait_tmout_ok(TCB *p_tcb)
119{
120 p_tcb->p_winfo->wercd = E_OK;
121 if (make_non_wait(p_tcb)) {
122 reqflg = true;
123 }
124
125 /*
126 * ‚±‚±‚Å—Dæ“x‚̍‚‚¢Š„ž‚Ý‚ðŽó‚¯•t‚¯‚éD
127 */
128 i_unlock_cpu();
129 i_lock_cpu();
130}
131
132#endif /* TOPPERS_waitmook */
133
134/*
135 * ‘Ò‚¿ó‘Ô‚Ì‹­§‰ðœ
136 */
137#ifdef TOPPERS_wairel
138
139bool_t
140wait_release(TCB *p_tcb)
141{
142 wait_dequeue_wobj(p_tcb);
143 wait_dequeue_tmevtb(p_tcb);
144 p_tcb->p_winfo->wercd = E_RLWAI;
145 return(make_non_wait(p_tcb));
146}
147
148#endif /* TOPPERS_wairel */
149
150/*
151 * ŽÀs’†‚̃^ƒXƒN‚Ì“¯ŠúE’ʐMƒIƒuƒWƒFƒNƒg‚Ì‘Ò‚¿ƒLƒ…
152[‚Ö‚Ì‘}“ü
153 *
154 * ŽÀs’†‚̃^ƒXƒN‚ðC“¯ŠúE’ʐMƒIƒuƒWƒFƒNƒg‚Ì‘Ò‚¿ƒLƒ…
155[‚Ö‘}“ü‚·‚éDƒI
156 * ƒuƒWƒFƒNƒg‚Ì‘®«‚ɉž‚¶‚āCFIFO‡‚Ü‚½‚̓^ƒXƒN—Dæ“x‡‚Å‘}“ü‚·‚éD
157 */
158Inline void
159wobj_queue_insert(WOBJCB *p_wobjcb)
160{
161 if ((p_wobjcb->p_wobjinib->wobjatr & TA_TPRI) != 0U) {
162 queue_insert_tpri(&(p_wobjcb->wait_queue), p_runtsk);
163 }
164 else {
165 queue_insert_prev(&(p_wobjcb->wait_queue), &(p_runtsk->task_queue));
166 }
167}
168
169/*
170 * “¯ŠúE’ʐMƒIƒuƒWƒFƒNƒg‚ɑ΂·‚é‘Ò‚¿ó‘Ô‚Ö‚Ì‘JˆÚ
171 */
172#ifdef TOPPERS_wobjwai
173
174void
175wobj_make_wait(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj)
176{
177 make_wait(&(p_winfo_wobj->winfo));
178 wobj_queue_insert(p_wobjcb);
179 p_winfo_wobj->p_wobjcb = p_wobjcb;
180 LOG_TSKSTAT(p_runtsk);
181}
182
183#endif /* TOPPERS_wobjwai */
184#ifdef TOPPERS_wobjwaitmo
185
186void
187wobj_make_wait_tmout(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj,
188 TMEVTB *p_tmevtb, TMO tmout)
189{
190 make_wait_tmout(&(p_winfo_wobj->winfo), p_tmevtb, tmout);
191 wobj_queue_insert(p_wobjcb);
192 p_winfo_wobj->p_wobjcb = p_wobjcb;
193 LOG_TSKSTAT(p_runtsk);
194}
195
196#endif /* TOPPERS_wobjwaitmo */
197
198/*
199 * ‘Ò‚¿ƒLƒ…
200[‚̏‰Šú‰»
201 */
202#ifdef TOPPERS_iniwque
203
204bool_t
205init_wait_queue(QUEUE *p_wait_queue)
206{
207 TCB *p_tcb;
208 bool_t dspreq = false;
209
210 while (!queue_empty(p_wait_queue)) {
211 p_tcb = (TCB *) queue_delete_next(p_wait_queue);
212 wait_dequeue_tmevtb(p_tcb);
213 p_tcb->p_winfo->wercd = E_DLT;
214 if (make_non_wait(p_tcb)) {
215 dspreq = true;
216 }
217 }
218 return(dspreq);
219}
220
221#endif /* TOPPERS_iniwque */
Note: See TracBrowser for help on using the repository browser.