i. How many processes are created in this program? (2-M ii. Write a sample output of this program (4 iii. Assuming that the statement exit(0) is commented out, and the new code is compiled and run, what kind of output would produced. (4 MS

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

Please answer this question 

Table 3 shows a C program that illustrates process creation. This program compiles and runs without any
errors. Take note that the header files been intentionally removed.
Table 3: Process Creation
#include <###.h> /*removed intentionally*/
#include <###.h> /*removed intentionally*/
#include <###.h> /*removed intentionally*/
#include <###.h> /*removed intentionally*/
int main() {
int i = 3;
int ret_val;
while(i > 0) {
if ((ret_val= fork()) ==0){ /* Child's code */
printf("In child %d.\n", i);
exit(0);
}
else { /* Parent's code */
}
printf("In parent %d.\n", i);
i=i-1;
}
return 0;
i. How many processes are created in this program? (2-Malay
ii. Write a sample output of this program (4 M
iii. Assuming that the statement exit(0) is commented out, and the new code is compiled and run, what kind of
output would produced. (4 MSE
Transcribed Image Text:Table 3 shows a C program that illustrates process creation. This program compiles and runs without any errors. Take note that the header files been intentionally removed. Table 3: Process Creation #include <###.h> /*removed intentionally*/ #include <###.h> /*removed intentionally*/ #include <###.h> /*removed intentionally*/ #include <###.h> /*removed intentionally*/ int main() { int i = 3; int ret_val; while(i > 0) { if ((ret_val= fork()) ==0){ /* Child's code */ printf("In child %d.\n", i); exit(0); } else { /* Parent's code */ } printf("In parent %d.\n", i); i=i-1; } return 0; i. How many processes are created in this program? (2-Malay ii. Write a sample output of this program (4 M iii. Assuming that the statement exit(0) is commented out, and the new code is compiled and run, what kind of output would produced. (4 MSE
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,