NOTE: this website is under construction for the new quarter. Please pardon our dust! The content of this website is subject to change as we put together resources for the new quarter. If you are a student who took the course last quarter, you should visit last quarter's class web site instead, accessible by visiting this link.
Below is a preview of the week-by-week plan for the quarter. There may be adjustments and rearrangements as we go.
Last updated: March 30, 2026.
-
Lecture videos are posted on Canvas under the "Panopto Course Videos" tab for enrolled students.
-
In the readings listed below, B&O is Computer Systems (Bryant and O'Hallaron), K&R is The C Programming Language (Kernighan and Ritchie) accessible here (requires free Open Library account to borrow), and Essential C is a PDF available at http://cslibrary.stanford.edu/101. B&O scanned PDFs for the listed readings are available on Canvas under the "Files" tab.
Lecture Code
Any code examples worked in class will be posted into /afs/ir/class/cs107/lecture-code/lect[N] where you replace [N] with the lecture number. You can make a copy to compile or modify by doing the following, which will make a folder in the current location called lect[N] that is a copy of the lect[N] code.
cp -r /afs/ir/class/cs107/lecture-code/lect[N] lect[N]
| Topics | Resources | Assignments |
|---|---|---|
| Week 1 | ||
|
Lecture 1 (Mon 3/30): Welcome to CS107!
We'll go through course logistics, learning goals, and a tour of Unix and the command line. |
Lecture Video
Handouts: Syllabus, Honor Code B&O Ch 1 - skim this chapter for a quick overview of what is meant by systems, and for a preview of topics to come. |
Out: assign0 |
|
Lecture 2 (Wed 4/1): Unix and C
We'll get started with the command line and introduce the C programming language. |
Lecture Video
|
No labs this week. |
|
Lecture 3 (Fri 4/3): Integers, Bits and Bytes
Topic 1: How can a computer represent integer numbers? We'll learn about the representation of the integer types: char, short, int, and long, in both unsigned and two's complement signed. We'll discuss binary, hexadecimal, integer arithmetic and overflow.
|
Lecture Video
B&O Ch 2.2-2.3 - skim the formal proofs, but it's important to take away a solid working knowledge of two's complement and behaviors of integer operations. |
|
| Week 2 | ||
|
Lecture 4 (Mon 4/6): Bitwise Operators
We'll wrap up integer representations by discussing truncation, sign extension and how mixed signed and unsigned comparison operations work. Then we'll see how to manipulate bits and bytes using bitwise operators. |
Lecture Video
B&O Ch 2.1 |
In: assign0 Out: assign1 |
|
Lecture 5 (Wed 4/8): More Bitwise Operators
We'll learn about the << >> shift operators and how to use GDB to examine the execution of our programs.
|
Lecture Video
|
Lab 1: Bits and intsBe sure to check out our guide to gdb. |
|
Lecture 6 (Fri 4/10): Chars and C-Strings
Topic 2: How can a computer represent and manipulate more complex data like text? We'll explore how strings and characters are manipulated in C using the char and char * types, discuss null termination, and become familiar with the string.h functions.
|
Lecture Video
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, so take note of the manual efforts required for correct use and pitfalls to avoid.
|
|
| Week 3 | ||
|
Lecture 7 (Mon 4/13): C-Strings, Buffer Overflows and Security
We'll learn more about string library functions, and discuss buffer overflows and techniques to avoid them. |
Lecture Video
|
|
|
Lecture 8 (Wed 4/15): C-Strings and Valgrind
We'll introduce the Valgrind memory analysis tool for spotting memory errors. Then we'll dig deeper into C strings and learn more about how C strings are represented in memory. |
Lecture Video
K&R Ch 1.6, 5.5 or Essential C section 3 on the mechanics of pointers and arrays. Pay special attention to the relationship between arrays and pointers and how pointers/arrays are passed as parameters. |
In: assign1 Out: assign2 |
Lab 2: C-Strings Be sure to check out our guide to Valgrind. |
|
Lecture 9 (Fri 4/17): Pointers and Arrays
Topic 3: How can we effectively manage all types of memory in our programs? We'll answer questions like: how are pointers useful in programs? How are arrays and pointers the same? How are they different? How is an array/pointer passed/returned in a function call? After this lecture, you'll understand how arrays and pointers allow two syntaxes for accessing sequential memory locations, but the underlying reality of the memory is the same. |
Lecture Video
K&R 5.2-5.5 or Essential C section 6 on advanced pointers |
|
| Week 4 | ||
|
Lecture 10 (Mon 4/20): Stack and Heap
We'll introduce dynamic allocation on the heap with malloc, compare the stack and the heap, and get practice using dynamic allocation.
|
Lecture Video
K&R 5.6-5.9 or Essential C section 6 on the heap. The key concept is comparing and contrasting stack and heap allocation. |
|
|
Lecture 11 (Wed 4/22): Stack and Heap, Continued
We'll continue discussing heap allocation, learn how to free memory with free, and talk about resizing heap allocations with realloc.
|
Lecture Video
|
In: assign2 Out: assign3 |
Lab 3: Arrays/Pointers |
Lecture 12 (Fri 4/24): Disclosure, Partiality, Generics and void *
Topic 4: How can we use our knowledge of memory and data representation to write code that works with any data type? We'll introduce untyped void * pointers and motivate C generics. We'll also discuss vulnerability disclosure, use-after-free bugs and partiality.
|
Lecture Video
|
|
| Week 5 | ||
|
Lecture 13 (Mon 4/27): More Generics and Function Pointers
We'll continue discussing generics and introduce function pointers, which allow us to pass functions as parameters and store them in variables. |
Lecture Video
K&R 5.11, review man pages or your C reference to be introduced to generic functions in the C library ( qsort, lfind, bsearch)
|
|
|
Lecture 14 (Wed 4/29): Function Pointers, Continued
We'll continue discussing generic function pointers and do examples of how to write and call functions with function parameters. |
Lecture Video
|
In: assign3 Out: assign4 |
Lab 4: void */Function Pointers |
|
Lecture 15 (Fri 5/1): Intro to x86-64, Data Movement
Topic 5: How does a computer interpret and execute C programs? We'll introduce assembly/machine language and find out what's happening underneath the hood of the C compiler, including a discussion of the x86-64 instruction set architecture and its powerful mov instruction, along with addressing modes, data layout, and access to variables of various types. |
Lecture Video
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 first "C" in CISC. Be sure to check out our x86-64 guide. |
|
| Week 6 | ||
|
Lecture 16 (Mon 5/4): x86-64 ALU
We'll talk about arithmetic and logical instructions. |
Lecture Video
B&O 3.5-3.6 Be sure to check out our x86-64 guide. |
(Tues) Midterm Exam 7-9PM |
|
Lecture 17 (Wed 5/6): More x86-64 ALU
We'll continue talking about arithmetic and logical instructions and do practice reverse engineering examples. |
Lecture Video
B&O 3.5-3.6 Be sure to check out our x86-64 guide. |
Lab 5: Assembly x86-64 in all its glory. Be sure to check out our x86-64 guide. |
|
Lecture 18 (Fri 5/8): x86-64 Condition Codes and Control Flow
We'll see how to implement C if/else in assembly.
|
Lecture Video
B&O 3.5-3.6 Be sure to check out our x86-64 guide. |
|
| Week 7 | ||
|
Lecture 19 (Mon 5/11): x86-64 Control Flow, Continued
We'll continue exploring loops and conditions in assembly and discuss other uses of condition codes ( setx/cmov).
|
Lecture Video
B&O 3.7, 5.1-5.6 Be sure to check out our x86-64 guide. |
|
|
Lecture 20 (Wed 5/13): x86-64 Runtime Stack
We'll talk about procedures and the runtime stack along with instructions for call/return, parameter passing, local stack storage, and register use. |
Lecture Video
|
In: assign4 Out: assign5 |
Lab 6: Runtime StackFun explorations with the stack! |
|
Lecture 21 (Fri 5/15): Reverse Engineering
We'll discuss assign5's focus on reverse engineering executables. We'll do lots of reverse engineering practice to get you up to speed on assign5! |
Lecture Video
Be sure to check out our x86-64 guide. |
|
| Week 8 | ||
|
Lecture 22 (Mon 5/18): Privacy, Trust and Managing the Heap
Topic 6: How do core memory-allocation operations like malloc and free work?We'll have larger discussions of privacy and trust, and then move on to our final main topic. We'll see how the heap fits into the address space and introduce design decisions for implementing malloc/realloc/free, as well as performance tradeoffs (throughput, utilization).
|
Lecture Video
B&O Ch. 9.9 and 9.11 cover heap allocation implementation and memory misuses. There's lots of very useful detail in 9.9 for your heap allocator! |
|
|
Lecture 23 (Wed 5/20): Managing the Heap, Continued
We'll learn about 3 different heap allocator designs: the bump allocator, the implicit free list allocator, and the explicit free list allocator, and compare them and discuss performance tradeoffs (throughput, utilization). |
Lecture Video
Optimally skim B&O Ch. 5 |
No labs this week. |
|
Lecture 24 (Fri 5/22): Explicit Free List Allocator
We'll learn more about the explicit free list allocator design, and other techniques employed by allocators including coalescing and in-place realloc. We'll also talk more about the requirements for assign6. |
Lecture Video
|
In (Sat): assign5 Out: assign6 |
| Week 9 | ||
| Mon 5/25 - No Lecture - Memorial Day | ||
|
Lecture 25 (Wed 5/27): Optimization
We'll explore the compilation process and the various optimizations GCC does on our behalf. We'll also learn of some tools we can use to profile our own code so we know where to optimize ourselves. This could be helpful for final tuning of your heap allocator! |
Lecture Video
|
Lab 7: Code and Memory Optimization Experiments in optimization and profiling. Be sure to check out our CS107 guide to callgrind. |
| Fri 5/29 - No Lecture - Off day | In: assign6 checkpoint | |
| Week 10 | ||
|
Lecture 26 (Mon 6/1): Wrap-up and Q&A
We'll wrap up the course themes, preview courses and opportunities post-107, and say some final words. Bring questions if you have them! |
Lecture Video
CS107 Recap Page |
|
| Wed 6/3 - No Lecture - Off day | In (Wed): assign6 | No labs this week. |
| Final Exam Week | ||
| Final Exam: Wednesday, June 10, 8:30AM-11:30AM PDT |