Construct a C/C++ program for a UNIX environment to use the

Construct a C/C++ program for a UNIX environment to use the trapezoidal rule to approximate the integral of

f(x) = 1/(x + 1)

for the interval [0, 2]. Construct your solution so that you compute the areas of n small trapezoids by N individual worker processes. The master process should spawn N worker processes using the fork () and exec () UNIX system calls. Read about using system V UNIX shared memory in Lab Exercise 11.1, and then use the facility to implement the requisite synchronization and information sharing for a concurrent solution to this problem. Whenever a worker process is ready to compute the area for another trapezoid, it synchronizes with the master using a shared variable and gets new work via shared memory. When the master process receives all the sums from the worker processes, it should sum them and print the answer, along with the amount of time required to obtain the solution. It should ignore the time to set up the shared memory. Experiment with various values of N between 1 and 8 for n = 64 trapezoids. Use a getTime () routine (see the exercises in Chapter 1) to instrument your program so that you can measure the amount of time spent processing your code. Include a suitably large for loop in your procedure to evaluate the area of a trapezoid so that you can measure the time required to accomplish the computation. Plot the amount of time versus the number of trapezoids used in the approximation.

If you have a shared-memory multiprocessor available to use, solve this problem using the shared-memory kernel extensions provided by the machine.


Members

  • Access to 1 Million+ Textbook solutions
  • Ask any question from 24/7 available
    Tutors
$9.99
VIEW SOLUTION
OR

Non-Members

Get help from Computer Engineering Tutors
Ask questions directly from Qualified Online Computer Engineering Tutors .
Best for online homework instance.