Mercurial > hg > Members > menikon > CbC_xv6
changeset 166:a70c436936e4
impl cbc_sleep
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Jan 2020 15:52:47 +0900 |
parents | 21e83548d738 |
children | 2a35e8c6f67c |
files | src/impl/file_impl_pipe.cbc |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/file_impl_pipe.cbc Wed Jan 15 19:56:28 2020 +0900 +++ b/src/impl/file_impl_pipe.cbc Thu Jan 16 15:52:47 2020 +0900 @@ -50,12 +50,35 @@ release(&p->lock); goto cbc_context->error(); } - goto cbc_sleep(p,&p->nread, &p->lock, cbc_piperead1); + goto cbc_sleep(p,&p->nread, &p->lock, next,cbc_piperead1); } n = 0; goto cbc_piperead2(p,n); } +__code cbc_sleep(struct pipe* p, unit* nread, struct spinlock* lock, __code next(...), __code pread(...)){ + if(proc == 0) { + goto cbc_context->panic("sleep"); + } + + if(lk == 0) { + goto cbc_context->panic("sleep without lk"); + } + + if(lk != &ptable.lock){ //DOC: sleeplock0 + acquire(&ptable.lock); //DOC: sleeplock1 + release(lk); + } + goto cbc_sched(cbc_sleep1); +} + +__code cbc_sched_stub(struct pipe* p, unit* nread, struct spinlock* lock, __code next(...), __code pread(...)){ + proc->chan = chan; + proc->state = SLEEPING; + proc->lk = lk; + proc->cbc_next = next1; +} + __code writepipe(struct pipe* file, char* addr, int n, __code next(...)) { goto next(...);