Below is a preview of the week-by-week plan for the quarter. There may be adjustments and rearrangements as we go. Exam dates are set at quarter start and will not change.

In the readings listed below, B&O is Computer Systems (Bryant and O'Hallaron), K&R is The C Programming Language (Kernighan and Ritchie), and EssentialC is a PDF available at Do the readings before lecture for best effect!

Any code examples worked in class will be posted after lecture into /afs/ir/class/cs107/samples/lectN where N is the lecture number.

SCPD posts lecture recordings a few hours after live capture on

Topics Readings
Week 1
Lecture 1 (Mon): Welcome
Intro to CS107. We'll go through course logistics, learning goals, a tour of some surprising realities about modern systems
Handouts: Course Info, Lecture slides
B&O Ch 1 (skim chapter for quick overview of what is meant by systems and preview of topics to come)
Why C still runs the world
Why every programmer should learn C
(Just for fun) Systems programmers and zombies
No lab during first week
Lecture 2 (Fri): Bits and bitwise operators
Bits and bytes, bitwise operators, integer family types
Lecture slides
B&O Ch 2.1
Week 2
Lecture 3 (Mon): Integers
Representation of the integer types: char, short, int, long in both unsigned and two's complement signed. Integer arithmetic, overflow. Truncation and sign extension. Mixed signed and unsigned comparison operations.
Lecture slides
B&O Ch 2.2-2.3 (skim the formal proofs, but important to take away solid working knowledge of two's complement and behaviors of integer operations).
Lab 1: Bits and ints Lab 1 writeup
Our guide to gdb
Unixref gdb video
Lecture 4 (Fri): Chars and C-strings
char and char *, null termination, string.h functions
Lecture slides
K&R (1.9, 5.5, Appendix B3) or Essential C section 3 for C-strings and string.h library functions. C-strings are primitive compared to Java/C++ strings, take note of the manual efforts required for correct use and pitfalls to avoid. Lecture code posted at /afs/ir/class/cs107/samples/lect4/code.c
Week 3
Lecture 5 (Mon): More C-strings
Now it's time to start digging into the tricky parts of C, including use of * and &, pointer operations/arithmetic, memory diagrams. In lecture, we will trace through code, draw lots of pictures, poke around in gdb.
Lecture slides
K&R Ch 1.6, 5.5 or Essential C section 3 on mechanics of pointers and arrays. Pay special attention to the relationship between arrays and pointers and how pointers/arrays are passed as parameters. Lecture code posted at /afs/ir/class/cs107/samples/lect5/.
Lab 2: C-strings Lab 2 writeup
Our guide to Valgrind
Lecture 6 (Fri): Arrays and pointers
How are arrays and pointers the same? How are they different? How is an array/pointer passed/returned in a function call? A key takeaway is how arrays and pointers allow two syntaxes for accessing sequential memory locations but the underlying reality of the memory is the same.
Lecture slides
K&R 5.2-5.5 or Essential C section 6 on advanced pointers
Lecture code posted at /afs/ir/class/cs107/samples/lect6/.
Week 4
Lecture 7 (Mon): Stack and heap
Stack allocation, stack frames, parameter passing. One thorny issue to work through is pointers to pointers. Introduce dynamic allocation (malloc/realloc/free). Heap contractual guarantees and undefined behavior.
Lecture slides
K&R 5.6-5.9 or Essential C section 6 on heap. Key concept is compare/contrast stack to heap allocation.
Lecture code posted at /afs/ir/class/cs107/samples/lect7/.
Lab 3: Arrays/pointers Lab 3 writeup
Lecture 8 (Fri): Void *, generics
Compare/contrast stack and heap allocation. Untyped void* pointers, motivation for C generics.
Lecture slides
Lecture code posted at /afs/ir/class/cs107/samples/lect8/.
Week 5
Lecture 9 (Mon): Generics, C wrap
Function pointers. Client callbacks used to implement generic operations.
Lecture slides
K&R 5.11, review man pages or your C reference to be introduced to generic functions in C library (qsort, lfind, bsearch)
Lecture code posted at /afs/ir/class/cs107/samples/lect9/
Lab 4: Void*/function pointers Lab 4 writeup
Lecture 10 (Fri): Floating point
Manipulating real-value data types (float/double) using IEEE floating point representation. Explore features/limitations of the floating point number line.
Lecture slides
B&O 2.4 on floats (ok to skim the details on exactly which bits go where, instead focus on which values are representable and why)
Lecture code posted at /afs/ir/class/cs107/samples/lect10/
Week 6
Lecture 11 (Mon): Intro to x86-64, data movement
Representation of pointers, structs, instructions. Introduce assembly/machine language and find out what's happening underneath the hood of the C compiler. The x86-64 instruction set architecture and its almighty mov instruction. Addressing modes, data layout, and access to variables of various types.
Lecture slides
B&O 3.1-3.3 for background info on x86-64 assembly. Very carefully read B&O 3.4 on addressing modes and data transfer. The multitude of addressing modes is one of the things that puts the C in CISC.
Our x86-64 guide
Lab 5: Floats
Hands-on float dissection
Lab 5 writeup
MIDTERM in-class
Friday May 11th, 12:30-1:50pm
See exams page for more information.
Week 7
Lecture 12 (Mon): x86-64 ALU and condition codes
Arithmetic and logical instructions; condition codes, cmp/test and jmp/jx instructions;
Lecture slides
B&O 3.5-3.6
Our x86-64 guide
Lecture code posted at /afs/ir/class/cs107/samples/lect12/
Lab 6: Assembly
x86-64 in all its glory
Lab 6 writeup
Our x86-64 guide
Lecture 13 (Fri): x86-64 control flow
implementing C if/else and loops in assembly, other use of condition codes (setx/cmov), procedures, runtime stack
Lecture slides
B&O 3.6
Our x86-64 guide
Lecture code posted at /afs/ir/class/cs107/samples/lect13/
Week 8
Lecture 14 (Mon): x86-64 runtime stack
Instructions for call/return, parameter passing, local stack storage, register use. Optimizing compiler transformations to reduce instruction/cycle count
Lecture slides
B&O 3.7, 5.1-5.6
Lecture code posted at /afs/ir/class/cs107/samples/lect14/
Lab 7: Runtime stack
Fun explorations with the stack!
Lab 7 writeup
Lecture 15 (Fri): Managing the heap
How the heap fits into the address space. Design decisions for implementing malloc/realloc/free. Performance tradeoffs (throughput, utilization). Compare/contrast stack versus heap allocation.
Lecture slides
B&O Ch. 9.9-9.11 covers heap allocation implementation, garbage collectors, and memory misuses. Lots of very useful detail in 9.9 for the heap allocator assignment!
Week 9
No Monday lecture, Memorial Day
Lab 8: Code and memory optimization
Experiments in optimization and profiling
CS107 guide to callgrind
Lab 8 writeup
Lecture 16: (Fri) Learning from real world software
Free and open software, how to further your coding education by reading, analyzing, contributing within the FOSS community
Lecture slides
Week 10
Lecture 17 (Mon): Wrap Wrap up course themes, preview courses/opportunities post-107, and try to reach closure on any loose ends. Bring questions if you have them!
Labs do not meet this week
No Friday lecture
Week 11
Wednesday June 13th, 12:15-3:15pm
See exams page for coverage, logistics, practice problems