Fall 2022 Course Overview

Class time: Tuesdays and Thursdays 4:10pm–5:25pm

Class location: 417 International Affairs Building (IAB)

Recitations:

  • Fridays 7pm–8:30pm in Mudd 524
  • Sundays 7pm–8:30pm in CSB 451
  • Mondays 7:15pm–8:45pm in Uris 301

Instructor: John Hui

Instructor office hours:

  • Tuesdays 5:30pm–7pm in CSB 488
  • Fridays 2pm–3:30pm in CSB 488
  • See also Office Hours

Exams

There will be three synchronous, in-person exams:

  • Oct 06 (Thursday), 4:10pm–5:25pm: Midterm #1
  • Nov 17 (Thursday), 4:10pm–5:25pm: Midterm #2
  • Dec 20 (Tuesday), 4:20pm–6:20pm: Final

All registered students must take the exams at those times. There are no make-up or alternate exams. If you cannot make any of those exams, please take the course next semester.

Labs

  • Lab 1 (80 points), due Sep 20 (Tuesday)
  • Lab 2 (101 points), due Oct 02 (Sunday)
  • Lab 3 (100 points), due Oct 16 (Sunday)
  • Lab 4 (100 points), due Oct 28 (Friday)
  • Lab 5 (80 points), due Nov 12 (Saturday)
  • Lab 6 (130 points), due Nov 28 (Monday) Nov 30 (Wednesday), hard deadline
  • Lab 7 (109 points), due Dec 12 (Monday)

Course Essentials

Course Schedule

Note: schedule for upcoming lectures are subject to change.

Lecture 1: Tuesday Sep 6

Course overview slides and lecture notes

  • Course overview, administrivia, and logistics
  • Introduction to command line

Lecture 2: Thursday Sep 8

Lecture notes

  • Review UNIX commands
  • Reading man pages
  • Version control with Git

Recitation 1: Weekend of Sep 9

Lecture 3: Tuesday Sep 13

Lecture notes

  • printf() debugging in C
  • Makefiles
  • Separate compilation

You can obtain a sample project built using Make on CLAC by running:

git clone ~j-hui/cs3157-pub/examples/myadd

Reading: K&R chapter 1

Lecture 4: Thursday Sep 15

Lecture notes

  • Storage classes and sizeof
  • Bits and binary

Reading: K&R chapters 2, 3, 4

Recitation 2: Weekend of Sep 16

Recitation notes

  • Review: Git, Make, C preprocessor, and header files

Lecture 5: Tuesday Sep 20

Lecture notes

  • Pointers and addresses
  • Stack allocation
  • Global variables and static allocation

Reading: K&R chapter 5

Lecture 6: Thursday Sep 22

Lecture notes

  • Heap allocation
  • malloc() and free()
  • Memory safety

Reading: K&R chapter 5

Recitation 3: Weekend of Sep 23

Recitation notes

  • Using bit operations
  • Understanding evaluation order
  • Debugging memory leaks and errors with Valgrind

Lecture 7: Tuesday Sep 27

Lecture notes

  • Pointer arithmetic
  • Arrays
  • Null-terminated arrays and strings

Reading: K&R chapter 5

Lecture 8: Thursday Sep 29

Lecture notes

  • Pointers to pointers
  • Structs
  • Function pointers

You can obtain sample code for a linked list of integers from CLAC:

git clone ~j-hui/cs3157-pub/examples/int-list

Reading: K&R chapter 6

Recitation 4: Weekend of Sep 30

Recitation notes

  • Address space layout
  • String and array operations

Midterm 1 Review: Tuesday Oct 4

Midterm 1: Thursday Oct 6

Recitation 5: Weekend of Oct 7

Recitation notes

  • Objects and methods in C
  • (Pascal) strings as objects

Lecture 9: Tuesday Oct 11

Lecture notes

  • Libraries and archives
  • Standard I/O (see lecture note 10)

You can obtain sample code for a basic numbers library from CLAC:

git clone ~j-hui/cs3157-pub/examples/libnumbers

Lecture 10: Thursday Oct 13

Lecture notes

  • Standard I/O vs file I/O
  • FILE pointers and file streams
  • (Textual) output and buffering

Reading: K&R chapter 7

See also: lecture note 11

You can obtain the source code for printf-test, scanf-test, and fprintf-test (featured in lecture note 10) from CLAC:

git clone ~j-hui/cs3157-pub/examples/stdio-tests

Recitation 6: Weekend of Oct 14

Recitation notes

  • Shell commands with pipes and redirection

Lecture 11: Tuesday Oct 18

Lecture notes

  • (Textual) input and blocking
  • EOF conditions
  • mdb demo

Reading: K&R chapter 7

