[关闭]
@Radon 2015-01-05T17:08:59.000000Z 字数 1143 阅读 1660

Homework 14 & 15

1100012749


Homework 14

9.11

A. 0 0 0 0 1 0 0 1 1 1 1 1 0 0

B.

Parameter Value
VPN 0X09
TLB index 0x1
TLB tag 0x02
TLB hit? N
Page fault? N
PPN 0x17

C.
0 1 0 1 1 1 1 1 1 1 0 0

D.

Parameter Value
Byte offset 0x0
Cache index 0xf
Cache tag 0x17
Cache hit? N
Cache byte returned -

9.12

A. 0 0 0 0 1 1 1 0 1 0 1 0 0 1

B.

Parameter Value
VPN 0x0e
TLB index 0x2
TLB tag 0x03
TLB hit? N
Page fault? N
PPN 0x11

C. 0 1 0 0 0 1 1 0 1 0 0 1

D.

Parameter Value
Byte offset 0x1
Cache index 0xa
Cache tag 0x11
Cache hit? N
Cache byte returned -

9.13

A. 0 0 0 0 0 0 0 1 0 0 0 0 0 0

B.

Parameter Value
VPN 0x01
TLB index 0x1
TLB tag 0x00
TLB hit? N
Page fault? Y
PPN -

C. -

D. -

9.14

  1. #include <fcntl.h>
  2. #include <sys/mman.h>
  3. #include <unistd.h>
  4. int main()
  5. {
  6. int fd;
  7. char *map_addr;
  8. fd = open("hello.txt", O_RDWR, NULL);
  9. map_addr = (char *) mmap(NULL, 1, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  10. close(fd);
  11. if (map_addr == MAP_FAILED) return -1;
  12. *map_addr = 'J';
  13. munmap(map_addr, 1);
  14. return 0;
  15. }

Homework 15

10.6

fd2 = 4

10.7

  1. int main(int argc, char **argv) {
  2. int n;
  3. rio_t rio;
  4. char buf[MAXBUF];
  5. Rio_readinitb(&rio, STDIN_FILENO);
  6. while ((n = Rio_readnb(rio, buf, MAXBUF)) != 0) {
  7. Rio_write(STDOUT_FILENO, buf, n);
  8. }
  9. return 0;
  10. }

10.9

  1. if (fork() == 0) {
  2. int fd = open("foo.txt", O_RDONLY, 0);
  3. dup2(fd, STDIN_FILENO);
  4. clode(fd);
  5. execve("fstatcheck", argv, envp);
  6. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注