in Operating System edited by
380 views
0 votes
0 votes

Consider the following program.

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(void)
{
    pid_t pid;
    int varl = 100;
    pid = fork();
    if(pid == 0)           /* Child process */
        varl = 200;
    fork();
    printf(“%d”, varl);
    return 0;
}

Assuming all invocations of fork are successful, which of the following is a correct output when the program is executed on the $\text{UNIX OS}?$

  1. $100 \; 100 \; 200 \; 200$
  2. $200 \; 200 \; 200 \; 200$
  3. $100 \; 100 \; 100 \; 100$
  4. $100 \; 200 \; 200 \; 200$
in Operating System edited by
by
380 views

1 Answer

0 votes
0 votes
100 100 200 200

a
Answer:

Related questions