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 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 24.06.2019 00:50
Which player type acts on other players? a. killer b. achiever c. explorer d. socializer
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
How to apply the fly in effect to objects on a slide
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
Create a class hand in its own module. one object of class hand represents a hand of cards and so one object stores a number of card objects. for this assignment you will submit three separate modules, one with the definition of class card, one with the definition of class hand and one with the main application that thoroughly tests class hand.class hand must contain the following four methods: 1) , numcardsinhand) takes an integer as parameter and initializes a hand object with numcardsinhand card objects inside it. these card objects are generated randomly. for simplicity, assume an infinite number of decks of cards.2) bjvalue(self) returns the blackjack value for the whole hand of cards3) ) returns a string containing all the cards in the hand4) hitme(self) adds one randomly generated card to the handcreate a main program in its own module that thoroughly tests class hand. you will have three modules/files to upload to your etudes assignment submission: card.py, hand.py and the module that contains your main program.two alternatives for extra credit - you cannot get credit for both! (+1 point): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a pickle file and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.or(+2 points): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a text file on the disk and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.notes: -start by making any and all modifications suggested by my comments to your previous submission of class card from assignment #6 "a robust card object"-once your class card is tested and working well, you will not make any further modifications to it for the purposes of class hand.-you can keep the test code for class card intact. if it is indented inside an if __name__ == "__main__", then it will not be executed when your main program's module imports it.-to save time, write and test one method for class hand at a time.-under no circumstances are you to attempt the extra credit until you are completely finished with writing and testing all the methods in class hand.
Answers: 3
You know the right answer?
You are given the following C code, running under Unix operating system, assuming the following:
Questions
question
Mathematics, 28.01.2021 16:40
question
Social Studies, 28.01.2021 16:40
question
Mathematics, 28.01.2021 16:40
question
Physics, 28.01.2021 16:40
question
Mathematics, 28.01.2021 16:40
question
Mathematics, 28.01.2021 16:40
Questions on the website: 13722361