search
Log In

Recent questions tagged fork

1 vote
3 answers
1
9 votes
3 answers
2
How many times ‘4’ will be printed ? int main() { if (fork() && (!fork())) { if (fork() || fork()) { fork(); } } printf("4 "); return 0; } How to approach these kind of questions using Tree structure ??
asked Jun 13, 2019 in Operating System Brij gopal Dixit 772 views
1 vote
1 answer
3
Consider the code fragment: count = 3; S1; Fork L1; L1: S3; S2; goto L3; S4; Fork L2; L2: S6; goto L3; S5; L3: join count S7 Which one of the following represents correct precedence graph of the above code fragment? the answer is given but I’m getting where am I wrong?
asked Jun 12, 2019 in Operating System aditi19 521 views
8 votes
3 answers
4
main() { if(fork()>=0) { printf("*"); if(fork()==0) { printf("*"); } else{ //do nothing } printf("*"); } How many number of times “*” will be printed?
asked Feb 27, 2019 in Operating System srestha 650 views
12 votes
8 answers
5
The following C program is executed on a Unix/Linux system : #include<unistd.h> int main() { int i; for(i=0; i<10; i++) if(i%2 == 0) fork(); return 0; } The total number of child processes created is ________________ .
asked Feb 7, 2019 in Operating System Arjun 5.7k views
0 votes
1 answer
7
what is the output of the following program? int ret = fork(); if(ret == 0) { exec(some_binary); // this call fails printf("child "); }else { wait(); printf("parent\n"); } Runtime Error child parent child parent
asked Jan 13, 2019 in Operating System dd 217 views
1 vote
2 answers
8
int main(void) { int var1=100; int pid; if(pid==fork()) var1=200; fork(); printf("%d",var1); return 0; } what could be the output ? a)100 100 200 200 b)200 200 200 200 c)none
asked Jan 1, 2019 in Operating System junaid ahmad 370 views
5 votes
2 answers
9
Consider a parent process $P$ that has forked a child process $C$. $C$ has again forked another child process $D$. Now $P$ terminates while $C$ and $D$ are still running. In this case, which of the following statements is true? $P$ immediately becomes a ... $P$ $P$ immediately becomes an orphan process, until adopted by its parent
asked Dec 27, 2018 in Operating System Ruturaj Mohanty 517 views
0 votes
0 answers
10
ans is 20. pls explain procedure. thanx in advance
asked Dec 7, 2018 in Operating System Shubham Aggarwal 148 views
0 votes
1 answer
11
A process executes the following segment of code: int main() { fork(); fork() && fork(); } The number of new processes created is __________ Can someone pls explain me the solution
asked Nov 24, 2018 in Operating System Pavan Shetty 267 views
1 vote
1 answer
12
2 votes
1 answer
13
A process executes the following segment of code : for(i = 1; i <= n; i++) fork (); fork (); The number of new processes created is
asked Oct 18, 2018 in Operating System iarnav 377 views
1 vote
0 answers
14
void forkexample() { // child process because return value zero if (fork() == 0) printf("Hello from Child!\n"); // parent process because return value non-zero. else printf("Hello from Parent!\n"); } int main() { forkexample(); return 0; } Please someone explain how things are working?
asked Oct 17, 2018 in Operating System iarnav 187 views
1 vote
0 answers
15
asked Oct 12, 2018 in Operating System amit166 109 views
0 votes
0 answers
17
if (e1 || e2 ) { print "OK" } print "HAI" if e1 is true, with out checking e2 ===> it directly prints OK then HAI let take, it is fork in the place of e1 ===> 1) parent ( which have > 0 ) ===> e1 is true, ===> OK HAI printed 2) child ( which have = 0 ) ==> e1 false, ==> check e2. is it right or wrong?
asked Sep 16, 2018 in Programming Shaik Masthan 230 views
0 votes
2 answers
18
The fork system call creates new entries in the open file table for the newly created child process. [True / False] [ what is open file table ? ]
asked Sep 15, 2018 in Operating System dd 237 views
3 votes
1 answer
19
The value of z after the execution of the following program is void f(int x) { static int z; z=z+x; } int main() { int y=10; fork(); fork(); f(y); return 0; } Options are: a. 40 b. 30 c. 20 d. 10
asked Sep 5, 2018 in Operating System sumedha bhatia 462 views
7 votes
1 answer
20
A process execute the code: main() { fork(); fork() && fork() || fork(); fork(); printf("Hi"); } The number of times "Hi" will be printed is
asked Aug 12, 2018 in Operating System nandini gupta 1.1k views
3 votes
1 answer
21
for ( i = 1; i<=3; i++ ) { fork(); fork(); } How many child process will create ?
asked Aug 9, 2018 in Operating System saurav raghaw 659 views
1 vote
2 answers
23
#include <stdio.h> int main(void) { int i=0; printf("HAI\n"); for(i=1;i<=3;i++) { if(fork()==0) printf("*"); } return 0; } How many times * will be printed? and How many times HAI will be printed?
asked Jun 4, 2018 in Operating System Shaik Masthan 291 views
1 vote
1 answer
24
#include<stdio.h> #include<sys/types.h> #include<unistd.h> void forkexample() { int x = 1; if (fork() == 0) printf("Child has x = %d\n", ++x); else printf("Parent has x = %d\n", --x); } int main() { forkexample(); return 0; } What will be the output? Parent has ... Child has x = 2 (or) Child has x = 2 Parent has x = 0 I guess both because we dont know who will return first parent or child is it ?
asked May 25, 2018 in Operating System Na462 614 views
0 votes
1 answer
25
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { pid_t pid = fork(); pid = fork(); pid = fork(); if (pid == 0) { fork(); } fork(); return 0; } Total Number of Processes existing will be (Including how many parent ... $24$ Processes (12 Parent and $12$ child). Please see my solution carefully and point out weather the number of parent and child were calculated correctly ?
asked May 25, 2018 in Operating System Na462 271 views
1 vote
2 answers
26
main() { if(fork()>0) sleep(100); } The given code results in the creation of: I) an orphan process II) a zombie process III) a process that executes forever IV) None of these Can someone explain this?
asked Apr 30, 2018 in Programming gauravkc 611 views
3 votes
3 answers
27
The following $C$ program: { fork(); fork(); printf("yes"); } If we execute this core segment, how many times the string yes will be printed? Only once 2 times 4 times 8 times
asked Apr 22, 2018 in Operating System Arjun 3.2k views
2 votes
1 answer
28
#include<stdio.h> #include<stdlib.h> void main() { int a =100; if(fork()==0) { a=a+5; printf("%d %d \n",a,&a ); } } How many parent and child process will be created?
asked Mar 8, 2018 in Operating System srestha 982 views
0 votes
2 answers
29
Consider following pseudo code : main() { int t1,t2,t3; t1=t2=t3=0; t1=fork(); t2=fork(); if (t1!=0){ t3=fork(); printf("Hello"); } } How many Hello's are printed when above code get executed. $1$ $2$ $3$ $4$
asked Feb 27, 2018 in Operating System bhanu kumar 1 368 views
0 votes
1 answer
30
...