Calendar

Below is a preview of the week-by-week plan for the quarter. There may be adjustments and rearrangements as we go.

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
Week 1
Lecture 1 (Mon 6/24): Welcome to CS107!
We'll go through course logistics, learning goals, and a tour of Unix and the command line.
Lecture 1 Slides
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.
Lecture 2 (Wed 6/26): 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 2 Slides
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.
Lecture 3 (Fri 6/28): Bitwise Operators

We'll learn about the << >> shift operators and how to use GDB to examine the execution of our programs.
Lecture 3 Slides
Lecture 3 Code
Week 2
Lecture 4 (Mon 7/1): 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
Lecture 4 Code
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/3): 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.
Lab 2: C-Strings Be sure to check out our guides! guide to Valgrind, guide to gdb.
Lecture 6 (Fri 7/5): 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
K&R 5.2-5.5 or Essential C section 6 on advanced pointers
Week 3
Lecture 7 (Mon 7/8): 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
Lecture 8 (Wed 7/10): C Strings, Valgrind and Pointers
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 examples of arrays and pointers.
Lecture 8 Slides
Lecture 8 Code
Lecture 9 (Fri 7/12): Function Pointers
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 9 Slides
Week 4
Lecture (Mon 7/15): Midterm Review Session
Lecture (Wed 7/17): Midterm
Lecture 10 (Fri 7/19): Intro to Assembly
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 10 Slides
Week 5
Lecture 11 (Mon 7/22): Arithmetic & Logic Operations
We'll be talking about arithmetic and logical instructions and do practice reverse engineering examples.
Lecture 11 Slides
Lecture 12 (Wed 7/24): Control Flow & Condition Codes
We'll see how to implement C if/else and loops in assembly.
Lecture 12 Slides
Lecture 13 (Fri 7/26): Control Flow & Condition Codes
We'll continue learning more about assembly.
Lecture 13 Slides
Week 6
Lecture 14 (Mon 7/29): Alignment, Optimization, & Basic Architecture
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 14 Slides
Lecture 15 (Wed 7/31): Privacy+Trust & 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 15 Slides
Lecture 16 (Fri 8/2): Managing the Heap, Contd
We'll continue to discuss heap setup and operations and the performance tradeoffs (throughput, utilization) from different design choices.
Lecture 16 Slides
Week 7
Lecture 17 (Mon 8/5): 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 17 Slides
Lecture 18 (Wed 8/7): Sockets
Topic 7: How can we perform network interactions via C programs?
We'll introduce the basics of networking and socket operations.
Lecture 18 Slides