Mercurial > hg > Members > menikon > CbC_xv6
changeset 37:fb3e5a2f76c1
fix
author | mir3636 |
---|---|
date | Fri, 22 Feb 2019 22:36:17 +0900 |
parents | d4e5846ddb48 |
children | 0a442b2df864 |
files | src/defs.h src/pipe.c src/proc.c src/proc.h src/spinlock.c |
diffstat | 5 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/defs.h Fri Feb 22 22:15:33 2019 +0900 +++ b/src/defs.h Fri Feb 22 22:36:17 2019 +0900 @@ -121,6 +121,7 @@ int pipealloc(struct file**, struct file**); void pipeclose(struct pipe*, int); int piperead(struct pipe*, char*, int); +__code cbc_piperead(struct pipe*, char*, int, __code (*)(int)); int pipewrite(struct pipe*, char*, int); //PAGEBREAK: 16 @@ -138,6 +139,7 @@ void sleep(void*, struct spinlock*); void userinit(void); int wait(void); +__code cbc_wakeup(void*, __code(*next1)()); void wakeup(void*); void yield(void);
--- a/src/pipe.c Fri Feb 22 22:15:33 2019 +0900 +++ b/src/pipe.c Fri Feb 22 22:36:17 2019 +0900 @@ -119,6 +119,7 @@ __code cbc_piperead3(){ struct pipe *p = proc->cbc_arg.cbc_console_arg.p; int i = proc->cbc_arg.cbc_console_arg.i; + __code(*next)(int ret) = proc->cbc_arg.cbc_console_arg.next; release(&p->lock); goto next(i); @@ -129,10 +130,7 @@ int n = proc->cbc_arg.cbc_console_arg.n; struct pipe *p = proc->cbc_arg.cbc_console_arg.p; char *addr = proc->cbc_arg.cbc_console_arg.addr; - if (i < n) { - if(p->nread == p->nwrite) { - break; - } + if (i < n && !(p->nread == p->nwrite)) { addr[i] = p->data[p->nread++ % PIPESIZE]; i ++; proc->cbc_arg.cbc_console_arg.i = i; @@ -146,6 +144,7 @@ __code cbc_piperead1(){ struct pipe *p = proc->cbc_arg.cbc_console_arg.p; + __code(*next)(int ret) = proc->cbc_arg.cbc_console_arg.next; if (p->nread == p->nwrite && p->writeopen){ if(proc->killed){ release(&p->lock); @@ -166,6 +165,7 @@ proc->cbc_arg.cbc_console_arg.n = n; proc->cbc_arg.cbc_console_arg.p = p; proc->cbc_arg.cbc_console_arg.addr = addr; + proc->cbc_arg.cbc_console_arg.next = next; goto cbc_piperead1(); }
--- a/src/proc.c Fri Feb 22 22:15:33 2019 +0900 +++ b/src/proc.c Fri Feb 22 22:36:17 2019 +0900 @@ -539,12 +539,13 @@ } release(&ptable.lock); - goto next(); + goto proc->cbc_next(); } -__code cbc_wakeup(void *chan) +__code cbc_wakeup(void *chan, __code(*next1)()) { acquire(&ptable.lock); + proc->cbc_next = next1; cbc_wakeup1(chan); }
--- a/src/proc.h Fri Feb 22 22:15:33 2019 +0900 +++ b/src/proc.h Fri Feb 22 22:36:17 2019 +0900 @@ -70,12 +70,15 @@ char name[16]; // Process name (debugging) union cbc_arg { struct cbc_console_arg { - int n; + int n; int target; char* dst; struct inode *ip; struct file *f; int num; + struct pipe *p; + char *addr; + int i; __code (*next)(int ret); } cbc_console_arg; } cbc_arg;
--- a/src/spinlock.c Fri Feb 22 22:15:33 2019 +0900 +++ b/src/spinlock.c Fri Feb 22 22:36:17 2019 +0900 @@ -46,6 +46,7 @@ #endif } +/* void cbc_acquire(struct spinlock *lk, __code (*next)(int ret)) { pushcli(); // disable interrupts to avoid deadlock. @@ -68,7 +69,9 @@ #endif goto next(); } +*/ +/* // Release the lock. void cbc_release(struct spinlock *lk, __code (*next)(int ret)) { @@ -95,6 +98,7 @@ popcli(); goto next(); } +*/ void release(struct spinlock *lk) {