Question 1For each procedure/system call below, write the letter of the choice to the right that best describes how the procedure/system call returns to its caller.
|
|
Part A: Explain exactly what the system call pipe()
does. Include the syntax.
Part B: Explain exactly what the system call dup() does. Include the syntax. Part C: Explain exactly what the procedure pthread_mutex_lock() does. Part D. Is the following piece of code going to cause a segmentation violation? Explain your answer in detail, including where in the code the segmentation violation occurs if indeed it does occur. { char *s; /* Line 1 */ s = sbrk(0); /* Line 2 */ *s[1] = 0; /* Line 3 */ } |
Part E: Write a shell command using only the programs
cat,
head,
ls,
sort,
tail or
grep,
where one of the processes forked off
dies because it catches SIGPIPE. For example, here is a command
where the processes all die normally:
In you answer, state which process dies by catching SIGPIPE, and why it does so. You may assume that there are two text files in your current directory: f1, which is 30 lines, or f2, which is 1,000,000. Note you can answer the question without using either of these files. You can also specify, it you'd like, that the user must type into the keyboard. |