# HG changeset patch # User anatofuz # Date 1579157567 -32400 # Node ID a70c436936e43153e983e673da35b92e392caf38 # Parent 21e83548d7381592d39bde3ee67cb7bce31c32a5 impl cbc_sleep diff -r 21e83548d738 -r a70c436936e4 src/impl/file_impl_pipe.cbc --- 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(...);