Question: Q1) Suppose you have the following code segment: char c int fd 1 open ( hm3 . txt, _RDONLY); int fd2 int fd3 open (hw3.txt,
Q1) Suppose you have the following code segment: char c int fd 1 open ( "hm3 . txt", _RDONLY); int fd2 int fd3 open ("hw3.txt", O RDONLY) read (fd1, &c, 1) read (fd3, &c, 1) fd2 dup (fdl); read(fdl, &c, 1) read (fd2, &c, 1); int pid fork(O if (pid 0) read (fd3, &c, 1); dup2 (fd2, fd3) close (fd1); read (fd3, &c, 1)i fd1open ("hw3.txt", o RDONLY) read (fd1, &c,1) ) else ( wait (NULL) read (fd3, &c, 1) read (fd1, &c, 1) Assume the file position starts with zero and the file "hw3.txt" includes: "ABCDEFGHIJKLMNOPORSTUVWXYZ" a. Draw the kernel data structures for each file and show the changes after each file operation (open, read, dup) Verify your answers with gdb. Show the commands used and variable values (fds and c) in the report. b. Q1) Suppose you have the following code segment: char c int fd 1 open ( "hm3 . txt", _RDONLY); int fd2 int fd3 open ("hw3.txt", O RDONLY) read (fd1, &c, 1) read (fd3, &c, 1) fd2 dup (fdl); read(fdl, &c, 1) read (fd2, &c, 1); int pid fork(O if (pid 0) read (fd3, &c, 1); dup2 (fd2, fd3) close (fd1); read (fd3, &c, 1)i fd1open ("hw3.txt", o RDONLY) read (fd1, &c,1) ) else ( wait (NULL) read (fd3, &c, 1) read (fd1, &c, 1) Assume the file position starts with zero and the file "hw3.txt" includes: "ABCDEFGHIJKLMNOPORSTUVWXYZ" a. Draw the kernel data structures for each file and show the changes after each file operation (open, read, dup) Verify your answers with gdb. Show the commands used and variable values (fds and c) in the report. b
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
