Problem 5. This problem deals with the semantics of Unix I/O. a. Suppose a process calls open with flags 0_WRONLY|0_CREAT and then forks. The child process writes "foo". The parent writes "bar". Both processes then close the file. What will be the final contents of the file? Is the answer nondeterministic, or will it be the same every time? b. Suppose two separate processes concurrently open an existing file for writing with flags 0_APPEND|0_WRONLY The initial content of the file is "XXX". Process A writes the 10 bytes "AAAAAAAAAA", while Process B writes the 10 bytes "BBBBBBBBBB". Assume the two write system calls occur very close to each other-that is, their machine instructions are interleaved at the lowest level. What will be the results? c. Suppose a process calls open on a file with flags 0_RDONLY and then forks. The file contains the ASCII string “ABCDEFGHIJK". The child process reads 5 bytes into a buffer, calls sleep (5), then exits. The parent process calls sleep (4) and then reads 5 bytes into a buffer. What does the parent's read () call put in the buffer? Is the answer the same every time? d. What can you say, if anything, about where the kernel stores the read and write pointers for a file that is opened by more than one process? In particular, are they kept in the per-process open file table, or the system-wide open file table? Or neither?
Problem 5. This problem deals with the semantics of Unix I/O. a. Suppose a process calls open with flags 0_WRONLY|0_CREAT and then forks. The child process writes "foo". The parent writes "bar". Both processes then close the file. What will be the final contents of the file? Is the answer nondeterministic, or will it be the same every time? b. Suppose two separate processes concurrently open an existing file for writing with flags 0_APPEND|0_WRONLY The initial content of the file is "XXX". Process A writes the 10 bytes "AAAAAAAAAA", while Process B writes the 10 bytes "BBBBBBBBBB". Assume the two write system calls occur very close to each other-that is, their machine instructions are interleaved at the lowest level. What will be the results? c. Suppose a process calls open on a file with flags 0_RDONLY and then forks. The file contains the ASCII string “ABCDEFGHIJK". The child process reads 5 bytes into a buffer, calls sleep (5), then exits. The parent process calls sleep (4) and then reads 5 bytes into a buffer. What does the parent's read () call put in the buffer? Is the answer the same every time? d. What can you say, if anything, about where the kernel stores the read and write pointers for a file that is opened by more than one process? In particular, are they kept in the per-process open file table, or the system-wide open file table? Or neither?
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
It's urgent
![Problem 5. This problem deals with the semantics of Unix I/O.
a. Suppose a process calls open with flags 0_WRONLY|0_CREAT and then forks. The child process
writes "foo". The parent writes "bar". Both processes then close the file. What will be the
final contents of the file? Is the answer nondeterministic, or will it be the same every time?
b. Suppose two separate processes concurrently open an existing file for writing with flags 0_APPEND|0_WRONLY
The initial content of the file is "XXX". Process A writes the 10 bytes "AAAAAAAAAA",
while Process B writes the 10 bytes "BBBBBBBBBB". Assume the two write system calls
occur very close to each other-that is, their machine instructions are interleaved at the lowest
level. What will be the results?
c. Suppose a process calls open on a file with flags 0_RDONLY and then forks. The file contains the
ASCII string "ABCDEFGHIJK". The child process reads 5 bytes into a buffer, calls sleep (5),
then exits. The parent process calls sleep(4) and then reads 5 bytes into a buffer. What
does the parent's read () call put in the buffer? Is the answer the same every time?
d. What can you say, if anything, about where the kernel stores the read and write pointers for
a file that is opened by more than one process? In particular, are they kept in the per-process
open file table, or the system-wide open file table? Or neither?](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8b8e71d2-7174-4547-8e64-2a015c00ea4a%2F437538eb-3278-494e-a3a6-4bb9c6146202%2Foppq1ye_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Problem 5. This problem deals with the semantics of Unix I/O.
a. Suppose a process calls open with flags 0_WRONLY|0_CREAT and then forks. The child process
writes "foo". The parent writes "bar". Both processes then close the file. What will be the
final contents of the file? Is the answer nondeterministic, or will it be the same every time?
b. Suppose two separate processes concurrently open an existing file for writing with flags 0_APPEND|0_WRONLY
The initial content of the file is "XXX". Process A writes the 10 bytes "AAAAAAAAAA",
while Process B writes the 10 bytes "BBBBBBBBBB". Assume the two write system calls
occur very close to each other-that is, their machine instructions are interleaved at the lowest
level. What will be the results?
c. Suppose a process calls open on a file with flags 0_RDONLY and then forks. The file contains the
ASCII string "ABCDEFGHIJK". The child process reads 5 bytes into a buffer, calls sleep (5),
then exits. The parent process calls sleep(4) and then reads 5 bytes into a buffer. What
does the parent's read () call put in the buffer? Is the answer the same every time?
d. What can you say, if anything, about where the kernel stores the read and write pointers for
a file that is opened by more than one process? In particular, are they kept in the per-process
open file table, or the system-wide open file table? Or neither?
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY