You are requested to build a new program called runsim


You are requested to build a new program called runsim. The runsim program runs up to pr_limit processes at a time. The runsim program takes exactly one command-line argument specifying the maximum number of simultaneous executions. Follow the outline below for implementing runsim.

Check the appropriate command-line argument and output a usage message if the command line is incorrect.
Initialize pr_limit from the command line. The pr_limit variable specifies the maximum number of children allowed to execute at a time. 
The pr_count variable holds the number of active children. Initialize it to 0.
Execute the following main loop until the end-of-file is reached on standard input:
If pr_count is pr_limit, wait for a child to finish and decrement pr_count.
Read a line from standard input (fgets) of up to MAX_BUF characters and execute a program corresponding to that command line by forking a child and execute the file.
Increment pr_count to track the number of active children. 
Check to see if any of the children have finished (**). Decrement pr_count for each child that has completed.

After encountering end-of-file on standard input, wait for all of the remaining children to finish and then exit.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: You are requested to build a new program called runsim
Reference No:- TGS0146844

Expected delivery within 24 Hours