Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description: Using a step-wise development (get this page too!) approach, write and demonstrate a pair of concurrent C programs that can be used in

image text in transcribed

Project Description: Using a step-wise development (get this page too!) approach, write and demonstrate a pair of concurrent C programs that can be used in the UNIX environment as a test bed for performance benchmarking. For this assignment, you are to do a concurrent comparison of two different approaches to solving factorials: recursive and iterative, with computation time being the measurement. P: The first program will be the parent process (P) of a 3- process hierarchy. Its job is to prompt the user for a positive integer (N) then to spawn 2 child processes (C1 and C2), each of which will calculate N! and report the processing time required to complete the task. In order to be a good benchmark, the task will actually be a loop of 4,000,000 factorial computations. C1 is to be embedded within program 1 (an "internal" child process) and calculates the factorial using a recursive approach. Because the runtime image of C1 will be a clone of P, N may actually be passed to C1 as a function call parameter. . C2 will use an iterative loop approach and will be the second program (.c file) of which the second spawned process will mutate into (i.e. an "external" child process). In order to communicate N from P to C2, use the kernel's messaging facility as your IPC vehicle. As each of the 3 processes start up, display a greeting including its process ID number. For the child processes, also show the value of the input parameter (N). Each child process may display its computation time, in 3 fractional digits, to the screen (stdout) before exiting. All screen output is to be preceded by some identification as to which process the output is coming from; see the sample run output screen for an example. For proper benchmark comparisons, have both child 1's rfact() and child 2's Ifact() functions accept and return arguments of type double. Project Description: Using a step-wise development (get this page too!) approach, write and demonstrate a pair of concurrent C programs that can be used in the UNIX environment as a test bed for performance benchmarking. For this assignment, you are to do a concurrent comparison of two different approaches to solving factorials: recursive and iterative, with computation time being the measurement. P: The first program will be the parent process (P) of a 3- process hierarchy. Its job is to prompt the user for a positive integer (N) then to spawn 2 child processes (C1 and C2), each of which will calculate N! and report the processing time required to complete the task. In order to be a good benchmark, the task will actually be a loop of 4,000,000 factorial computations. C1 is to be embedded within program 1 (an "internal" child process) and calculates the factorial using a recursive approach. Because the runtime image of C1 will be a clone of P, N may actually be passed to C1 as a function call parameter. . C2 will use an iterative loop approach and will be the second program (.c file) of which the second spawned process will mutate into (i.e. an "external" child process). In order to communicate N from P to C2, use the kernel's messaging facility as your IPC vehicle. As each of the 3 processes start up, display a greeting including its process ID number. For the child processes, also show the value of the input parameter (N). Each child process may display its computation time, in 3 fractional digits, to the screen (stdout) before exiting. All screen output is to be preceded by some identification as to which process the output is coming from; see the sample run output screen for an example. For proper benchmark comparisons, have both child 1's rfact() and child 2's Ifact() functions accept and return arguments of type double

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

Students also viewed these Databases questions