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]
3 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]3 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
You want to multiply 50 in cell D3 by 8.90 in cell E3. Which formula should you use?
Effectus [21]

Answer:

The formula is =D3*E3

Explanation:

To multiply the items in 2 cells, the formula like every other in excel begins with = .

to multiply 50 in cell D3 by 8.90 in cell E3 the formula to be used is

=D3*E3

This will multiply the numbers in both cell and show as 445.

7 0
4 years ago
Suppose end system A wants to send a large file to end system B. At a very high level, describe how end system A creates packets
sashaice [31]

Answer:

The answer is below

Explanation:

Suppose end system A wants to send a large file to end system B, the large file is first divided into smaller chunks. Each chunk is then assigned a header forming a packet. Multiple packets are being generated with each of the packet containing a unique destination address in its header.

When a packet arrives at the packet switch, the switch uses the unique destination address that is attached in the header of the packet to determine the link onto which the packet is to be forwarded.

5 0
3 years ago
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="225547404f435156475062404e434c4947560c414d4f">[email&#1
Basile [38]
The answer would be D. An email address
3 0
4 years ago
Read 2 more answers
What is the use of html in websites
Alborosie
HTML is a very basic markup language and requires memorization of a few dozen HTML commands that structure the look and layout of a web page. Before writing <span>any HTML code or designing your first web page, you must decide on an HTML editor or text editor, such as Notepad or Word Pad.</span>
4 0
3 years ago
Read 2 more answers
What is the build in libary function to compare two strings?​
worty [1.4K]

Answer:

strcmp() is a built-in library function and is declared in <string. h> header file. This function takes two strings as arguments and compare these two strings lexicographically.

Explanation:

Hope it helps

3 0
4 years ago
Other questions:
  • When using static ip addressing, software automatically configures the network connection on each device.?
    9·1 answer
  • 1. Rice paste changes from white to blue black colour when a few drops of iodine solution are added to it. It shows the presence
    8·1 answer
  • Given positive integer num_insects, write a while loop that prints that number doubled up to, but without exceeding 100. Follow
    8·1 answer
  • Complete the statement below with the correct term.
    5·1 answer
  • Which layer concerns the gateway to the network?
    10·1 answer
  • Which of the following statements best reflects the usefulness of commercial digital editing programs?
    7·1 answer
  • Methods can be ____ correctly by providing different parameter lists for methods with the same name.
    7·1 answer
  • They have requested a 1- to 2-page memo that describes the hospital's protections against a ransomware attack.
    10·1 answer
  • What is another word for: a location in memory that contains a value?
    7·2 answers
  • HELLO. Which of the following is NOT a way to control the flow of a program?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!