Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this problem you are requested to expand the previous problem so that the processes can be handled via the use of signals, in order
In this problem you are requested to expand the previous problem so that the processes can be handled via the use of signals, in order to print their messages in a depth-first fashion. Every process creates its own children-processes and suspends its execution until it receives the appropriate resume signal (SIGCONT). When the process receives SIGCONT it prints the corresponding message and activates its child processes one after another. It monitors and waits for their terminations and prints the corresponding diagnostics. The process evolves recursively, starting from the root process. The initial process of the program sends SIGCONT to the root process, after displaying the process tree to the user. In the example of scheme 1, the activation messages are printed in order: A, B, D, C Remarks: A process suspends its execution with the use of sys call: raise (SIGSTOP). But before it does so, it validates that all the children have suspended their execution as well. This validation is conducted by means of a function named: wait for_children(). To build the latter you may use function explain_wait_status () following sys call wait) or waitpid(). During your program execution you may try to send manual messages via the use of instruction kill from another window. You may use the command: strace -f -p to monitor the system calls coming from process and all its children processes. Questions 1. We have used sleep() in the previous parts to synchronize processes. What is the What can be the role of your function wait_for_children()? What benefit does it ensure and what potential problem could its omission bring about? 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started