subject

You are given the following C code, running under Unix operating system, assuming the following:
(1) system calls never fail; (2) the function Fn() never returns; (3) the function Fn() does not contain any system calls; (4) whenever a process is created, it inherits exactly the same signal handlers as its parent; and (5) system calls cannot be interrupted. Since Fn() never returns, all processes that are created with the following code reach a steady state. This means that the process tree stays the same forever and each process executes a specific function or system call.

void handler (int signum)
{
Fn(0, -1);
}
int main(void)
{
int i, p[2], writefd [4];
pid_t pid [4];
signal (SIGUSR1, handler);
for (i = 0; i < 4; i++) {
pipe (p);
pid[i] = fork();
if (pid[i] == 0) {
close (p [1]);
read (p [0], &pid[i], sizeof(pid_t));
if (pid[i] > 0) kill (pid[i], SIGUSR1);
Fn(i, pid[i]);
}
close (p [0]);
writefd[i] = p [1];
}
write (writefd [1], &pid [0], sizeof(pid_t));
close (writeid [3]);
wait (NULL);
write (writefd [2], &pid [1], sizeof (pid_t));
Fn(-1, -2);
return 0;
}

1. Answer the following questions:
(a) Describe the functionality of the pipe() system call in Unix. How many and what type of values does it return to the program that uses it?
(b) When does a process turn into a zombie process and how does this process eventually leave the system?
(c) What happens when a process calls read() in an empty pipe while the write edge is open?
(d) What happens when a process calls read() in an empty pipe while the write edge is closed?
(e) What do the system calls getpid() and getppid() do in Unix? Can the return values of each of these system calls change throughout the execution of the same process?
2. Regarding the steady-state of the created processes, draw a process tree that shows how processes are connected. Briefly describe it.
3. For each node (process) of that tree, mention:
(a) the system call or the function that this node (process) executes, and
(b) the arguments with which that system call or function was called. Regarding the arguments you can make assumptions for the values you do not know (e. g., PIDs assigned to new processes).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 12:30
Amanager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breaching data integrity. which technology would the manager look into the activities of the team member? technology would be useful to look into the activities of the team member.
Answers: 3
question
Computers and Technology, 21.06.2019 19:30
Can you make money in why are you guys so
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
What does the faves button do? a. users mark a web page as a favorite b. leads other readers to favor a specific page c. readers sort and align their favicons, or favorite icons d. leads users to a message board where they can post questions
Answers: 1
You know the right answer?
You are given the following C code, running under Unix operating system, assuming the following:
Questions
question
Mathematics, 04.08.2019 11:30
Questions on the website: 13722361