Mercurial > hg > Members > menikon > CbC_xv6
changeset 188:9d385a07dbfc
aligned API at pipe close...
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Jan 2020 15:30:43 +0900 |
parents | 312f86884606 |
children | 648247c08bbd 64a1b9b8f08e |
files | src/impl/file_impl_pipe.cbc src/impl/pipe.h |
diffstat | 2 files changed, 39 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/file_impl_pipe.cbc Tue Jan 21 15:12:05 2020 +0900 +++ b/src/impl/file_impl_pipe.cbc Tue Jan 21 15:30:43 2020 +0900 @@ -4,12 +4,27 @@ // ---- // typedef struct pipe<Impl, Isa> impl file { // #define PIPESIZE 512 +// union Data* file; // struct spinlock lock; // char data[PIPESIZE]; // uint nread; // number of bytes read // uint nwrite; // number of bytes written // int readopen; // read fd is still open // int writeopen; // write fd is still open +// +// // interface field +// int n; +// char* addr; +// +// // private code gear +// __code piperead1(Impl* pipe, char* addr, int n, __code next(...)); +// __code piperead2(Impl* pipe, char* addr, int n, __code next(...)); +// __code cbc_pipeclose(Impl* pipe, Isa* file, __code next(...)); +// __code cbc_pipeclose2(Impl* pipe, Isa* file, Isa* ff, __code next(...)); +// __code cbc_pipeclose3(Impl* pipe, Isa* file, Isa* ff, __code next(...)); +// __code cbc_pipeclose4(Impl* pipe, int writable, __code next(...)); +// __code cbc_pipe_close_writeopen(Impl* pipe, __code next(...)); +// __code cbc_pipe_close_readopen(Impl* pipe, __code next(...)); // } pipe; // ---- @@ -17,7 +32,7 @@ struct file* file = new file(); struct pipe* pipe = new pipe(); file->file = (union Data*)pipe; - pipe->file = (union Data*)file; //pipe -> file + pipe->file = NULL; pipe->lock = 0; pipe->spinlock = 0; pipe->data = 0; @@ -37,10 +52,10 @@ file->fd = 0; pipe->piperead1 = C_piperead1pipe; pipe->piperead2 = C_piperead2pipe; - pipe->cbc_fileclose = C_cbc_fileclosepipe; - pipe->cbc_fileclose2 = C_cbc_fileclose2pipe; - pipe->cbc_fileclose3 = C_cbc_fileclose3pipe; - pipe->cbc_pipe_close = C_cbc_pipe_closepipe; + pipe->cbc_pipeclose = C_cbc_pipeclosepipe; + pipe->cbc_pipeclose2 = C_cbc_pipeclose2pipe; + pipe->cbc_pipeclose3 = C_cbc_pipeclose3pipe; + pipe->cbc_pipeclose4 = C_cbc_pipeclose4pipe; pipe->cbc_pipe_close_writeopen = C_cbc_pipe_close_writeopenpipe; pipe->cbc_pipe_close_readopen = C_cbc_pipe_close_readopenpipe; file->stat = C_statpipe; @@ -134,26 +149,28 @@ f->ref = 0; f->type = FD_NONE; relsease(&ftable.lock); + struct pipe* p = ff.pipe; + int writable = ff.writable; - goto pipe->cbc_pipeclose4(ff.pipe,ff.writable,next); + goto pipe->cbc_pipeclose4(p,writable,next); } -__code cbc_pipeclose4(struct pipe* p, int writable, __code next(...)) { - acquire(&p->lock); +__code cbc_pipeclose4(struct pipe* pipe, int writable, __code next(...)) { + acquire(&pipe->lock); if (writable) { - goto p->cbc_pipe_close_writeopen(next); + goto pipe->cbc_pipe_close_writeopen(next); } - goto p->cbc_pipe_close_readopen(next); + goto pipe->cbc_pipe_close_readopen(next); } -__code cbc_pipe_close_writeopen(struct pipe* p, __code next(...)) { - p->writeopen = 0; - goto cbc_wakeup(&p->nread,p,cbc_pipe_release,next); +__code cbc_pipe_close_writeopen(struct pipe* pipe, __code next(...)) { + pipe->writeopen = 0; + goto cbc_wakeup(&pipe->nread,pipe,cbc_pipe_release,next); } -__code cbc_pipe_close_readopen(struct pipe* p, __code next(...)) { - p->readopen = 0; - goto cbc_context->wakeup(&p->nwrite,p,cbc_pipe_release,next); +__code cbc_pipe_close_readopen(struct pipe* pipe, __code next(...)) { + pipe->readopen = 0; + goto cbc_context->wakeup(&pipe->nwrite,pipe,cbc_pipe_release,next); }
--- a/src/impl/pipe.h Tue Jan 21 15:12:05 2020 +0900 +++ b/src/impl/pipe.h Tue Jan 21 15:30:43 2020 +0900 @@ -15,10 +15,10 @@ // private code gear __code piperead1(Impl* pipe, char* addr, int n, __code next(...)); __code piperead2(Impl* pipe, char* addr, int n, __code next(...)); - __code cbc_fileclose(Impl* pipe, Isa* file, __code next(...)); - __code cbc_fileclose2(Impl* pipe, Isa* file,struct file* ff, __code next(...)); - __code cbc_fileclose3(Impl* pipe, Isa* file,struct file* ff, __code next(...)); - __code cbc_pipe_close(Impl* p, int writable, __code next(...)); - __code cbc_pipe_close_writeopen(Impl* p, __code next(...)); - __code cbc_pipe_close_readopen(Impl* p, __code next(...)); + __code cbc_pipeclose(Impl* pipe, Isa* file, __code next(...)); + __code cbc_pipeclose2(Impl* pipe, Isa* file, Isa* ff, __code next(...)); + __code cbc_pipeclose3(Impl* pipe, Isa* file, Isa* ff, __code next(...)); + __code cbc_pipeclose4(Impl* pipe, int writable, __code next(...)); + __code cbc_pipe_close_writeopen(Impl* pipe, __code next(...)); + __code cbc_pipe_close_readopen(Impl* pipe, __code next(...)); } pipe;