You can obtain the demo code for output buffering from CLAC:

git clone ~j-hui/cs3157-pub/examples/output-buffering

You can obtain the source code for ncat from CLAC, in here:

git clone ~j-hui/cs3157-pub/examples/file-io-examples

Lecture 12: Thursday Oct 20

Lecture notes

  • File I/O with binary data
  • Endianness
  • File pointers vs file descriptors
  • Network stack

Reading: K&R chapter 8

See also: lecture note 11

Recitation 7: Weekend of Oct 21

Recitation notes

  • myhead
  • myarchive and myexpand

Lecture 13: Tuesday Oct 25

Lecture notes

  • TCP/IP networking
  • Client/server model
  • C sockets API

Reading:

Examples:

  • tcp-echo: a TCP client and server exchange some text with one another using file descriptors:

    git clone ~j-hui/cs3157-pub/examples/tcp-echo
    
  • tcp-ncat: implements the ncat (from file-io-examples) over a TCP connection using FILE pointers:

    git clone ~j-hui/cs3157-pub/examples/tcp-ncat
    

Lecture 14: Thursday Oct 27

Lecture notes

  • TCP/IP demos
  • Application layer networking
  • HTTP demo

Reading:

John’s CLAC homepage URL: http://clac.cs.columbia.edu/~j-hui/cs3157/

Recitation 8: Weekend of Oct 28

Recitation notes

  • TCP/IP networking in the shell using netcat

Lecture 15: Tuesday Nov 1

Lecture notes

  • HTTP/1.0
  • Dynamic web pages and multitier server architecture
  • UNIX permissions

You can find code for the sockaddr puzzle here:

git clone ~j-hui/cs3157-pub/examples/sockaddr-puzzle

Lecture 16: Thursday Nov 3

Lecture notes

  • Concurrency and process management
  • fork()

You can find examples demonstrating fork(), waitpid(), and exec() on CLAC, here:

git clone ~j-hui/cs3157-pub/examples/fork-exec-demos

Election Day Holiday: Tuesday Nov 8

Lecture 17: Thursday Nov 10

Lecture notes

  • waitpid()
  • exec()
  • Signals

You can find examples demonstrating sigaction() on CLAC, here:

git clone ~j-hui/cs3157-pub/examples/sigaction-demos

Recitation 9: Weekend of Nov 11

Recitation notes

  • TCP/IP networking with sockets

Midterm 2 Review: Tuesday Nov 15

Midterm 2: Thursday Nov 17

Recitation 10: Weekend of Nov 18

Recitation notes

  • Puzzle: Starfork
  • fork(), waitpid(), exec(), and signals

TA Chat: Tuesday Nov 22

Thanksgiving Holiday: Thursday Nov 24

Lecture 18: Tuesday Nov 29

Lecture notes

  • Demo: jsh
  • Memory allocation
  • Automatic memory management

You can find the code for the jsh demo on CLAC, here:

git clone ~j-hui/cs3157-pub/examples/cmdline

Lecture 19: Thursday Dec 1

Lecture notes

  • Demo: mdb-lookup-server and dynamic HTTP server
  • Compiler optimizations
  • Memory access latency
  • Performance and benchmarking

You can find the gtg-fast and list-vs-vector demos on CLAC, here:

git clone ~j-hui/cs3157-pub/examples/gtg-fast
git clone ~j-hui/cs3157-pub/examples/list-vs-vector

Recitation 11: Weekend of Dec 2

Recitation notes

  • Puzzle: Malgrind
  • Memory safety

Lecture 20: Tuesday Dec 6

Guest lecture: Andreas Kellas

  • Bugs, vulnerabilities, and exploits
  • Buffer overflows and return addresses
  • Modern computer security

Wrap-up: Thursday Dec 8

Epilogue slides

  • Final review
  • Course recap
  • Beyond 3157

Recitation 12: Weekend of Dec 9

Recitation notes

  • fork() + exec() puzzles

Additional Material

Cats:

  • FILE I/O
  • Strings
  • exec()

forkherd:

  • fork()
  • FILE I/O

Final exam: Tuesday Dec 20

4:20pm–6:20pm

Cumulative; topics covered:

  • Git, Make, and separate compilation
  • Bits, bytes, binary, and endianness
  • C types, expressions, statements, and functions
  • Pointers, arrays, structs, function pointers
  • Null bytes, NULL pointers, and null terminators
  • Heap allocation and memory safety in C
  • Standard file streams, file I/O with text vs binary data
  • Pipes and redirection in the shell
  • TCP/IP networking with netcat
  • TCP/IP networking with sockets and file streams
  • HTTP/1.0
  • UNIX process hierarchy and file permissions
  • fork(), waitpid(), and exec()