Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume pr1 always executes first and is invoked as follows: ./pr1 How many unique processes do the programs pr1 and pr2 create when executed, including

image text in transcribed

Assume pr1 always executes first and is invoked as follows: ./pr1

  1. How many unique processes do the programs pr1 and pr2 create when executed, including the initial process? Provide a brief explanation.
  2. What will these programs print? (Choose one valid sequence and display it.)

prl: int main(int argc, char **argv) { pid_t pidi, pid2; pr2: int main(int arge, char **argv) { pid_t pid; pidl = fork(); if (pidl == 0) { printf ("P1 child "); execlp ("./pr2", "pr2", "fork 1", NULL); } else { printf ("P1 original "); wait (NULL); printf ("P2 %s ", argv[1]); pid = fork(); if (pid > 0) { wait (NULL); printf ("P2 parent ts ", argv[1]); } else if (pid == 0) printf ("P2 child ts ", argv[1]); return 0; pid2 = fork(); } if (pid2 == 0) { printf ("Child of P1 "); execlp("./pr2", "pr2", "fork 2", NULL); } else { printf ("Still P1 original "); wait (NULL); } } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions