Question: part b: int main ( int argc, char * * argv ) { printf ( - - beginning of program ) ;

part b:
int main(int argc, char **argv)
\{
printf("--beginning of program
");
int counter \(=0\);
int second;
pid_t pid =fork();
if (pid ==0)
\{
int max_c =atoi(argv[1]);
int i,x;
for (i \(=0\); i \(<5\)++i)
\{
printf("child process: counter=sd
",++counter);
for (\(x=0\); \(x<\max \_c ; x++\));
\}
\}
else if (pid >0)
\{
int j,x,status;
int max_p =atoi(argv[2]);
pid =wait(\&status);
for \((j=0; j<5;++j)\)
\{
printf("parent process: counter=sd
",++counter);
for (x=0; \(x<\)max_p; \(x++\));
\}
\}
else
\{
//fork failed
printf("fork()failed!
");
return 1;
\}
printf("--end of program--");
return 0;
\}
In the code from part b what is the purpose of the command line arguments: 1000 and
10000?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!