ECEC 201 · Week 10

Modern Computer: Von Neumann

The demo is one C program: each button press logs one decoded register reading to a file.

Week 10 of 10 · Das Frite

ECEC 201 · Week 10 · In class

The demo is one C program: each button press logs one decoded register reading to a file.

ECEC 201 · Week 10 · In class

Each partner answers one question about their own code.

ECEC 201 · Week 10 · Lecture

One loop, three jobs

for (;;) {
	if (!wait_for_press(line_fd))       /* week 9 */
		break;
	int raw = read_reg(dev, addr, reg); /* week 8 */
	if (raw < 0)
		continue;                       /* log the failure? */
	log_reading(log_fd, raw);           /* week 7 */
}

ECEC 201 · Week 10 · Lecture

Who owns what

ResourceAcquired byReleased by
Heap blockmallocfree, once
File descriptoropenclose
GPIO linethe line requestclose on its descriptor

Write each release on the path out, including the error paths.

ECEC 201 · Week 10 · Lecture

Clean under valgrind

ECEC 201 · Week 10 · Lecture

Freeze the demo

ECEC 201 · Week 10 · Lab

Lab

  1. Demonstrate the project: each button press logs one decoded register reading to a file.
  2. Each partner answers one question about pointers or memory in their own code. Second pass: run the demo under valgrind and show no leaks.
  3. Assemble the lab hand-in: The demo, the repository with its `Makefile`, and the valgrind summary.

ECEC 201 · Week 10 · Lab

Hand in

The demo, the repository with its `Makefile`, and the valgrind summary.

ECEC 201 · Week 10 · Homework

Homework

ECEC 201 · Week 10 · Homework

Turn in

The two questions and the two answers.

ECEC 201 · Week 10 · Read

Read

On the lab site: Module 12, A whole system, is a full product. This week grades one C program that joins a register and a button.

Arrow keys or space to move, F for full screen, N for speaker notes, Home and End for the first and last slide. Print gives one slide per page.