University of Waterloo

CS 452/652 - Real-time Programming

     I hear the train a comin'
     It's rollin' 'round the bend
     And I ain't seen the sunshine
     Since I don't know when...

     Johnny Cash

Winter 2020

Comp Sec Camp Loc Time Days/Date Bldg Room Instructor
LEC 001UW U10:30-11:20 MWFMC 4045Martin Karsten

Instructor's Name Office Location Contact Office Hours
Martin Karsten DC 3506 open door / by appointment

Registrar's Schedule of Classes

Teaching Assistants

Course Overview

The course presents tools and techniques for real-time programming, including system support for real-time applications and calibrating interfaces to hardware. One part of the course is writing a small, real-time-capable operating system that runs on stand-alone computers and provides a low-level interface to control electric trains. The other part is concerned with implementing a control application for the trains.

Course Objectives

At the end of the course, successful students will be able to:
  1. program low level system services in assembly language,
  2. program hardware interfaces in C/C++,
  3. develop a multi-tasking runtime kernel providing message passing,
  4. develop a multi-task application based on message passing, and
  5. develop a calibrated control application for external hardware.


Piazza is used as the primary communication channel for announcements, clarifications, questions, discussions, etc. It is expected that all students are familiar with all material posted and discussed on Piazza. There are different Q&A folders for (more might be added as needed):

For any personal matters, please email the instructor.

Lecture Notes

Lecture notes will be posted here after class. They are telegraphic, so they are not a substitute for the lectures. But if you attend the lecture they will most likely be a good memory prosthetic.


IMPORTANT: Late assignment submissions will not be accepted. Plagiarism detection software will be used. See below for further information about academic integrity and appeals. Also see Notes on Assignments.

Due dates below are tenative until the assignment is published.

AssignmentLink to AssignmentDue DateNotes
A0Polling LoopMon, Jan 13, 10:00amCommunication with Trains and Terminal
 Kernel Description Minimum Kernel Specification for K1-K4
K1Kernel (Part 1)Mon, Jan 27, 10:00amContext-Switch, Task Scheduling
K2Kernel (Part 2)Fri, Jan 31, 10:00amMessage Passing, Name Server
K3Kernel (Part 3)Mon, Feb 10, 10:00amEvent Notification, Clock Server
CSContext Switch PresentationTue, Feb 11, 5:00pmIn-Class Presentations on Feb 12 and 14
K4Kernel (Part 4)Mon, Feb 24, 10:00amUART Server(s)
TC1Train Control (Part 1)Mon, Mar 9, 10:00amDemo: control one train
Final Project - ProposalMon, Mar 16, 10:00amcancelled
TC2Train Control (Part 2)Mon, Mar 23, 10:00amcancelled Demo: control multiple trains
Final ProjectFri, Apr 3, 10:00amcancelled Demo

Exams and Marking

Final Exam30%

UPDATE: The marking scheme has been modified to only take into account the components that were completed before the suspension of classes due to COVID-19: A0, Kernel, TC1.

The final exam is scheduled by the Registrar for Monday, Apr 13, 9am - 11:30am. It will cover material from the entire course. The final exam will be given as take-home exam. 24 hours before the registrar-scheduled start time. Exam answers have to be submitted by email to the instructor at the scheduled end time (i.e., after 26.5 hours).

The final exam will be made available at this link on Sunday, Apr 12, 9am. Download requires UW authentication.



The lab room is MC 3018. The lab is for the exclusive use of CS452 students. The access code is announced in class. Do not give the code to other students! The usual rules apply, such as no food - and drinks only in sealable containers. Please see CSCF Teaching Lab Policies for details.

The workstations in the main room run Ubuntu Linux with access to the regular linux.student.cs environment. The workstations in the inner room run a slightly different Linux setup with a default login and are connected to grey boxes that contain the embedded ARM computers. Two of those are connected to train tracks. You can use the gtkterm terminal emulator to communicate with the ARM computer via serial interface.

ARM Computer

The ARM computer in the grey box is a TS-7200 single-board computer based on the EP9302 system-on-a-chip (SoC) that uses an ARM 920T processor. The processor implements ARM architecture version ARMv4T. The most relevant manuals are provided here: Additional documentation for reference:

Train Set

The track and trains are controlled by sending commands via the serial interface.


cross compiler:/u/cs452/public/xdev/bin/arm-none-eabi-gcc
example code:/u/cs452/public/iotest/ (see README)




Providing Course Materials to Third-Party Organization

In short: Do not provide course materials to third-party organizations. See
these guidelines for details.

Academic Integrity

In order to maintain a culture of academic integrity, members of the University of Waterloo community are expected to promote honesty, trust, fairness, respect and responsibility. Check the Office of Academic Integrity's website for more information.

All members of the UW community are expected to hold to the highest standard of academic integrity in their studies, teaching, and research. This site explains why academic integrity is important and how students can avoid academic misconduct. It also identifies resources available on campus for students and faculty to help achieve academic integrity in — and out — of the classroom.


A student who believes that a decision affecting some aspect of his/her university life has been unfair or unreasonable may have grounds for initiating a grievance. Read Policy 70 — Student Petitions and Grievances, Section 4. When in doubt please be certain to contact the department's administrative assistant who will provide further assistance.


A student is expected to know what constitutes academic integrity, to avoid committing academic offenses, and to take responsibility for his/her actions. A student who is unsure whether an action constitutes an offense, or who needs help in learning how to avoid offenses (e.g., plagiarism, cheating) or about "rules" for group work/collaboration should seek guidance from the course professor, academic advisor, or the Undergraduate Associate Dean. For information on categories of offenses and types of penalties, students should refer to Policy 71 — Student Discipline. For typical penalties, check Guidelines for the Assessment of Penalties.

Avoiding Academic Offenses

Most students are unaware of the line between acceptable and unacceptable academic behaviour, especially when discussing assignments with classmates and using the work of other students. For information on commonly misunderstood academic offenses and how to avoid them, students should refer to the Faculty of Mathematics Cheating and Student Academic Discipline Policy.


A decision made or a penalty imposed under Policy 70, Student Petitions and Grievances (other than a petition) or Policy 71, Student Discipline may be appealed if there is a ground. A student who believes he/she has a ground for an appeal should refer to Policy 72 — Student Appeals.

Note for Students With Disabilities

AccessAbility Services (formerly the Office for Persons with Disabilities or OPD), located in Needles Hall, Room 1132, collaborates with all academic departments to arrange appropriate accommodations for students with disabilities without compromising the academic integrity of the curriculum. If you require academic accommodations to lessen the impact of your disability, please register with the OPD at the beginning of each academic term.