Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, I would like some assistance with this question please! must be written in C, thank you! Begin by writing a recursive C function that
Hi, I would like some assistance with this question please! must be written in C, thank you!
Begin by writing a recursive C function that calculates the nth fibonacci number, this will be used in the main assignment problem. The fibonacci numbers are a sequence given by: fi = 1, fz = 1, fn = {n-1 + fn-2; for n > 3 . . Write a C program that generates a timer profile of the current process. Your time measurements should have seconds, and microseconds accuracy. It should be able to display four (4) different timer measurements for the current process: Wall Time Spent Executing - The amount of time the process spent from start to finish. (1.e. the Real Time) Total Time Spent on CPU - The amount of time the process spent executing instructions on the CPU plus the amount of time that the kernel was doing work on behalf of the process. (i.e. the Profile Time) Time Spent in User Space - The amount of time the process spent executing instructions on the CPU. (1.e. the Virtual Time) Time Spent in Kernel Space - The amount of time the kernel spent doing work on behalf of the process. For each interval that you wish to record, set up an interval timer that raises a signal every one (1) second. Each second, when the signal is raised, some counter should be used to keep track of the number of seconds that have elapsed. In the end, the counter together with the present contents of the given interval timer will be sufficient to obtain the number of seconds and microseconds that have elapsed since the process began. Write the code for profiling the process in a general manner so that it can be re-used for multiple processes. This will be necessary for the next part of the assignment given below. Next adjust your program so that it spawns new processes. The main program (the parent process) should spawn a first child that is given to compute the nth fibonacci number, where n is the second command line parameter (1.e. argv[2]). Immediately after spawning the first child, the parent should spawn a second child that is given to compute the mth fibonacci number, where m is the third command line parameter (1.e. argv[3]). After spawning the second child, the parent itself should then proceed to compute the fibonacci number for the first command line parameter (i.e. argv[1]). After the parent has finished computing, it should wait on the first and second child processes to complete before continuing. After each child has finished computing its assigned fibonacci number, it's timer profile should be printed. The parent's profile should be printed after it has done waiting on the children. Begin by writing a recursive C function that calculates the nth fibonacci number, this will be used in the main assignment problem. The fibonacci numbers are a sequence given by: fi = 1, fz = 1, fn = {n-1 + fn-2; for n > 3 . . Write a C program that generates a timer profile of the current process. Your time measurements should have seconds, and microseconds accuracy. It should be able to display four (4) different timer measurements for the current process: Wall Time Spent Executing - The amount of time the process spent from start to finish. (1.e. the Real Time) Total Time Spent on CPU - The amount of time the process spent executing instructions on the CPU plus the amount of time that the kernel was doing work on behalf of the process. (i.e. the Profile Time) Time Spent in User Space - The amount of time the process spent executing instructions on the CPU. (1.e. the Virtual Time) Time Spent in Kernel Space - The amount of time the kernel spent doing work on behalf of the process. For each interval that you wish to record, set up an interval timer that raises a signal every one (1) second. Each second, when the signal is raised, some counter should be used to keep track of the number of seconds that have elapsed. In the end, the counter together with the present contents of the given interval timer will be sufficient to obtain the number of seconds and microseconds that have elapsed since the process began. Write the code for profiling the process in a general manner so that it can be re-used for multiple processes. This will be necessary for the next part of the assignment given below. Next adjust your program so that it spawns new processes. The main program (the parent process) should spawn a first child that is given to compute the nth fibonacci number, where n is the second command line parameter (1.e. argv[2]). Immediately after spawning the first child, the parent should spawn a second child that is given to compute the mth fibonacci number, where m is the third command line parameter (1.e. argv[3]). After spawning the second child, the parent itself should then proceed to compute the fibonacci number for the first command line parameter (i.e. argv[1]). After the parent has finished computing, it should wait on the first and second child processes to complete before continuing. After each child has finished computing its assigned fibonacci number, it's timer profile should be printed. The parent's profile should be printed after it has done waiting on the childrenStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started