Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C to create N processes that form a ternary tree (i.e., each node has exactly three child nodes) where N is

Write a program in C to create N processes that form a ternary tree (i.e., each node has exactly three child nodes) where N is the command line input to the program (N must be greater than zero and less than 10). Each process prints out its own PID and its parent PID. Use loop structure. Explain fully how the program works. For brevity, do not write include files. My previous lab was provided as starting point,please complete.

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 # include # include # include # include unistd.h? int main int argc, char *argvI) int i, m, n, sleeptime, seed pid t childpid; if (argc 2) { printf("in Usage: %s processesa", argv[0]) exit(1) n = atoi(argv[1]); m = 10; childpid = 0; for (i=0; i<><>

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago