Computer Systems Programming

Instructor: Wu-chang Feng
Office hours: here
TA: Christopher Chak (OdinID=chak)
TA Office hours: MW 2pm-3:50pm (Outside of FAB 120)
Resources
Required textbooks
  • Computer Systems: A Programmer's Perspective, 3rd ed., Bryant and O'Hallaron, Prentice Hall, 2015. ISBN-13: 978-0134092669.
  • The C Programming Language, 2nd ed., Kernighan and Ritchie, Prentice Hall, 1998. ISBN 0-13-110362-8.
Recommended textbooks
  • The C Book M. Doran. GB Direct on-line book.
  • SEI CERT C Coding Standard CERT, on-line site.

Schedule

Date Topic (Reading) Slides Assignment
1/10 Introduction, The C Programming Language (K/R Ch 1-4) Slides
Slides
A1
1/12 The C Library, GDB (B/O Ch1, Ch 7, K/R Ch 7) Slides  
1/17 Computer System Organization (to ELF) (B/O Ch 7) Slides
1/19 Computer System Organization (B/O Ch 7)
Data Representation (to hex) (B/O Ch 2.1-2.2)
Slides A1 Due
Submission instructions
MetaCTF assignment
1/24 Data Representation (B/O Ch 2.1-2.2)

1/26 Floating Point and Arithmetic (B/O Ch 2.3-2.5) Slides
1/31 x86 Basics (B/O Ch 3.1-3.5) Slides A2 Due
Submission instructions
2/2 Midterm Exam (K/R Ch 1-4,7, B/O Ch 1-2,7)
Sample | Sample solution | Practice | Practice site
2/7
x86 Control Flow (B/O Ch 3.6) Slides
2/9 x86 Procedures (to func_ptrs)  (B/O Ch 3.7, K/R Ch. 5.11-5.12) Slides
2/14 x86 Stack Overflow (B/O Ch 3.10)

2/16 x86 Arrays (B/O Ch. 3.8 K&R Ch. 5.1-5.10) Slides
2/21 x86 Structures, Embedded Assembly, ARM (B/O Ch. 3.9, K&R Ch 6) Slides
Slides

2/23 Program optimization (B/O Ch 5) Slides
2/28 Program optimization - SIMD (B/O Ch 3.11)
Cache memories (B/O Ch 6)
Slides
Slides

3/2
Cache memories (B/O Ch 6) Slides
3/7 Cache memories (B/O Ch 6)
Exceptional control flow (B/O Ch 8)
Slides A3 Due
Submission instructions
3/9 Exceptional control flow Slides
3/14 Advanced topics Habit slides
C/Rust slides
A4 Due
3/16 Advanced topics
3/20 Monday
(10:15am-12:05pm)
Final Exam (K/R Ch 5,6, B/O Ch 3, 5, 6, 8)   MetaCTF levels due
Final Practice
FinalReviewQs | FinalReviewSolutions | Screencast

Policies

Grading
A1 (C/libc) 5%
A2 (bit ops/floats) 10%
A3 (asm,SIMD) 5%
A4 (caching) 5%
MetaCTF 20%
Attendance 10%
Midterm 20%
Final 25%
Assignments
  • Due at the beginning of class
  • Docked 10% for each day late up to 5 days.
  • Not accepted after 5 days late
Exams
  • In class
  • Closed book
  • Closed notes
  • No electronics

MetaCTF
For homework, we will be applying the concepts learned in the labs to Linux binaries. Assignments are to be done individually at the following site: cs205.oregonctf.org. Binaries are unique to each student and no collaboration is allowed. The binaries implement a set of capture-the-flag challenges that require you to reverse engineer a set of binary executables. Each binary asks for a password that will unlock it and print "Good Job". While you will be running binaries on your own machine, answers to each should be submitted at the above site. The homework is intended to give you practice for the final exam CTF. To obtain full credit, levels associated with a particular chapter must be completed by Monday at 11:30pm the week after they are assigned. For example, Ch01 and Ch03 levels are assigned for the first week of class and are due on Monday the following week. Partial credit will be given at the end of the course for levels that are turned in late.

To download binaries on a linuxlab machine, do the following:
mkdir metactf; cd metactf; virtualenv -p python3 env
source env/bin/activate
pip install requests bs4
wget http://thefengs.com/wuchang/courses/cs205/meta_dl.py
python meta_dl.py malware.oregonctf.org username password
              
Academic integrity
  • All assigned work is to be completed individually
  • For assignments, source code plagiarism tools will check that code has not been duplicated
  • Ensure your code is kept private

Academic misconduct
  • Includes allowing another student to copy your work
  • Includes copying blocks of code from external sources without proper attribution
  • Results in a grade of 0 for the assignment or exam
  • Forwarded to the university for disciplinary action.

Course objectives

  • Describe basic computer system organization including the operating system (processes, files, virtual memory) and the underlying hardware (CPU, registers, memory hierarchy).
  • Describe the compilation system (preprocessing, assembling, compiling, and linking) and the function of object/executable files and shared libraries, as well as how basic system utilities such as debuggers and Makefiles work.
  • Write C programs to illustrate basic systems programming concepts, including file I/O, system calls, memory management, exception handling and process management.
  • Do arithmetic in hexadecimal, decimal, octal, and binary notation, and convert among these notations.
  • Explain how data types such as integers, characters, floating point numbers, arrays, pointers, and structures are represented
  • Describe the basic instruction set architecture for the Intel x86 family (or similar machine), including the arithmetic/logic instructions, registers, memory model and addressing, and control instructions.
  • Explain how high-level programming constructs such as loops and stack-based function calls are implemented in underlying machine code.
  • Explain how exceptions, traps, and context switches occur and how they are handled at the machine level.
  • Explain the performance impact of hardware features such as pipelining, and architecture principles such as memory locality.
  • Understand and identify performance bottlenecks in C programs.