1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tanya [424]
2 years ago
11

Using the program below, explain what the output will be at LINE A. 1 #include 2#include 3#include 4 5 int value - 128; 6 7 int

main 8 9 pid.t pid; 10 11 pid=fork 12 13 if (pid 0) { /* child process */ 14 15 16 value +8; return 0; 17 else if (pid > 0) parent process / 18 19 20 21 wait (NULL); printf ("PARENT: return 0; value =%d\n" ,value); /* LINEA */
Computers and Technology
1 answer:
slega [8]2 years ago
5 0

Answer:

This is the complete correct program:

#include <stdio.h>

#include<sys/types.h>

#include<unistd.h>

int value = 128;

int main()

{

  pid_t pid;

  pid=fork();

  if (pid==0) /* child process */

  {

  value +=8;

  return 0; }

  else if (pid > 0) {/* parent process */

 wait (NULL);

 printf ("PARENT: value =%d\n" ,value); /* LINEA */

 return 0;

}

}

The output of the LINE A is:

PARENT: value = 128

Explanation:

The fork() function used in the program creates a new process and this process is the child process. The child process is same as the original process having its own address space or memory.

In the child process the value of pid is 0. So the if condition checks if pid==0. Then the child process adds 8 to the value of its variable according to the following statement  

value +=8;

Now the original process has value = 128. In else if part the parents process has the value of pid greater than zero and this portion of the program is of the parent process :

else if (pid > 0)

{ wait (NULL);

printf ("PARENT: value =%d\n" ,value);

return 0; }

So the value 128 is printed at the end in the output.

wait(NULL) is used to wait for the child process to terminate so the parent process waits untill child process completes.

So the conclusion is that even if the value of the variable pid is changed in the child process but it will not affect the value in the variable of the parent process.

You might be interested in
What is the biggest difference between a movie and a game?
sveta [45]

Answer:

It could be D

Explanation:

3 0
2 years ago
Kiara is using her software's graphic formats to create a line graph. As she
Ad libitum [116K]

Correct the data she entered , and the software will adjust the graph -apex

5 0
3 years ago
Read 2 more answers
What two benefits are a result of configuring a wireless mesh network? Check all that apply.
Andrei [34K]

Answer:

1)PERFORMANCE

2)RANGE

Explanation:

A mesh network can be regarded as local network topology whereby infrastructure nodes connect dynamically and directly, with other different nodes ,cooperate with one another so that data can be efficiently route from/to clients. It could be a Wireless mesh network or wired one.

Wireless mesh network, utilize

only one node which is physically wired to a network connection such as DSL internet modem. Then the one wired node will now be responsible for sharing of its internet connection in wireless firm with all other nodes arround the vicinity. Then the nodes will now share the connection in wireless firm to nodes which are closest to them, and with this wireless connection wide range of area can be convered which is one advantage of wireless mesh network, other one is performance, wireless has greater performance than wired one.

Some of the benefits derived from configuring a wireless mesh network is

1)PERFORMANCE

2)RANGE

7 0
2 years ago
In an all-integer linear program,
xenn [34]

Answer: E

All decision variables must be integer

Explanation:

The integer-linear program is a program in which the objective function and any constraints are all linear ie all of the variables are restricted to be integers.

A linear program is Np complete. Also every decision variable appear in any constraints must also appear in the objective function, possibly with zero coefficient if needed.

8 0
3 years ago
Explain how a third party cookie can track your web browsing across multiple web domains.
Vlada [557]
A third party cookie can stay in your hard drive or browsing files, and record all the action

Hope this helps.
3 0
3 years ago
Other questions:
  • How can i save a word 2016 document as a word 2016 document?
    6·1 answer
  • The difference between a want and a need is a want is not necessary for survival. Things necessary for survival are known as ___
    6·1 answer
  • EIPP:________.
    9·2 answers
  • A program that processes data submitted by the user. Allows a Web server to pass control to a software application, based on use
    11·1 answer
  • Write a function that accepts an argument for a persons name. The method should loop through the number of characters in the nam
    7·1 answer
  • Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price
    7·1 answer
  • Python;
    6·1 answer
  • Please answer fast..​
    15·1 answer
  • Amogus :0) owo have a good day y'all
    12·1 answer
  • Which attributes are indicators that a website is reliable? Check all that apply is up to date explains sources of data is an ed
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!