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
Jensen is a senior developer for Hackers R'Us, a company that helps secure management information systems. Jensen's new task is
Harlamova29_29 [7]

Answer:

b. white-hat hacker

Explanation:

A White-hat Hacker, also known as an Ethical Hacker is an information security specialist, known for performing penetration testing and checks in search for information and communications system's vulnerabilities on demand for his/her clients.

These efforts are meant to find security risks before someone else does, who could cause any kind of damage to the systems or unauthorized access to sensitive information

6 0
3 years ago
Convert the following decimal fraction to binary with a maximum of six places to the right of the binary point: 194.03125Note: n
nika2105 [10]

Answer:

11000010.000010

Explanation:

3 0
4 years ago
A __________ is a device that allows a computer, which works with digital information, to communicate over lines that use analog
navik [9.2K]

Answer:

MODEM(Modulator Demodulator)

Explanation:

A modem is a device used in data communication that allows analog signal to be sent over a telephone line.

The modem works by converting the analog signal into digital data that the computer understands. The digital data is converted back to its original form at the receiver end.

Modem modulates analog signal from a telephone line to digital data the computer can understand. also, at the receiver end, it demodulates the digital data back to its original analog signal.

3 0
4 years ago
Suppose a program is operating with execution-time binding and the physical address generated is 6730. The relocation register i
zaharov [31]

Answer:

730

Explanation:

Calculation for What is the corresponding logical address

Using this formula

Corresponding logical address=Physical address generated-Relocation register

Let plug in the formula

Corresponding logical address=6730-6000

Corresponding logical address=730

Therefore the corresponding logical address will be 730

4 0
3 years ago
Write an application that reads an English-language phrase and encodes it into Morse code. Also write an application that reads
Morgarella [4.7K]

Answer: English to Morse code. Hello my name is Isabella:   .... . .-.. .-.. --- / -- -.-- / -. .- -- . / .. ... / .. ... .- -... . .-.. .-.. .-

Morse code to English: .. / .-.. .. -.- . / -- .- - ....  is I like math

6 0
3 years ago
Other questions:
  • What two methods can be used to access and modify an existing program that is running on an iot device in cisco packet tracer? (
    6·1 answer
  • What does "ttyt" stand for?
    13·2 answers
  • An attacker tried to hack into the database of a reputed organization. The attacker inserted malicious code into the query of a
    14·1 answer
  • "background" software that helps the computer manage its own internal resources is called ________.
    5·1 answer
  • Arctic Gear LLC. recently adopted a new ERP​ system, but quickly found that it​ wasn't a perfect fit with their existing procedu
    14·1 answer
  • While (e &lt; 10):<br> print (c)
    10·1 answer
  • A testing lab wishes to test two experimental brans of outdoor pain long each wiil last befor fading . The testing lab makes six
    11·1 answer
  • Match each term in the second column with its correct definition in the first column. Write the letter of the term on the blank
    12·1 answer
  • Function of pons for class 7​
    15·1 answer
  • Make a program that receives several integers (the program ends when a negative number is entered) and shows how many times the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!