Question: Please answer this question correctly and put the screenshot Write a program named , which should take one command-line argument called maxnum. prseq should fork

Please answer this question correctly and put the screenshot

Write a program named , which should take one command-line argument called maxnum. prseq should fork two child processes. Together, these three processes will print the sequence of integers from 0 up to maxnum (inclusive), one integer on each line.

The parent process will print out 0, 3, 6, 9, etc.

One of the two child processes will print out 1, 4, 7, etc.

The other child process will print out 2, 5, 8, etc.

Obviously, unless we control the execution order of these three processes carefully, different outcomes will be observed (for example, when maxnum=4, 1,4,2,0,3 and 2,1,4,0,3 are two of the possible outcomes). You will be exploring ways to manufacture such different outcomes.

Use any kind of techniques (sleep(), excessive computation, etc.) to slow down one or two of the three processes to come up with as many different outputs as possible.

All of your executions should be fed with a maxnum=4.

Do not use semaphores or any standard solution that we have discussed or will discuss in Chapter 6.

Take snapshots

How many different outcomes have you generated?

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 Databases Questions!