Question

Problem la Points (20) Draw the process tree for the program shown below. #include<sys/types.h> #include<stdio.h> #include<un
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The fork() system call is used to create a new process.

when we execute the fork statement it creates two processes, one child and parent

When we call fork() which return 3 possible values

1) value >0 , indicate parent process

2) value = 0, indicate child process

3) value <0, error

Problem la Points (20) Draw the process tree for the program shown below. #include<sys/types.h> #include<stdio.h> #include<un

The following figure shows the process tree for the given program.

P is the main process

Add a comment
Know the answer?
Add Answer to:
Problem la Points (20) Draw the process tree for the program shown below. #include<sys/types.h> #include<stdio.h> #include<unistd.h>...
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
  • Source code to modify: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main() { pid_t pid; /*fork...

    Source code to modify: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main() { pid_t pid; /*fork a child process*/ pid = fork(); if (pid<0){ /*error occured*/ fprintf(stderr,"Fork failed\n"); return 1; } else if (pid == 0) { /*child process */ printf("I am the child %d\n",pid); execlp("/bin/ls","ls",NULL); } else { /*parent process */ /*parent will wait for the child to complete*/ printf("I am the parent %d\n",pid); wait(NULL); printf("Child Complete\n"); } return 0; } 1. Write program codes for 3.21 a and...

  • What is the output? #include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main()...

    What is the output? #include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int x = 5; int y = 2; int z = 30; x = fork(); y = fork(); if (x != 0) printf("Type 1\n"); if (y != 0) printf("Type 2\n"); z = fork(); if (x > 0 || y > 0 || z > 0) printf("Type 3\n"); if (x == 0 && y == 0 && z != 0) printf("Type 4\n"); if (x...

  • plz help me

    #include <sys/types.h> #include <stdio.h> #include <unistd.h> int value = 10; int main() { pid_t pid;  pid = fork();  if (pid == 0) {  value = value + 100;  } else if (pid > 0) { value = value -100;  printf("PARENT: value= %d \n", value); //Line A  wait (NULL); } }  (i) What will be the output in Line A? Justify your answer. (ii) Do you think there is synchronization problem in updating the variable value? Justify your answer.

  • 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)...

  • #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void...

    #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void insertionSort(int arr[], int n); void merge(int a[], int l1, int h1, int h2); void mergeSort(int a[], int l, int h) { int i, len=(h-l+1); //Using insertion sort for small sized array if (len<=5) { insertionSort(a+l, len); return; } pid_t lpid,rpid; lpid = fork(); if(lpid<0) { //Lchild proc not created perror("Left Child Proc. not created\n"); _exit(-1); } else if (lpid==0) { mergeSort(a,l,l+len/2-1); _exit(0); } else...

  • 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...

  • modify the code for timer_test_02.c to allow the time delay between events to be pseudo- random...

    modify the code for timer_test_02.c to allow the time delay between events to be pseudo- random exponential, with a mean time between arrivals of 0.1 second. Change the limit in the time_stamps() function from 5 time-stamps to 10, so that the mean run-time will be about 10*0.1 = 1.0 seconds. Once this is working, you should be able to generate 10 events with a pseudo-random exponential arrival process. The code is: #include <stdio.h> #include <stdint.h> #include <time.h> #include <unistd.h> #include...

  • GIVEN CODE- FILL IN THE BLANK! #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h>...

    GIVEN CODE- FILL IN THE BLANK! #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> // Function ptototypes int readX(); void writeX(int); int main() /// chi read x ---> divi ---> write x into file ---> par read x --> sub--> write x into file---> chi read x-->etc {    int pid;           // pid: used to keep track of the child process    int x = 19530;       // x: our value as integer   ...

  • 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...

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