Recent questions tagged fork-system-call

4 4 votes
2 2 answers
384
384 views
Consider the following C program. Assume that every $\texttt{fork()}$ call succeeds.int main(void) { unsigned long int i; for (i = 0; i < 6; i++) if (fork() >= 0) continu...
2 2 votes
1 1 answer
251
251 views
Assume that every $\texttt{fork()}$ call succeeds.int main() { int a = 0; int rc = fork(); a++; if (rc == 0) { rc = fork(); a++; } else { a++; } printf("a is %d\n", a); }...
2 2 votes
1 1 answer
242
242 views
Assume that every $\texttt{fork()}$ call succeeds.int main() { int pid; pid = fork() && fork(); if (!pid) printf("A\n"); else printf("B\n"); return 0; }How many times are...
3 3 votes
1 1 answer
229
229 views
Consider the following program. Assume that every $\texttt{fork()}$ call succeeds.int main() { int p1 = 1, p2 = 2, p3 = 3; p1 = fork(); if (p2 0) p2 = fork(); if (p1 0)...
3 3 votes
2 2 answers
220
220 views
Consider the following C program. When the execution reaches line $5$, how many processes and threads, respectively, exist in the process hierarchy?int main() { int i; fo...
3 3 votes
1 1 answer
237
237 views
Consider the following statement:After $\texttt{fork()}$, the child’s standard input, standard output, and standard error are reset to their default states.True False
4 4 votes
2 2 answers
254
254 views
Assume that every $\texttt{fork()}$ call succeeds.int value = 0; int main() { fork(); value++; fork(); value++; if (fork() == 0) printf("Child\n"); else printf("Parent\n"...
3 3 votes
1 1 answer
188
188 views
ssume that the process priorities are $X Y Z$.Process $X$ is initially running. $X$ creates process $Y$ using $\texttt{fork()}$. $X$ requests a disk operation and becom...
5 5 votes
2 2 answers
233
233 views
Assuming that no error occurs, which statement about $\texttt{fork()}$ is correct?It is called once and returns once. It is called once and returns twice. It is called on...
3 3 votes
1 1 answer
182
182 views
When a process creates a child using $\texttt{fork()}$, which of the following is shared between the parent and child?Stack Heap Shared-memory segments All of the above
7 7 votes
1 1 answer
278
278 views
When a child process is created using the $\texttt{fork()}$ system call, its state is set to running.True False
17 17 votes
5 5 answers
3.1k
3.1k views
Consider the following program snippet. Assume that the program compiles and runs successfully. Further, assume that the fork() system call is always successful in creati...
1 1 vote
0 0 answers
265
265 views
Can anyone please give suggest some resource for studying1. System calls2. User mode and Kernel mode3. Threads.The system calls part of galvin is only 4 pages long and I ...
1 1 vote
2 2 answers
670
670 views
Suppose the following code is compiled, and run for different values of N .int main() { for (int i = 1; i <= N; i++) { fprintf(stderr, "OPERATING\n"); fork(); fork(); } f...
1 1 vote
2 2 answers
684
684 views
How to draw the tree diagram for these types of questions fork() calls ?1.main() { if( fork() ) { if(!fork()) { fork(); printf(" 1 "); } else { fork(); printf(" 2 "); } }...