CS-384 Lab 3: Embedded OS Phase I

Overview

The purpose of this lab is to increase understanding of operating system process management by implementing some components of a preemptive multitasking operating system for the Motorola 68HC11 microprocessor.

Lab activity

Design and implement a simple dispatcher and round-robin scheduler for the 68HC11 microprocessor using assembly language (GNU as/ld, used in CS-280, is recommended; C++ is not allowed). You must also design and implement at least two "user" processes:

The OS dispatcher should be designed to handle up to eight processes, though initially only the two above will be used. It should have a manually variable time quantum value (from tens of milliseconds to a few seconds); when the currently running process has exhausted its quantum, the dispatcher should context switch to the next "ready" process. Be sure to handle the possibility that there is no "ready" process. This could be accomplished by using an idle process.

I recommend that you use the real-time interrupt to interrupt the running process at regular intervals, count down the number of interrupts remaining in the quantum, and, if needed, dispatch to a new process. See my week 9 day 2 notes for CS-280 for a review of the real-time interrupt. Refer to table 10-2 in the RM (page 385) for real-time interrupt timing information. Note that the RTI is not affected by the master timer prescaler even though it comes after it in the timing chain; the HC11 internally compensates the RTR to achieve this.

If you prefer, you may also use the timer overflow interrupt. Assume that your OS must run in normal mode and that you are not able to control the startup code that runs during the first 64 cycles, when any change to TMSK2:PR must be made.

Each process must have its own stack; the stack areas may be allocated statically (e.g., each of the process "slots" may have a fixed stack area associated with it).

Observe the behavior of the processes as you vary the quantum; by setting a large quantum value (e.g., 2-3 seconds), it should be possible to see the system "time slicing" from one process to the next.

Once the basic round-robin scheduling is working, add the following capabilities:

Note: Past experience has shown the importance of detailed analysis and good design. It is very easy to get lost in the assembly language coding if you have not carefully considered your data structures and function decomposition beforehand. My week 3 day 1 notes for CS-280 provide some hints on how to implement data structures in assembly language.

Three lab periods are allocated for this project. It is recommended that you use the GNU assembler and linker (You have the option of using an IDE, such as MGTEK or Tarantula.), the Wookie simulator, and the WBUG11 downloader/debugger. See my 68HC11 tools page for the core toolset. If you are not familiar with this software or the hardware, please ask the instructor for assistance. Keep in mind that there are significant differences between the Wookie environment and the physical hardware. Wookie does not simulate the Fox11’s LCD display or port layout. Also the default values for registers and memory and the memory map differ.

Milestones

References

Lab report (due by 11 P.M., the day before the week 7 lab)

Your lab report (one report per group) need not be self-contained. This means that it is not necessary to restate the entire specification in your report.


This lab was developed by Dr. Barnicki, Dr. Durant, Dr. Sebern, and Dr. Welch.