Question

In: Computer Science

When the following statements are executed, what is the output from the child process? You may...

When the following statements are executed, what is the output from the child process? You may assume all variables have been properly declared and all function calls are successful.

var2 = 200;
var3 = 300;
var1 = fork();
if ( var1 > 0 )
{
   printf("%d\n", var2);
}
else
{
   printf("%d\n", var3);
}

200

1

0

300

100

A process that has terminated, but whose parent has not yet called wait(), is known as a __________ process.

zombie

terminated

false

init

In Unix/Linux, a process can run the __________ system call to load another executable to its memory image.

wait()

exit()

fork()

exec()

Solutions

Expert Solution

When the following statements are executed, what is the output from the child process?
You may assume all variables have been properly declared and all function calls are successful.

var2 = 200;
var3 = 300;
var1 = fork();
if ( var1 > 0 )
{
   printf("%d\n", var2);
}
else
{
   printf("%d\n", var3);
}


Answer: 0 (zero)                                 

Explanation:

fork() system call is used to create a new process in unix. fork()
call returns twice. It returns in both process calling fork() and
in the newly created process. Child process returns zero
and the parent process returns a number greater than zero.

                                                  -------------------

A process that has terminated, but whose parent has not yet called wait(), is known as a __________ process.

Answer: Zombie

A zombie process is a process that has completed but still has an entry in the process table.

                                                   -------------------

In Unix/Linux, a process can run the __________ system call to load another executable to its memory image.

Answer: exec()

exec() runs an executable file in the context of an already existing process, replacing the previous executable.


Related Solutions

1. Write an application that prints the following diamond shape. You may use output statements that...
1. Write an application that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space or a single newline character. Maximize your use of repetition (with nested for statements), and minimize the number of output statements 2. Modify the application you wrote in Exercise 5.20 (Question 1 Above) to read an odd number in the range 1 to 19 to specify the number of rows in the diamond. Your program should...
c programing language When a new program is executed, a new process is created with the...
c programing language When a new program is executed, a new process is created with the next available process ID. However, there are a few special processes that always have the same process ID, which are usually given the ID value less than 5 these are called system processes. Can you identify which of the two system processes have the process ID of 0 and 1 respectively?
You will write a C program to fork a child process. The child process will print...
You will write a C program to fork a child process. The child process will print the current time/date. The parent will wait for the child to complete. Here is how you can programmatically call the Linux date command from a C program. execlp("/bin/date","date",NULL); Your C file should be named myfork.c The binary will be named myfork.
What is the output of the following statements? a. cout << ("Jack" <= "John" && "Business"...
What is the output of the following statements? a. cout << ("Jack" <= "John" && "Business" >= "Accounting") << endl; b.cout << boolalpha << ((10 <= 15 - 2) && (15 >= 20) || (15 - 2 != 20)) << endl; c.cout << !(30 > 10) << endl; d.cout << showpos << (6 <= 5 || 3 < 15) << endl; e.cout << boolalpha << ("bill" > "billy") << endl;
Identify the directives and statements in the following program. What is the output of the program?...
Identify the directives and statements in the following program. What is the output of the program? [2 points] #include <stdio.h> int main (void) { printf(“Parkinson’s Law: \n Work expands so as to \t”); If i and j are positive integers, does (-i)/j always have the same value as –(i/j)? Justify your answer. [2 points] printf(“fill the time \n”); Supply parenthesis to show how a C compiler would interpret the following expressions: [2 points] a * b – c *d +...
The signal output from a certain process in an industry is described by the following equation...
The signal output from a certain process in an industry is described by the following equation h (t) = 5 cos 2π1000 t + 7 cos 2π 2000 t + 2 cos 2π 3000 t. Suggest any two remedial measures to avoid any problems that occurred during the reconstruction process.
JAVA programing language: What is printed when the following code is executed? int columns; int rows;...
JAVA programing language: What is printed when the following code is executed? int columns; int rows; for(rows = 1; rows < 2; ++rows) { for(columns = 1; columns < 3; ++columns) { System.out.print("x"); } System.out.println(): } select one: A) xx B) xxx xxx C) x x D) xx xx xx
What is the output from each of the following segments of C++ code? Record the output...
What is the output from each of the following segments of C++ code? Record the output after the “Answer” prompt at the end of each program fragment. Assume all variables have been suitably declared. (Each problem is worth 3 points.) 1. for (int j = 8; j > 3; j -= 2)         cout << setw(5) << j;     Answer:      2. int sum = 5;    for (int k = -4; k <= 1; k++)         sum = sum...
You are given the following information for the May overhead expenses as follows:     Budgeted output...
You are given the following information for the May overhead expenses as follows:     Budgeted output quantity                                        12,800     Budgeted fixed manufacturing overhead          $80,000     Budgeted variable manufacturing overhead      $20/direct labor hour     Budgeted direct manufacturing labor hours       8 hours/unit     Fixed manufacturing costs incurred                 $104,000     Direct manufacturing labor hours used                28,800     Variable manufacturing costs incurred            $142,400     Actual quantity manufactured                               13,600    a.    Compute a 4-variance analysis b.    Compute a 3-variance analysis c.     Compute a 2-variance analysis...
The following list describes some common responses that you may receive from a customer, when on...
The following list describes some common responses that you may receive from a customer, when on a collection call. Discuss (50–80 words each) your tactics or verbal response for overcoming each customer statement. 1. ‘I’ll fax you a copy immediately and call you back in 10 minutes.’ 2. ‘Your invoice was actually incorrect. You didn’t quote our order number, that’s why it hasn’t been paid as yet.’ 3. ‘Great, how much is the cheque for?’ 4. ‘The guy you need...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT