Due: Wednesday, 28 September
Project 2
References:
Chapter 7, section 6,7, 8 in Understanding Unix/Linux Programming,
by Bruce Molay.
Requirements
Complete the exercise on Kernel Timers given in the handout. You do have to complete
all the parts of the exercise given in the handout.
In addition, you must fork off 3 (not two) children, each of which calculates a Fibonacci
number. You must instrument each of the children and the parent process.
- You will be graded on how much of the exercise you complete.
- I will only look at your solution to Fibonacci problem. This part requires, however, that you use
the timers described in the exercise.
- Note that for part A you do not have to create your own timeofday function.
Instead just create a function that will calculate the amount of real
time that has passed since a process has started.
- Your main program for the Fibonacci numbers should input the 3 numbers that you are going to use to calculate
the fibonacci numbers from the command line (it should not automatically do the numbers
20, 30, and 36 as described in the handout). The main function should use one of these input
numbers to calculate a
fibanocci number and the main function should also fork off 3 children, each of which will calculate
a different fibonacci number. Each process (the parent and the three children) must calcualte
real, CPU, user, and kernel times using the timers
as described in the exercise in the handout.
- You will notice that the Fibonacci program that you are required to implement does not use
any kernel (system) time. You must add system calls that will clearly demonstrate that your program
is reading the virtual and profile times correctly.
- You may also find that your main function will not set its timer correctly unless the
program uses a sufficient amount of time. If you're having problems getting the timer to set,
try running fibonacci in the main function with a value like 25. You'll have to time how long
this takes and decrement that time from the final time of your main function later.
- Note that because of the accuracy of the system clock, an alarm may be triggered 10ms
later than the specified time. Recall that in Linux, the clock triggers an interrupt every
10ms.
- Debugging Hint. There is a systems program named strace that will keep
track of all the signals and system calls that your program makes. See the man page for details.
Documentation
- You must include a readme file that
explains your results and details how the various times relate to each other. If there are
any unexpected results (a time of 0 sec, for example) you must explain that also.
- Your program must be user friendly.
- Every file in your solution must contain a comment
giving your name and the assignment number. This comment must list every function
that is defined in the file and the purpose of each.
- There must also be a separate commnent before the main function. This
comment should briefly describe the purpose of the program, describe
how it is implemented, given the major interface elements, etc.
- Finally, each function (including the main function) must have a beginning
comment that includes the following components:
- The name of the function
- The function inputs and outputs
- Changes to any global variables or kernel data structures
- System calls made from the function
- Your program must also have appropriate comments. You do not have to comment each line
of the program, but you must comment each section, feature, and functional unit of the code.
- Your program must also be appropriately formatted with tabs, spaces, etc. You will be
penalized if your code is not easy to read.
Requirements.
- You must demonstrate your program to me.
- You must hand in a hard copy of all code that you use in
your solution.
- You must also turn in your solution on the Linux server.
Revision History
| Date |
Revision |
| 16 September |
Posted Project |
| 26 September |
Added reference |
| 29 September |
Clarified part A |