Computer Architecture and Organization
The purpose of this assignment is to build a package of timing routines for the tutor VM and use it to time code on the tutor VM. This code does not run on UNIX. Read the Intel 8254 Programmable Interval Timer (PIT) Data Sheet, linked in course readings.
A package is a set of utilities that can be called by a program that wants to use them. When designing a package, we carefully consider the things in it that must be visible to the caller, specify those, and require that everything else be internal and invisible. The visible parts of the timing package you will build are in "timepack.h" (function prototypes and comments are listed in the timing directory /home/cheungr/examples/timer_dir on the users host.). A customer for the package's services includes that header file (using #include) in the program for compilation and links his or her object code with "timepack_sapc.o" to build the executable.
Every package should have a test program showing that it works by calling it. This test program is called a "driver" because it sits on top of the package and drives it like we test- drive a car – start up, do this, do that, stop, shut down. It is also called a "unit test" program because it tests just this one package separate from any other package in a bigger program. If you suspect something is wrong in a certain package, you’ll try to make its unit test fail, and then you debug the problem in the relatively simple environment of the unit test, rather than in the bigger program.
The test programs for timepack is measure.c and charGen.c. You can build measure and measure.lnx using the makefile provided. File transfer the measure.lnx and the charGen.c file from the course directory to your vserver VM. Build the charGen program at vserver VM using:
Use cs444 as your sudo password. Capture this in a typescript1 file (see an example). It shows that the timing package (as provided) can time things on the tutor VM to 55-ms accuracy, but not to the microsecond accuracy we want. The next step is to get your
You're working directly with the hardware device, the Programmable Interval Timer (PIT) with its interrupt handler. This code has been provided to you in a). The timepack_sapc.c as provided can measure time in timer "ticks" at an 18.2-Hz (55 ms/tick) standard PC tick rate. To use the PIT to measure higher precision, you make use of "downcounts" within the timer chip. What you need to do is determine how many counts have down counted in the timer *since* the last tick and compute a higher accuracy time. By doing this at both the start and the end of the time interval being measured, you can compute the elapsed time accurate to a few microseconds, a very respectable timer service. You’ll need to modify the timepack_sapc.c to achieve this.
Note that you need to *convert* downcounts (an int) to usecs (another int). To do this, cast the downcount value to double, multiply by the correct double conversion factor, and then cast back to int usecs. The idea here is that the conversion factor is itself non-integral, so the needed multiplication by it needs to be in floating point, resulting in a floating point number accurate to about 1 usec, so we might as well cast it back to an int value since ints are easier to work with.
Don't leave any printf's in your final code that output during timing runs!! They take a really long time and ruin the data. Save the timing figures in memory and print them out after the stoptimer call.
Any private functions or variables you need should be declared static in "timepack_sapc.c" file, so that the calling program can never accidentally use a variable or function with the same name, or interfere with yours. Capture your improved result in a typescript2 file.
Leave working versions of the source files and the script files in your mp4 project directory. The grader or I may rebuild them and/or run them to test them. A copy of the rubric sheet for grading mp4 is included. In the event that you are unable to correctly complete this assignment by the due date, do not remove the work you were able to accomplish - partial credit is always better than none.