function viewuser( address, length, startpage ) numpages := pagenum(address+length-1) - pagenum(address) + 1; for i := 0 to numpages-1 do map[system][startpage+i] = map[user][page(address)+i]; return makeaddr(startpage,offset(address));
The problem, part B: After a system call, the first parameter on the stack top is the address of a buffer and the second parameter on the stack top is the length of the buffer. Write code using the viewuser function to map the user's buffer into the system's address space and return a pointer to it.
userstack := viewuser( usersp, (usersp-userfp)+1, systop ); bufpointaddr := userstack + (usersp-userfp)-1; buflenaddr := userstack + (usersp-userfp)-2; bufpoint := bufpointaddr^; buflen := buflenaddr^; bufferaddr := viewuser( bufpoint, buflen, systop );
Jones C-list grades rw ----------->file /export rw ----------->C-list<---------------. handout rw -----. handout r --->file \ /bin r ---. `------------------' | /public r -. \ | \ \ | Smith C-list | | | homework rw ---+--+---->file | /export rw ---+--+---->C-list<-------------. | project rw ---+--+-. project r --->file \ | /bin r ---+. | `---------------' | | /bin r -. | \| | | \| \ | | Root C-list | \ | | /bin rw ---+------->C-list | | ls rx ---+----. ls r ---->file | | cat rx ---+--. \ cat r -./ | | /public rw -. | \ `----------'\ | | \| `--------------->file / / `------->C-list / / smith r ---------' / jones r ----------'