Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program using C to generate a binary tree of processes. The input to the program includes the number of levels in the tree.

Write a program using C to generate a binary tree of processes. The input to the program includes the number of levels in the tree. The maximum number of levels is 5, but the program should work for a general case of any number. Use command line arguments. Example of a program run is as follows: ecs416lin213.cecs.csuld.edu:1>p1 4

Please show output listing using N = 3. Draw a tree diagram showing the process IDs in circles. My previous lab is shown as reference, please complete

image text in transcribed

Starting point:

image text in transcribed

image text in transcribed

/**************************************************************************/ /* PROGRAM: lab2.c */ /* DESCRIPTION: This program generates a chain of processes */ /* using fork(). The number of processes n is a command line argument. */ /* Each process sleeps for a random time less than 10 seconds then prints out */ /* process ID, parent ID, and child ID */ /**************************************************************************/ # include # include # include # include int main(int argc, char *argv[]) { int i, m, n, sleeptime, seed; pid_t childpid; if (argc !=2) { printf(" Usage: %s processes ", argv[0]); exit(1); } n = atoi(argv[1]); m = 10; childpid = 0; for (i=0; i Level Procs Parent Child 1 Child 2 8 3608 35743609 3610 3610 26083612 3613 3609 3608 361 3614 3612 3610 3616 3617 3614 3609 3620 3621 3611 3609 3615 3622 3613 3610 3618 3619 3620 36143629 3630 3622 3611 3633 3634 3615 3611 3623 3635 3616 3612 3624 3625 3617 3612 3626 3636 3618 3613 3627 3637 3619 36133628 3638 3621 3614363 3632 2<>

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions