Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) Suppose you have the following code segment: char c int fd 1 open ( hm3 . txt, _RDONLY); int fd2 int fd3 open (hw3.txt,

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions