edited by
751 views
0 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$

2 Answers

Answer:
Position:
Show:

Related questions

0 0 votes
0 0 answers
418
418 views
admin asked Jan 5, 2019
418 views
Assume that a file is written using write $\text{(fd, buf, K)}$ system call, where $\text{fd}$ is the file descriptor and $\text{K}$ is the number of bytes to be written ...
0 0 votes
0 0 answers
462
462 views
admin asked Jan 5, 2019
462 views
Consider the following statements regarding interrupts.If a process is interrupted during system call handling then the $\text{OS}$ will crash.If a process is interrupted...
0 0 votes
0 0 answers
589
589 views
admin asked Jan 5, 2019
589 views
Consider the following statements regarding life time of any normally terminating process in an operating system.The process must be in $\text{RUNNING}$ state at least on...
0 0 votes
1 1 answer
567
567 views
admin asked Jan 5, 2019
567 views
Consider a computer system with $32-$ bit virtual addressing and page size of sixty-four kilobytes. The computer system has one-level page table per process with each pag...