Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

4. [20 points] Unix I/O and file operations [10 points] Suppose that the file tmpdata.txt contains abcdefghijk. If the following code is executed correctly without

image text in transcribed

4. [20 points] Unix I/O and file operations [10 points] Suppose that the file "tmpdata.txt" contains "abcdefghijk". If the following code is executed correctly without generating any errors. a. 1: int fd; 2: char buf [6]12345"; 3: fd-open ("tmpdata. txt", 0 RDONLY); 4: fork) 5: read (fd, buf, 2)i 6: read (fd, buf+2, 2); 7: printf ("%d: %s ", (long ) getpid ( ), buf); i). [5pt] Explain if the following two outputs are possible or not? Why/why not? Suppose parent's pid is 7 while child's pid is 8. 7:a2bc5 8:a2b45 7: a2c45 8:b2de5 ii. [5pt] What could be the outputs if the lines 3 and 4 are exchanged? Write at least 3 possible outputs. Suppose parent's pid is 7 while child's pid is 8. 4. [20 points] Unix I/O and file operations [10 points] Suppose that the file "tmpdata.txt" contains "abcdefghijk". If the following code is executed correctly without generating any errors. a. 1: int fd; 2: char buf [6]12345"; 3: fd-open ("tmpdata. txt", 0 RDONLY); 4: fork) 5: read (fd, buf, 2)i 6: read (fd, buf+2, 2); 7: printf ("%d: %s ", (long ) getpid ( ), buf); i). [5pt] Explain if the following two outputs are possible or not? Why/why not? Suppose parent's pid is 7 while child's pid is 8. 7:a2bc5 8:a2b45 7: a2c45 8:b2de5 ii. [5pt] What could be the outputs if the lines 3 and 4 are exchanged? Write at least 3 possible outputs. Suppose parent's pid is 7 while child's pid is 8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions