2. What to Do?

Write in the C programming language several functions to use the PC's timer. The goal is to develop a generic module that will be used to create a library, which you will be able to use in the course's project.

In this lab we specify the prototype of functions that operate on the I/O device. However, for testing/evaluation purposes you will also have to develop a set of test functions, whose prototype we specify. In future labs, we will specify only the testing functions and you will have to design the functions for operating on the I/O device.

Specifically, you shall develop the following test functions:

  1. int timer_test_config(unsigned char timer)
  2. int timer_test_time_base(unsigned long freq)
  3. int timer_test_int(unsigned char time)

These three functions are declared in header file timer.h, and file timer.c contains their implementation stubs. You may find it convenient to add your test code to these files; this way you will avoid making mistakes in their definition. Section 6 describes what these functions should do, and specifies the functions that you will have to develop to implement them. You can also read the documentation generated by doxygen for the timer module.

In this lab, we will provide you the main() function, in a file named lab2.c. This file allows you to invoke each of the three test functions, by invoking your program with the appropriate arguments, and it will make it easier for you to test the code you develop, without having to change main() every time you want to test a specific function.

To create a working copy for this lab in the home directory of user lcom in the Minix 3 VBox image of the lab's PCs, you can follow the steps suggested in the SVN tutorial. I.e. you can:

  1. Download the archive with the development files provided for this lab
  2. Unzip that archive and import the directory tree rooted at lab2 to the SVN repository of your project on Redmine, as described in Lab 0 's Section 6. (Remember that i) this need not be done in a working copy, and ii) it does not make the imported directory a working copy.)
  3. Create, in the /home/lcom/lab2/ directory of the Minix image, a working copy of the directory tree rooted at lab2, that you have just imported.
    This step depends on whether you already have a working copy of the root of your repository on your Minix image. If you have (this is likely the case if you are using your laptop) all you need to do is to use the SVN update command. Otherwise (this is the case if you are using the lab's PCs), you can use the SVN's checkout command to the directory tree rooted at lab2, like you've done in Lab 0.

You should be user root only to:

  1. install the configuration file lab2 in /etc/system.conf.d/, and
  2. run your program with service.

Otherwise, you should always be user lcom. I suggest that you use two Linux terminals, and login, via ssh, as user lcom on one of them and as user root on the other one.Use the latter only for the two tasks mentioned above. (If you forgot how to login on Minix via ssh, check Section 4 of this tutorial.)

2.1 Class Preparation

This lab is planned to be carried out in two classes. The goals for the each class are as follows:

First class
Implement both timer_test_config() and timer_test_time_base() and associated functions.
Second class
Implement timer_test_int() and associated functions in the second lab.

Thus you should start by reading these notes, which provide an overview of the development process that you'll use in LCOM.

Furthermore, for the first class, you should read this handout, except Sections 4 and 5.3, which concern interrupts, the focus of the second class. In addition, you should read the i8254 data sheet, especially the section on its programming interface, and the material that was presented in the lectures of September 30th and October 3rd. Finally, you should also import the code provided to the SVN repository of your Redmine project.

For the second class, you should read Sections 4 and 5.3, as well as the material about interrupts that will be presented in the lectures. (Furthermore, if you have not completed the goals for the first class, you should complete them before the second class.)

Although we will grade the contents of your SVN repository only by the deadline of the lab, we encourage you to regularly commit your work as you implement and test the required functions. Remember that one of the goals of this course is that you learn how to use tools typically used in the development of large programs, including version control systems, and you will receive credit for it.