Mercurial > hg > Members > menikon > CbC_xv6
diff src/impl/file_impl_pipe.cbc @ 165:21e83548d738
def file_impl_pipe.cbc private code gears
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 15 Jan 2020 19:56:28 +0900 |
parents | 9c501dca25e3 |
children | a70c436936e4 |
line wrap: on
line diff
--- a/src/impl/file_impl_pipe.cbc Wed Jan 15 18:53:32 2020 +0900 +++ b/src/impl/file_impl_pipe.cbc Wed Jan 15 19:56:28 2020 +0900 @@ -39,9 +39,21 @@ goto next(...); } -__code readpipe(struct pipe* file, char* addr, __code next(...)) { +__code readpipe(struct pipe* file, char* addr, int n, __code next(...)) { + acquire(&p->lock); + goto cbc_piperead1(file,addr,n,next); +} - goto next(...); +__code piperead1(struct pipe* p, char* addr, int n, __code next(...)) { + if (p->nread == p->nwrite && p->writeopen){ + if(proc->killed){ + release(&p->lock); + goto cbc_context->error(); + } + goto cbc_sleep(p,&p->nread, &p->lock, cbc_piperead1); + } + n = 0; + goto cbc_piperead2(p,n); } __code writepipe(struct pipe* file, char* addr, int n, __code next(...)) {