Course Information

About

This course gives a solid understanding of the principles and abstractions used in computer systems and machine programs using C. Towards this aim, it covers a broad range of topics, providing students with an in-depth perspective and programming experience regarding the basic topics of C language and how programs are formed and executed at the microprocessor-level.

Upon the completion of COMP201, student will be able to (1) demonstrate proficiency in writing C programs that require effective memory management, (2) gain a deep knowledge of the compilation flow and runtime behavior of C programs, (3) have a clear understanding of computer arithmetic in a modern computing system, (4) recognize the relationship between a C program and its assembly translation, and (5) gain a general sense of working in a Unix environment as a power user, getting familiar with shell tools, version control systems, compilers, debuggers, profilers.

The course is taught by Aykut Erdem, Mert Cokelek, Samet Demir, Nafiseh Jabbari Tofighi, Pinar Erbil, Doga Ege Inhanli, Irem Karaca, Omer Faruk Tal, and Ahmet Uyar.

                                           
                                   

Time and Location

Lectures: Monday, Wednesday at 10:00-11:10 (SOS B07)
Labs: Friday at 16:00-17:40 (Lab A), 12:00-13:40 (Lab B)
Office Hours Tuesday 11:00-12:00 (Aykut)

Reference Books

Policies: All work on assignments must be done individually unless stated otherwise. You are encouraged to discuss with your classmates about the given assignments, but these discussions should be carried out in an abstract way. That is, discussions related to a particular solution to a specific problem (either in actual code or in the pseudocode) will not be tolerated.

In short, turning in someone else’s work, in whole or in part, as your own will be considered as a violation of academic integrity. Please note that the former condition also holds for the material found on the web as everything on the web has been written by someone else.

Communication

The course webpage will be updated regularly throughout the semester with lecture notes, presentations, assignments and important deadlines. All other course related communications will be carried out through Blackboard.

Pre-requisites

COMP201 is open to second-year undergraduate students. Non-COMP students should ask the course instructor for approval before the add/drop period. The prerequisites for this course is COMP 132 - Advanced Programming.

Course Requirements and Grading

Grading will be based on

Schedule

Date Topic Notes
Feb 14 Introduction. Course logistics, A tour of C programs (slides) (video spring'22) (video spring'21) (code) B&O 1

Additional Reading:
The Strange Birth and Long Life of Unix, Warren Toomey, IEEE Spectrum, 28 Nov 2011
“A damn stupid thing to do”—the origins of C, Arstechnica
Feb 16 Bits and Bytes, Representing and Operating on Integers (slides) (video spring'22) (video spring'21) (code)
Assg0 out: Getting Started with Unix and C
B&O 2.2-2.3

Additional Readings:
Feb 18 Bootcamp: Programming with C and Git basics (slides) (video)
Feb 21 Bits and Bitwise Operators (slides) (video spring'22) (video spring'21) (code) B&O 2.1
Feb 23 Floating point (slides) (video spring'22) (video spring'21) (code)
Assg0 in, Assg1 out: Manipulating Bits
B&O 2.4
Additional Reading: What Every Computer Scientist Should Know About Floating-Point Arithmetic, David Goldberg, ACM Computing Surveys, 23(1), 1991

Demos:
Feb 25 Lab 1: The Linux Shell (slides) MIT MS The Shell
Stanford CS107 Unix videos 1-15, 24, 25
Feb 28 Chars and Strings in C (slides) (video spring'22) (video spring'21) (code) K&R 1.9, 5.5, Appx B3
Mar 2 More Strings, Pointers (slides) (video spring'22) (video spring'21) (code) K&R 1.6, 5.5, Essential C 3 (strings and string.h library functions, The mechanics of pointers and arrays)
Mar 4 Lab 2: Bits, Ints and Floats, Vim (slides) MIT MS Editors (Vim)
Stanford CS107 Unix videos 28
Mar 7 Arrays and Pointers (slides) (video spring'22) (video spring'21) (code) K&R 5.2-5.5, Essential C 6 (Advanced pointers)
Mar 9 The Stack and The Heap (slides) (video spring'22) (video spring'21)
Assg1 in, Assg2 out: Strings in C
K&R 5.6-5.9, Essential C 6 (The heap)
Mar 11 No lab this week -- Canceled due to snow
Mar 14 Realloc, Memory Bugs (slides) (video spring'22) (code) K&R 5.6-5.9, Essential C 6 (The Heap)
Mar 16 void *, Generics (slides) (video spring'22) (video spring'21) (code) K&R 5.6-5.9, Essential C 6 (The Heap)
Mar 18 Lab 3: C-Strings and Valgrind (slides) Stanford CS107 Unix videos 26
Mar 21 Function Pointers (slides) (video spring'22) (video spring'21) (code) K&R 5.11
Mar 23 const, Structures (slides) (video spring'22) (video spring'21) (code)
Assg2 in, Assg3 out: Heap Management
K&R 6.1-6.7
Mar 25 Lab 4: Arrays/Pointers and GDB (slides) Stanford CS107 Unix videos 27
Harvard CS50 short on GDB
Mar 28 Compiling C programs (slides) (video spring'22) (video spring'21) (code) Stanford Unix Programming Tools 1
Mar 30 Introduction to x86-64, Data Movement (slides) (video spring'22) (video spring'21)(code) B&O 3.1-3.4

Additional reading:
Apr 1 Lab 5: Working with multiple files, writing your own Makefiles (slides)
Apr 4 Arithmetic and Logic Operations (slides) (video spring'22) (video spring'21) B&O 3.5-3.6
Apr 6 x86-64 Control Flow (slides) (video spring'22) (video spring'21)
Assg3 in, Assg4 out: Defusing a Binary Bomb
B&O 3.6.1-3.6.2
Apr 8 Lab 6: Machine Programming with Assembly (slides)
Apr 11 No class - Spring break
Apr 13 No class - Spring break
Apr 15 No lab this week - Spring break
Apr 18 More Control Flow (slides) (video spring'22) (video spring'21) B&O 3.6.3-3.6.8
Apr 20 x86-64 Procedures (slides) (video spring'22) (video spring'21) (code) B&O 3.7
Apr 22 No lab this week
Apr 25 Data and Stack Frames (slides) (video spring'22) (video spring'21) B&O 3.8-3.9
Apr 27 Security Vulnerabilities (slides) (video spring'22) (video spring'21) (code)
Assg4 in Buffer Overflow Attacks
B&O 3.10
Additional Reading: Smashing the Stack for Fun and Profit, Aleph One
Apr 29 No labs this week
Apr 30 Midterm Exam (Midterm Exam Guide)
May 2 No class - Ramadan feast (holiday)
May 4 No class - Ramadan feast (holiday)
May 6 No lab this week
May 9 The Memory Hierarchy (slides) (video spring'22) (video spring'21) B&O 6.1-6.3
May 11 Cache Memories (slides) (video spring'22) (video spring'21)
Assg5 out
B&O 6.4-6.7
Demos:
Cache Simulator
May 13 Lab 7: Runtime Stack (slides)
May 16 More Cache Memories (slides) (video spring'22) B&O 6.4-6.7
May 18 Optimization (slides) (video spring'22) (code) B&O 5
May 20 Lab 8: Memory organization (slides)
May 23 Linking (slides) (video spring'22) (video spring'21) B&O 7
May 25 Managing The Heap (slides) (video spring'22) (video spring'21)
Assg5 in
B&O 9.9
May 27 Lab 9: Code Optimization
Jun 2 Final Exam (Final Exam Guide)