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, 22.06.2019 12:50
You have just been hired as an information security engineer for a large, multi-international corporation. unfortunately, your company has suffered multiple security breaches that have threatened customers' trust in the fact that their confidential data and financial assets are private and secured. credit-card information was compromised by an attack that infiltrated the network through a vulnerable wireless connection within the organization. the other breach was an inside job where personal data was stolen because of weak access-control policies within the organization that allowed an unauthorized individual access to valuable data. your job is to develop a risk-management policy that addresses the two security breaches and how to mitigate these risks.requirementswrite a brief description of the case study. it requires two to three pages, based upon the apa style of writing. use transition words; a thesis statement; an introduction, body, and conclusion; and a reference page with at least two references. use a double-spaced, arial font, size 12.
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
The fourth generation of computers emerged between 1970s and 1980s. which technological advancement brought about this generation of computers? which computer architecture was used most in this generation?
Answers: 3
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, 24.06.2019 15:30
What is the function of compilers and interpreters? how does a compiler differ from an interpreter?
Answers: 2
You know the right answer?
You are given the following C code, running under Unix operating system, assuming the following:
Questions
question
Chemistry, 05.05.2020 07:48
question
Mathematics, 05.05.2020 07:48
question
Biology, 05.05.2020 07:48
question
History, 05.05.2020 07:48