Mercurial > hg > Members > tobaru > CbC_xv6
changeset 145:6c81e02e323f
impl_piperead.cbc
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Dec 2019 13:57:57 +0900 |
parents | eef045e9772a |
children | fd166dda4361 |
files | src/impl/PipeRead.cbc |
diffstat | 1 files changed, 30 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/PipeRead.cbc Sun Dec 15 13:43:23 2019 +0900 +++ b/src/impl/PipeRead.cbc Sun Dec 15 13:57:57 2019 +0900 @@ -26,7 +26,7 @@ pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; - pipe_read->next = C_nextPipeRead; + //pipe_read->next = C_nextPipeRead; sys_read->read = C_readPipeRead; sys_read->next = C_nextPipeRead; return sys_read; @@ -36,34 +36,49 @@ struct SysRead* sys_read = new SysRead(); struct PipeRead* pipe_read = new PipeRead(); sys_read->sys_read = (union Data*)pipe_read; + pipe_read->p = p; - pipe_read->i = 0; - pipe_read->n = n; + pipe_read->i = 0; + pipe_read->n = n; + sys_read->impl = (union Data*)p; sys_read->addr = addr; - sys_read->n = n; + sys_read->n = n; + + pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; + pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; + pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; + //pipe_read->next = C_nextPipeRead; + sys_read->read = C_readPipeRead; sys_read->next = C_nextPipeRead; return sys_read; } -__code cbc_piperead1PipeRead(struct PipeRead* sys_read, struct pipe* p, __code next(...)) { - - goto next(...); +__code cbc_piperead1PipeRead(struct PipeRead* sys_read, struct pipe* p, __code error(int err), __code next(int i, p,...)) { + if (p->nread == p->nwrite && p->writeopen){ + if(proc->killed){ + release(&p->lock); + goto error(-1); + } + goto cbc_sleep(&p->nread, &p->lock, cbc_piperead1); + } + goto next(i,p,...); } -__code cbc_piperead2PipeRead(struct PipeRead* sys_read, int i, int n, struct pipe* p, __code next(...)) { - +__code cbc_piperead2PipeRead(struct PipeRead* sys_read, int i, int n, struct pipe* p,char* addr, __code next(...)) { + if (i < n && !(p->nread == p->nwrite)) { + addr[i] = p->data[p->nread++ % PIPESIZE]; + i++; + goto sys_read->cbc_piperead2(i,n,p,addr,cbc_wakeup); + } + goto cbc_wakeup(&p->nwrite, cbc_piperead3); //DOC: piperead-wakeup goto next(...); } __code cbc_piperead3PipeRead(struct PipeRead* sys_read, int i, struct pipe* p, __code next(...)) { - - goto next(...); -} - -__code nextPipeRead(...) { - + release(&p->lock); + goto sys_read->ret(i,...); } __code readPipeRead(struct PipeRead* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)) { @@ -71,7 +86,4 @@ goto next(int ret,...); } -__code nextPipeRead(...) { -} -