Designing a Timer Interrupt Handler for Your Prototype OS

Weight

   5% weight in your final grade

 

Objectives

In this project, we will take the first step to design our own prototype OS. Specifically, we will enable the prototype OS to interact with the underlying (bare-machine) DE-2 board, by means of manipulating the timer on the DE-2 board via an interrupt handler.

This project will be fairly easy, but it lays an indispensable foundation for the following two projects.

Tasks

1.   Initial steps (essentially, by following the instructions in the pre-project lab):

á   download the NIOS-II CPU to the DE-2 board.

á   build a program of which the main function just calls prototype_os (defined in Table 1)

á   execute it on the DE-2 board

á   observe the results on your NIOS-II IDE.

2.   Design an interrupt handler for the timer of your DE-2 board. The timer needs to be first initialized with alt_alarm_start in prototype_os, then it will periodically interrupt the execution of prototype_os with its interrupt handler (see Table 1). Regarding how to use alt_alarm_start, please refer to the document Nios-II Software DeveloperÕs Handbook.

3.   Try to insert the inline assembly asm(ÒnopÓ) at any place in your program, and see what will happen.

4.   Debug your program, observe its disassembly code and see what the difference will be if the inline assembly asm(ÒnopÓ) is added.

 

 

Table 1A Description of Required Functions

 

main()

 void main()

 {

   // Here: call prototype_os

 }

prototype_os( )

 void prototype_os( param_list)

 {

     // Here: initialize the timer and its interrupt handler  

     while (true)

     {

         alt_printf (ÒThis is the prototype os for my exciting CSE351 course projects!\nÓ);

         // Here: think about what MAX is used for. Pick up an appropriate value for it experimentally.

         for (j = 0 ; j < MAX; j++);

     }

 }

alt_alarm_start( )

// This function schedules an alarm callback upon an alarm interrupt

myinterrupt_handler( )

 alt_u32 myinterrupt_hander (void * context)

 {

     alt_printf(ÒInterrupted by the timer!\nÓ);

     return ALARMTICKS(QUANTUM_LENGTH);

     // Here: added on 09/25/2011 upon a group's request

     // put "#define ALARMTICKS(x) ((alt_ticks_per_second()*(x))/10)" at the beginning of your code

     // when you use "ALARMTICKS(5)", it specifies the interrupt period to be 0.5 second (= 1 second * 5 / 10)

 }

 

Submission

You are supposed to submit a tarball file (in either zip or tar.gz format) packed with the following things by the deadline

1.            A project report that includes:

á      the project title & your team membersÕ names

á      an introduction to your project goals, problem description and project management (including project timeline, teamwork, risk anticipation, resources, etc.)

á      your key ideas of solving the project problems

á      an elaboration of how you accomplish your project tasks (including data structures, algorithms, strategy, etc.) using diagrams, flowcharts, tables or descriptions

á      a summary of:

o   what you have accomplished in this project

o   how it can help you understand what you have learned in class

o   your evaluation of the work that you have done (e.g., how creative your proposed idea is, how simple and sweet your design and implementation are, how well your project is organized, etc.)

o   how the course project and its specifications can be improved

á      references: list the sources of citations appearing in your report

á      format: 11pt Times-New-Roman fonts (the title and section headings can be larger); single-column; 1 inch margins all the way around a page; page numbers; no more than 8 pages in all; DONOT paste source code with more than 10 lines; diagrams/charts/graphs with brief explanations are more preferable than thousands of words; submitted as a PDF file.

 

2.            A folder containing your project source code with meaningful comments, as well as a README file that details the organization of your own source code (e.g., what each file is used for and how they function together) , as well as how to compile and run the program. Please DONOT include any files or folders automatically generated by the NIOS-II IDE.

Grading Criteria (Rubric)

1.   Project report: 50%

2.   Correctness of the program: 40%

3.   Detailed source code comments and README: 10%

Typically, all members in a team will get the same grade for a project, unless the team leader or other members report to the grader that someone contributes little to the project and he/she should get only a certain percentage (e.g., 90%) of the teamÕs grade.