Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A. (4 pts) Pick the first 3 system calls included in the code below. Analyze how each affects the program: outline what happens if they
A. (4 pts) Pick the first 3 system calls included in the code below. Analyze how each affects the program: outline what happens if they are successful or unsuccessful. Hint: To describe the unsuccessful execution of an instruction Z you must assume that all preceding instructions have executed in such a way that your program reaches instruction/line Z. ANS: The fork() sys call creates a process if value <=8 The B. (8 pts) Assume now every sys call is SUCCESSFUL. You must make minor code modifications such as: 1) only change the sequence of existing sys calls, and/or 2) add conditional statements in front of the sys calls (like if, for, etc.) These modifications are made so that: Q1. (6 pts) Both printouts of Line C and Line E are executed. Then list all the possible printouts for your solution. List no more than the first 6 printouts you are getting in order (with detailed values of the variables involved). Does the program run indefinitely or not? Are the processes forked indefinite or not? Q2 (2 pts): What extra to Q1 must be done for the program to a) terminate in the case that it does not, or b) run indefinitely in the case that it does not? C. (6 pts) Under what circumstances are your answers to the questions in part B same or different if we execute Line B before Line A? Answer again: Q1, Q2, exactly as they are phrased in part B. D. (6 pts) Use variable x to insert a simple instruction in Line H in order to ensure that your program terminates under ANY circumstances with the assumptions of Part B. Will your instruction work the same way if we execute Line B before Line A? Or do we need to make further assumptions/scenarios? E. (6 pts) If in Line H x is to add number 3 to variable value, will the program terminate? How many processes with be running concurrently at any time? Will our program be a form-bomp (continuous forking of an ever increasing number of processes)? # ALL_DECLARATIONS_AND_INCLUDES //pseudo-code int value = 4; // global variable int x = 2; void sig_handler(int sig
A. (4 pts) Pick the first 3 system calls included in the code below. Analyze how each affects the program: outline what happens if they are successful or unsuccessful. Hint: To describe the unsuccessful execution of an instruction Z you must assume that all preceding instructions have executed in such a way that your program reaches instruction/line Z.
ANS: The fork() sys call creates a process if value <=8
The
B. (8 pts) Assume now every sys call is SUCCESSFUL. You must make minor code modifications such as:
1) only change the sequence of existing sys calls, and/or
2) add conditional statements in front of the sys calls (like if, for, etc.)
These modifications are made so that:
Q1. (6 pts) Both printouts of Line C and Line E are executed. Then list all the possible printouts for your solution. List no more than the first 6 printouts you are getting in order (with detailed values of the variables involved). Does the program run indefinitely or not? Are the processes forked indefinite or not?
Q2 (2 pts): What extra to Q1 must be done for the program to a) terminate in the case that it does not, or b) run indefinitely in the case that it does not?
C. (6 pts) Under what circumstances are your answers to the questions in part B same or different if we execute Line B before Line A? Answer again: Q1, Q2, exactly as they are phrased in part B.
D. (6 pts) Use variable x to insert a simple instruction in Line H in order to ensure that your program terminates under ANY circumstances with the assumptions of Part B. Will your instruction work the same way if we execute Line B before Line A? Or do we need to make further assumptions/scenarios?
E. (6 pts) If in Line H x is to add number 3 to variable value, will the program terminate? How many processes with be running concurrently at any time? Will our program be a form-bomp (continuous forking of an ever increasing number of processes)?
# ALL_DECLARATIONS_AND_INCLUDES //pseudo-code
int value = 4; // global variable
int x = 2;
void sig_handler(int sig
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