University of Waterloo

CS 452/652 - Real-time Programming


Fall 2019

Comp Sec Camp Loc Time Days/Date Bldg Room Instructor
LEC 001UW U09:30-10:20 MWFAL 105Martin 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

I will post my lecture notes 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.

AssignmentLink to AssignmentDue DateNotes
A0Polling LoopWed, Sep 11, 9:00amCommunication with Trains and Terminal
 Kernel Description Minimum Kernel Specification for K1-K4
K1Kernel (Part 1)Fri, Sep 27, 9:00amContext-Switch, Task Scheduling
K2Kernel (Part 2)Mon, Sep 30, 9:00amMessage Passing, Name Server
K3Kernel (Part 3)Mon, Oct 7, 9:00amEvent Notification, Clock Server
CSContext Switch PresentationMon, Oct 9 or 11In-class Presentations
K4Kernel (Part 4)Mon, Oct 21, 9:00amUART Servers
TC1Train Control (Part 1)Thu, Nov 7 (Demo), 9:00amControl one train
Final Project - ProposalFri, Nov 15, 9:00am 
TC2Train Control (Part 2)Thu, Nov 21 (Demo)Control multiple trains
Final ProjectTue, Dec 3 (Demo) 

Exams and Marking

Assignment A05%
Final Exam30%

The final exam is scheduled by the Registrar for Monday, Dec 16, 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, Dec 15, 9am. Download requires UW authentication.

UW Final Exam Regulations
Math Faculty INC Rules
If things go wrong...

Previous Exams

Different instructors emphasize different topics in various ways. Also, course material is continuously updated. With that in mind, previous exams are available in the hope that they will be useful, but WITHOUT ANY WARRANTY! 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 or drink. 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 (classic):/u/cs452/public/gnuarm-4.0.2/bin/arm-elf-gcc
new gcc version (less tested):/u/cs452/public/xdev/bin/arm-none-eabi-gcc
example code (see README):/u/cs452/public/iotest/




Providing Course Materials to Third-Party Organization

In short: Do not provide course material 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.