Calendar

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

  • Live lecture sessions are 11:30AM-1PM, NVIDIA Auditorium.

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 1/9): Welcome to CS107!
We'll go through course logistics, learning goals, and a tour of C programs.
Lecture 1 Slides
Lecture 1 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
No labs this week.
Lecture 2 (Fri 1/13): Integers and Bits
Topic 1: How can a computer represent integer numbers?
We'll learn more about the representation of the integer types: char, short, int, and long, in both unsigned and two's complement signed. We'll also discuss integer arithmetic, overflow, truncation and sign extension, and how mixed signed and unsigned comparison operations work. Finally, we'll dive further into bits and bytes and how to manipulate them using bitwise operators.
Lecture 2 Slides
Lecture 2 Code
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
(Mon 1/17) No Lecture (Martin Luther King's Birthday) In:assign0
Out:assign1
Lab 1: Bits and ints Be sure to check out our guide to gdb.
Lecture 3 (Fri 1/20): 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 3 Slides
Lecture 3 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.
Week 3
Lecture 4 (Mon 1/23): 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 4 Slides
Lecture 4 Code
K&R 5.2-5.5 or Essential C section 6 on advanced pointers
Lab 2: C-Strings Be sure to check out our guide to Valgrind. In (Wed): assign1
Out: assign2
Lecture 5 (Fri 1/26): Stack and Heap
We'll learn about stack allocation, stack frames, and parameter passing. Then, we'll introduce dynamic allocation on the heap (malloc/realloc/free), heap contractual guarantees and undefined behavior.
Lecture 5 Slides
Lecture 5 Code
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.
Week 4
Lecture 6 (Mon 1/30): void *, Generics
Topic 4: How can we use our knowledge of memory and data representation to write code that works with any data type?
We'll continue comparing and contrasting stack and heap allocation. Then, we'll move on to untyped void * pointers and motivate C generics.
Lecture 6 Slides
[Lecture 8 Code]
still working through K&R 5.6-5.9 or Essential C section 6 on the heap.
Lab 3: Arrays/Pointers In (Thur): assign2
Out (Wed): assign3
Lecture 7 (Fri 2/3): More Generics
We'll talk about function pointers, which allow us to implement generic operations using client callbacks.
Lecture 7 Slides
Lecture 7 Code
K&R 5.11, review man pages or your C reference to be introduced to generic functions in the C library (qsort, lfind, bsearch)
Week 5
Lecture 8 (Mon 2/6): Floating Point Numbers
We'll talk about floating point numbers, which is the way the computer holds and calcuates with numbers that are not integers.
Lecture 8 Slides
Lecture 8 Code
Lab 4: void */Function Pointers In (Wed): assign3
Out: assign4
Lecture 9 (Fri 2/10): 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. Then, we'll talk about addressing modes, data layout, and access to variables of various types.
Lecture 9 Slides-->
Lecture 9 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.
Week 6
Lecture 10 (Mon 2/13): x86-64 ALU
We'll talk about arithmetic and logical instructions.
Lecture 10 Slides
Lecture 10 Code
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. (Wednesday) Midterm Exam
Lecture 11 (Fri 2/17): x86-64 Condition Codes and Control Flow
We'll see how to implement C if/else and loops in assembly and discuss other uses of condition codes (setx/cmov).
Lecture 11 Slides
Lecture 11 Code
B&O 3.6
Be sure to check out our x86-64 guide.
Week 7
(Mon 2/20) - No Lecture (Presidents' Day)
Lab 6: Runtime Stack
Fun explorations with the stack!
In (Wed): assign4
Out (Wed): assign5
Lecture 12 (Fri 2/17): x86-64 Stack, recursion, arrays, structs
We will finish up assembly by talking about some more advanced topics
Lecture 12 Slides
Lecture 12 Code
B&O 3.6
Be sure to check out our x86-64 guide.
Week 8
Lecture 13 (Mon 2/27): Managing the Heap
Topic 6: How do core memory-allocation operations like malloc and free work?
We'll see how the heap fits into the address space. We'll introduce design decisions for implementing malloc/realloc/free, as well as performance tradeoffs (throughput, utilization). Then, we'll compare and contrast stack and heap allocation.
Lecture 13 Slides-->
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 14 (Fri 3/3): Managing the Heap 2
Topic 6: We'll review implicit heap allocators and dive deeper into explicit free list heap allocators.
Lecture 14 Slides
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!
In: assign5
Out: assign6
No labs this week.
Week 9
Lecture 15 (Mon 3/6): Optimization
We'll take a look at 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 15 Slides
Lecture 15 Code
Optimally skim B&O Ch. 5
Lab 7: Code and Memory Optimization
Experiments in optimization and profiling
Be sure to check out our CS107 guide to callgrind.
Lecture 16 (Fri 3/10): Guest lecture by Jerry Chen: Memory Safety Lecture 16 Slides
Week 10
Lecture 17 (Mon 3/13): Guest lecture by Christine Cheng and Jinang Shah: How do computer work? Lecture 17 Slides
No labs this week. In: assign6 (Wed)
Lecture 18 (Fri 3/17): 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 18 Slides
CS107 Recap Page -->
Week 10
Finals Week
Final Exam: Friday March 24, 8:30am-11:30am