Below is a preview of the week-by-week plan for the quarter. There may be adjustments and rearrangements as we go.
-
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 videos are posted on Canvas under the "Panopto Course Videos" tab.
Lecture Code
Any code examples worked in class will be posted after lecture 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]
You can also view lecture code from your web browser by clicking here.
Topics | Readings | Assignments |
---|---|---|
Week 1 | ||
Lecture 1 (Mon 6/26): Welcome to CS107! We'll go through course logistics and learning goals, then dive into some Unix and C. |
Lecture 1 Slides Lecture 2 Code 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 6/28): Integer Representations and Bits / Bytes 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 integer arithmetic, overflow, truncation and sign extension, and how mixed signed and unsigned comparison operations work. |
Lecture 2 Slides | No labs this week. |
Lecture 3 (Fri 6/30): Bits, Bytes, and Bitwise Operators We'll see how to manipulates bits and bytes using bitwise operators. We'll also learn about << and >> shift operators and how to use GDB! |
Lecture 3 Slides | In: assign0 Out: assign1 |
Week 2 | ||
Lecture 4 (Mon 7/3): 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 4 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, so take note of the manual efforts required for correct use and pitfalls to avoid. |
|
Lecture 5 (Wed 7/5): C-Strings, Pointers, and Arrays We'll review a little bit of what we went over on Monday! Then we'll dig deeper into C strings and learn more about how C strings are examples of arrays and pointers. |
Lecture 5 Slides Lecture 5 Code 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. |
Labs start this week |
Lab 1: Bits and ints |
Be sure to check out our guide to gdb. | |
Lecture 6 (Fri 7/7): Arrays and Pointers Topic 3: How can we effectively manage all types of memory in our programs? We'll answer questions like: 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 6 Slides Lecture 6 Code K&R 5.2-5.5 or Essential C section 6 on advanced pointers |
|
Week 3 | ||
Lecture 7 (Mon 7/10): The Stack & Heap We'll introduce dynamic allocation on the heap with malloc and free and compare the stack and the heap. |
Lecture 7 Slides | |
Lab 2: C-Strings | Be sure to check out our guide to Valgrind. | |
Lecture 8 (Wed 7/12): Generics and void * 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. |
Lecture 8 Slides Lecture 8 Code |
|
Lecture 9 (Fri 7/14): Function Pointers Topic 3: How can we make logic generic ? We'll examine how function pointers allow us to pass logic as a parameter and store it in a variable. |
Lecture 9 Slides | |
Week 4 | ||
Lecture 10 (Fri 7/17): 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 15 Slides Lecture 10 Code 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. |
|
Lab 3: Arrays/Pointers | ||
Lecture 11 (Wed 7/19): x86-64 ALU We'll talk about arithmetic and logical instructions, and some control flow! |
Lecture 11 Slides B&O 3.5-3.6 Be sure to check out our x86-64 guide. |
|
Lecture 12 (Fri 7/21): x86-64 Condition Codes and Control Flow We'll see how to implement C if /else and loops in assembly. |
Lecture 12 Slides Lecture 12 Code B&O 3.6 Be sure to check out our x86-64 guide. |
|
Week 5 | ||
Lecture 13 (Mon 7/24): x86-64 Assembly Continued We'll continue learning more about assembly. |
Lecture 13 Slides B&O 3.6 Be sure to check out our x86-64 guide. |
|
Lecture 14 (Wed 7/26): Assembly & Optimization Beyond translation, how do compilers enhance our programs? |
Lecture 14 Slides B&O 3.6 Be sure to check out our x86-64 guide. |
|
Lecture 15 (Fri 7/28): Accessing the Architecture: An Introduction to Computer Architecture Examining the layers of translation and interpretation that power our programs and the architecture that runs it. |
Lecture 15 Slides | |
Week 6 | ||
Lecture 16 (Mon 7/30): Reverse Engineering Privacy, Trust and Managing the Heap We'll discuss assign5's focus on reverse engineering executables. We'll practice on a small vault to get you ready to handle the real deal! We'll then 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 16 Slides Lecture 16 Code Be sure to check out our x86-64 guide. |
|
Lecture 17 (Wed 8/02): Heap Allocators We'll continue our discussion from Monday and talk about tradeoffs we need to consider when thinking of different design implementations for Heap Allocators. We'll introduce a straight forward Bump Allocator and then talk about more complicated designs, implicit and explicit allocators. |
Lecture 17 Slides |
|
Lecture 18 (Fri 8/04): Heap Allocators II We'll continue we left off on wednesday and introduce the explicit allocator and talk about coalescing and in-place realloc . |
Lecture 18 Slides |