Question

including the initial parent process, how many processes are created by the following programs.

including the initial parent process, how many processes are created by the following programs.
#include<stdio.h>
#include<unistd.h>
Main()
{
Int pid1,pid2;
Pid1=fork();
Pid2=fork();
}


0 0
Add a comment Improve this question Transcribed image text
Answer #1
1
the lines with fork() have undeclared variable Pid1, Pid2
answered by: jaswant singh dosanjh
Add a comment
Answer #2
Each process that executes a fork() divides into two processes. The initial process is the only one to encounter the first fork(). Each of the twoprocesses leaving the first fork() will divide again at the second fork(), making 4 total processes to reach "return 0'".
answered by: Dianara
Add a comment
Answer #3
1, because the lines containing fork() have an undeclared variable (Pid1, Pid2) because of capitalization. Otherwise, 3 (1 parent, 2 children).
answered by: Brenda Leak
Add a comment
Know the answer?
Add Answer to:
including the initial parent process, how many processes are created by the following programs.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q1) Including the initial parent process, how many processes are created by the program shown in...

    Q1) Including the initial parent process, how many processes are created by the program shown in Figure 1? Give an explanation for your answer. You can include an output statement to test and run the program. A sample output statement could be: printf("Testing......"); #include <stdio.h> #include <unistd.h> int main() { /*fork a child process*/ fork(); /*fork another child process*/ fork(); /*fork another child process*/ fork(); return 0; } Figure 1a - How many processes are created? Another version, now displaying...

  • Suppose that you have three programs that are suppose to print a house diagram in a...

    Suppose that you have three programs that are suppose to print a house diagram in a collaborative manner. (i) prog1.c #include <stdio.h>      /* Input/Output */ #include <stdlib.h>     /* General Utilities */ int main() {     printf(“                      ^^^^^^^^^^^^                       \n”);     printf(“           ^^^^^^^^^^^            ^^^^^^^^^^^            \n”);     printf(“^^^^^^^^^^^                                  ^^^^^^^^^^^ \n”);     printf(“     |                                            |      \n”);     printf(“     |                                            |      \n”);     exit(1); } (i) prog2.c #include <stdio.h>      /* Input/Output */ #include <stdlib.h>     /* General Utilities */ int main() {     printf(“     |                                             |    ...

  • With explanation Please. #include #include <sys/types.h> <unistd.h> int main void ) fork fork fork execip (...

    With explanation Please. #include #include <sys/types.h> <unistd.h> int main void ) fork fork fork execip ( "/bin/ls", return 0 /* Line A /* Line B/ /*Line C/ /. Line D ./ "ls", NULL); Answer the following: (a) Including the initial parent process, how many processes are created by the program? (b) Answer (a) assuming that lines C and D are interchanged in the program (c) Answer (a) assuming that lines B and D are interchanged (instead of C and D)...

  • M ALL ELEG220 LABS jamalbaraka X Race Condition in operating syst X o Mail- Jamal A...

    M ALL ELEG220 LABS jamalbaraka X Race Condition in operating syst X o Mail- Jamal A Baraka Outlook nments.dk X Lauk.edu.kw/pluginfile.php/214840/mod_resource/content/1/Assignment-1.pdf 1. Including the initial parent process, how many processes are created by the program shown in the following Figure? #include <stdio.h> #include <unistd.h> int nain) int i for (i 0; i< 4; i++ ) fork); return 0; Using the program shown in the following Figure, explain what the output will be at lines X and Y. 2. include ays/types.h...

  • 2Processes. Use the following assumptions to answer the questions: » All processes run to completion and no system calls will fail printf ( is atomic and calls fflush (stdout) after printing argument...

    2Processes. Use the following assumptions to answer the questions: » All processes run to completion and no system calls will fail printf ( is atomic and calls fflush (stdout) after printing argument(s) but before returning 1 int main) ( int status, pid, pid2 pid -fork O if (pid0) printf ("A") else pid2 fork ) if (pid20) printf ("C"); waitpid (pid, &status, 0) printf("D") 4 10 12 13 return; ) else ( printf("B") 14 15 17 19 return 0; 20 [8...

  • Answer this question Properly Please find out how many processes and how many threads are created:...

    Answer this question Properly Please find out how many processes and how many threads are created:                              pid_t pid;             pid = fork();             if (pid == 0) { /* child process */                   fork();                   thread_create(...); } fork(); a) Write working codes from the pseudo-code above. Add appropriate codes to ensure that you have time to observe processes and threads using ‘top’ and ‘H’ keystroke. b) Draw a simple diagram showing the processes and threads in their parent/child...

  • Consider the following program: 1int main) 2nt count1; 3 int pid 0,pid2-0 4if ((pid - fork))) cou...

    Consider the following program: 1int main) 2nt count1; 3 int pid 0,pid2-0 4if ((pid - fork))) count-count 2; printf("%d ", count); 8 if (count 1) count++ pid2-fork) printf("%d ", 12 13 14 if(pid2){ 15 16 17 18 19 > count); wa i tpid(pid2, NULL, θ); countcount*2; printf("%d ", count); a. How many processes are created during the execution of this program? Explain b. List all the possible outputs of the program c. If we delete line 15 (the waitpid) show...

  • Write code that forks into two processes: a parent process, and a child process. Your code...

    Write code that forks into two processes: a parent process, and a child process. Your code will be called with command-line arguments consisting of negative integers. Do not worry about bad command-line arguments such as "xyz". Your code will not be tested in this way. The parent process will take the arguments to main(), convert them into ints by calling atoi(), and send those ints one at a time to the child process through a pipe (one call to write()...

  • ) Using Linux or Unix command line interpreter, compile and run the programs in Figure 3.8,...

    ) Using Linux or Unix command line interpreter, compile and run the programs in Figure 3.8, Figure 3.30. DO NOT compile and ron these programs on Windows Write the 3.16, Figare 317 and Figure 3 programs in Notepadt+, for example, then compile and run them at the command pr apt. Provide screenshots of your programs compilation, execution, and the results. 144 6 7 8 9 ry-maps a shared-memory object of the ws writing to the object. The flag shared-memory object...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT