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

Spring 2022

Important Note for Students Not Enrolled Yet

Comp Sec Camp Loc Time Days/Date Bldg Room Instructor
LEC 001UW U10:00-11:20 TThMC 4060Martin 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 second part is concerned with building 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.


If a student needs to self-isolate due to COVID protocols, individual adjustments will be made to assignment deadlines and/or weighting depending on the particular circumstances.

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 lectures they will most likely be a good memory prosthetic.


Assignment A0 is to be completed independently by each student. Afterwards, groups of 2 students (or 3 in exceptional circumstances) work on the remaining assignments.

IMPORTANT: Late assignment submissions will not be accepted. Plagiarism detection software will be used. Students might be asked to meet with TAs and explain their code. See below for further information about academic integrity and appeals. Also see Notes on Assignments.

Due dates below are tentative until the assignment is published.

AssignmentLink to AssignmentDue DateNotes
A0Polling LoopTue, May 10, 9:00amCommunication with Trains and Terminal
K1Kernel (Part 1)Tue, May 24, 9:00amContext-Switch, Task Scheduling
K2Kernel (Part 2)Tue, May 31, 9:00amMessage Passing, Name Server
K3Kernel (Part 3)Tue, Jun 7, 9:00amEvent Notification, Clock Server
Kernel Context SwitchThu, Jun 9, 9:00amIn-Class Presentations on Jun 9 (Jun 14)
K4Kernel (Part 4)Thu, Jun 16, 9:00amUART Server(s)
TC0Train Control (prep)Thu, Jun 16, 9:00ampreliminary speed calibration (same due date as K4)
TC1Train Control (Part 1)Thu, Jun 30, 9:00amDemo: control one train
Final Project - ProposalThu, Jul 7, 9:00amsubmitted for feedback, but not graded
TC2Train Control (Part 2)Thu, Jul 14, 9:00amDemo: control multiple trains
Final ProjectTue, Jul 26, 9:00amDemo

Exams and Marking

Final Exam30%

The final exam is scheduled by the Registrar for Friday, Aug 5, 4pm - 6:30pm. 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 on Learn on Thursday, Aug 4, 4pm.

UW Final Exam Regulations
Math Faculty INC Rules



The lab room is MC 3018. The lab is for the exclusive use of CS 452/652 students. The access code is announced in class. Do not give the code to other students! The usual rules apply, such as no food. 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 for more information.]


A student who believes that a decision affecting some aspect of their 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 an academic offence, and to take responsibility for their actions. [Check the Office of Academic Integrity for more information.] A student who is unsure whether an action constitutes an offence, or who needs help in learning how to avoid offences (e.g., plagiarism, cheating) or about "rules" for group work/collaboration should seek guidance from the course instructor, academic advisor, or the undergraduate associate dean. For information on categories of offences and types of penalties, students should refer to Policy 71, Student Discipline. For typical penalties, check Guidelines for the Assessment of Penalties.


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 they have a ground for an appeal should refer to Policy 72, Student Appeals.

Note for Students With Disabilities

AccessAbility Services located in Needles Hall, Room 1401, 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 AccessAbility Services at the beginning of each academic term.

Text matching software (Turnitin©) may be used to screen assignments in this course. Turnitin© is used to verify that all materials and sources in assignments are documented. Students' submissions are stored on a U.S. server, therefore students must be given an alternative (e.g., scaffolded assignment or annotated bibliography), if they are concerned about their privacy and/or security. Students will be given due notice, in the first week of the term and/or at the time assignment details are provided, about arrangements and alternatives for the use of Turnitin in this course.

It is the responsibility of the student to notify the instructor if they, in the first week of term or at the time assignment details are provided, wish to submit alternate assignment.