Mercurial > hg > Members > tobaru > CbC_xv6
comparison src/console.c @ 29:a672d603ccb2
fix
author | mir3636 |
---|---|
date | Fri, 18 Jan 2019 10:04:37 +0900 |
parents | 1a64b5645cdd |
children | 6a7ab1d7001c |
comparison
equal
deleted
inserted
replaced
28:68de775c3a29 | 29:a672d603ccb2 |
---|---|
213 } | 213 } |
214 | 214 |
215 release(&input.lock); | 215 release(&input.lock); |
216 } | 216 } |
217 | 217 |
218 __code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret)) | |
219 { | |
220 uint target; | |
221 | |
222 iunlock(ip); | |
223 | |
224 target = n; | |
225 acquire(&input.lock); | |
226 | |
227 while (n > 0) { | |
228 while (input.r == input.w) { | |
229 if (proc->killed) { | |
230 release(&input.lock); | |
231 ilock(ip); | |
232 goto next(-1); | |
233 } | |
234 | |
235 proc->cbc_arg.cbc_console_arg.n = n; | |
236 proc->cbc_arg.cbc_console_arg.target = target; | |
237 proc->cbc_arg.cbc_console_arg.dst = dst; | |
238 proc->cbc_arg.cbc_console_arg.ip = ip; | |
239 proc->cbc_arg.cbc_console_arg.next = next; | |
240 goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1); | |
241 } | |
242 } | |
243 } | |
244 | |
245 __code cbc_consoleread1 (__code(*next)(int ret)) | 218 __code cbc_consoleread1 (__code(*next)(int ret)) |
246 { | 219 { |
247 int cont = 1; | 220 int cont = 1; |
248 int n = proc->cbc_arg.cbc_console_arg.n; | 221 int n = proc->cbc_arg.cbc_console_arg.n; |
249 int target = proc->cbc_arg.cbc_console_arg.target; | 222 int target = proc->cbc_arg.cbc_console_arg.target; |
281 ilock(ip); | 254 ilock(ip); |
282 | 255 |
283 goto next(target - n); | 256 goto next(target - n); |
284 } | 257 } |
285 | 258 |
259 __code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret)) | |
260 { | |
261 uint target; | |
262 | |
263 iunlock(ip); | |
264 | |
265 target = n; | |
266 acquire(&input.lock); | |
267 | |
268 while (n > 0) { | |
269 while (input.r == input.w) { | |
270 if (proc->killed) { | |
271 release(&input.lock); | |
272 ilock(ip); | |
273 goto next(-1); | |
274 } | |
275 | |
276 proc->cbc_arg.cbc_console_arg.n = n; | |
277 proc->cbc_arg.cbc_console_arg.target = target; | |
278 proc->cbc_arg.cbc_console_arg.dst = dst; | |
279 proc->cbc_arg.cbc_console_arg.ip = ip; | |
280 proc->cbc_arg.cbc_console_arg.next = next; | |
281 goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1); | |
282 } | |
283 } | |
284 } | |
285 | |
286 int consoleread (struct inode *ip, char *dst, int n) | 286 int consoleread (struct inode *ip, char *dst, int n) |
287 { | 287 { |
288 uint target; | 288 uint target; |
289 int c; | 289 int c; |
290 | 290 |