System Programming

list Preamble

info Description

This course is an introduction to unix-specific, system-level programming with an emphasis on the C programming and bash command programming languages. Topics include build systems like Make, debugging techniques and process management. Other topics include streams, buffers and pipes, system calls, multi-threading, and libraries for system programming. Students will use their computer’s command line interface, or cli, exclusively in this course.

list Learning Outcomes

Upon successful completion of this course, students will understand...

file_download Software Requirements

The software making up the toolchain required for this course is free. Install each in the order listed below.

Git Client (Mac, Windows, Linux)

All in-class examples, assignments, and help is done via GitHub. Download the client for your computer here.

A Command Line Interface (Mac, Windows, Linux)

Mac and Linux users do not have to install a Command Line Interface, or cli, because these operating systems already have The Terminal installed. Windows users, however, will need to install Cygwin, which is fully supported in class. Windows users may also consider installing the wsl.

Note: Once your cli has been installed, configure your environment using the Terminal-related config files from this repo.

Package Manager (Mac, Windows)

Package managers provide an easy way to install software via your cli from a single registry. Install Homebrew for macos via The Terminal from https://brew.sh/; install Chocolatey for Windows via PowerShell from https://chocolatey.org/install.

Text Editor (Mac, Windows, Linux)

The code you write will require a text editor. Although there are many on the market, such as Sublime Text (nagware), for example, vs Code (open source) is the only editor supported in class. Download the Linux, Windows, or macOS version from https://code.visualstudio.com/.

GCC (Mac, Windows, Linux)

The gnu Compiler Collection, or gcc, is the cli tool we’ll use to compile, build, and run our programs. No other compiler is supported in class. All examples shared with students, and all assignments, will be compiled, run, and graded using gcc. In macos, gcc is installed as part of the Xcode Command Line Tools kit. If you type gcc in The Terminal, it will automatically launch xcode-select --install. You may, alternatively, type xcode-select --install directly.

In Windows, gcc might have been installed by Cygwin. To find out, type which gcc in Cygwin. If found, Cygwin will respond with a path, likely /usr/bin/. The Windows path equivalent is C:\cygwin64\bin, assuming you installed Cygwin to Windows’ root drive. If you want access to gcc from PowerShell and/or the Command Prompt, you’ll need to edit your Environment Variable by adding C:\cygwin64\bin.

If gcc was not found by Cygwin, restart the Cygwin installer, and choose to only install gcc.

CLion (Mac, Windows, Linux)

JetBrains’s CLion is a C/C++ ide that you may use alongside gcc. If you have experience with IntelliJ or WebStorm, then CLion will feel familiar. Recall that, as a student, you have access to a free educational license for all JetBrains products. Download CLion from here, then apply for your free license here.

EditorConfig (Mac, Windows, Linux)

EditorConfig is a tool that enforces consistent coding styles for everyone who works on a codebase. In our case, that codebase consists of all the examples in class and all the assignments you’ll submit throughout the semester. EditorConfig consists of an extension and a configuration file (.editorconfig) that goes in your home — or project — folder. Some editors and ides have EditorConfig built in. vs Code, unfortunately, is not one of them. Install the EditorConfig extension for vs Code from here, then download this .editorconfig file and place it in your home folder. Ensure the file name is exactly .editorconfig, starting with a dot and without a file extension.

Make (Mac, Windows, Linux)

The make cli utility acts like a script that automatically determines which files of a multi-object program need to be recompiled, then issues commands to recompile them. The official documentation is available from gnu, while a more accessible tutorial is available from Makefile Tutorial.

If you’re using Windows, simply run choco install make from your cli, assuming you’ve already installed Chocolately. Linux and macos users already have make installed.

Splint (Mac, Windows, Linux)

Splint, or Secure Programming Lint, is a powerful linter for C programs from the early aughts, and is still a valid and helpful linter for modern C programs. You can read more at splint.org. Install it for macOS via Homebrew (brew install splint) or Windows via Chocolately (choco install splint.)

Shellcheck (Mac, Windows, Linux)

A static analysis tool — or linter — for bash scripts, shellcheck is available for all evergreen operating systems via your favorite package manager. Run brew install shellcheck via Homebrew to install in macOS, and choco install shellcheck via Chocolatey as an elevated user in Cygwin or PowerShell for Windows.

menu_book Textbook

The textbook(s) listed below is/are the only book(s) used for this course. Ensure all the details match before making your purchase. Note: A 25% discount code from No Starch Press is available for students purchasing books before 28 Feb. Contact me for the code.

Textbooks-related Info
Book Cover
[Cover of The Linux Programming Interface.]
Title The Linux Programming Interface
Edition 1
Authors Michael Kerrisk
isbn-13 (print and ebook) 9781593272203
Publisher No Starch Press
Comment This book will be referred to as lpi, for Linux Programming Interface, in the reading schedule below.
Book Cover
[Cover of The C Programming Language, 2nd Edition.]
Title The C Programming Language
Edition 2
Authors Brian W Kernighan, Dennis M Ritchie
isbn-13 (print) 9780131103627
Publisher Pearson
Comment This book will be referred to as K&R, for Kernighan and Ritchie, in the reading schedule below. Note: A version of the book is available as a free pdf from Archive.org. Download it from here.

calendar_month Schedule

Notable Dates

Note: Time permitting, I will make every attempt to cover the topics listed below in order. However, depending on the cadence of the class, some topics may be overlooked.

The weekly schedule for the semester, complete with topics and readings.
Week Class Topics Homework
1
Thur
  • Thorough syllabus breakdown
  • Software installfest
  • A little unix and C history
  • Working with Makefiles
2 Tue

(k&r) Chapter 1: A Tutorial Introduction

  • (1.1) Getting Started
  • (1.2) Variables and Arithmetic Expressions
  • (1.3) The for statement
  • (1.4) Symbolic Constants
  • (1.5) Character Input and Output
  • Visit the web-dev-env-config-files repo and configure your cli environment according to the Terminal Theme and Environment Files (Mac and Windows) section
Thur

(k&r) Chapter 1: A Tutorial Introduction

  • (1.6) Arrays
  • (1.7) Functions
  • (1.8) Arguments — Call by Value
  • (1.9) Character Arrays
  • (1.10) External Variables and Scope
3 Tue

(k&r) Chapter 2: Types, Operators, and Expressions

  • (2.1) Variable Names
  • (2.2) Data Types and Sizes
  • (2.3) Constants
  • (2.4) Declarations
  • (2.5) Arithmetic Operators
  • (2.6) Relational and Logical Operators
Thur

(k&r) Chapter 2: Types, Operators, and Expressions

  • (2.7) Type Conversions
  • (2.8) Increment and Decrement Operators
  • (2.9) Bitwise Operators
  • (2.10) Assignment Operators and Expressions
  • (2.11) Conditional Expressions
  • (2.12) Precedence and Order of Evaluation
4 Tue

(k&r) Chapter 3: Control Flow

  • (3.1) Statements and Blocks
  • (3.2) If-Else
  • (3.3) Else-If
  • (3.4) Switch
Thur

(k&r) Chapter 3: Control Flow

  • (3.5) Loops — While and For
  • (3.6) Loops — Do-While
  • (3.7) Break and Continue
  • (3.8) Goto and Labels
5 Tue

(k&r) Chapter 4: Functions and Program Structure

  • (4.1) Basics of Functions
  • (4.2) Functions Returning Non-integers
  • (4.3) External Variables
  • (4.4) Scope Rules
  • (4.5) Header Files
  • (4.6) Static Variables
Thur

(k&r) Chapter 4: Functions and Program Structure

  • (4.7) Register Variables
  • (4.8) Block Structures
  • (4.9) Initialization
  • (4.10) Recursion
  • (4.11) The C Preprocessor
6 Tue

(k&r) Chapter 5: Pointers and Arrays

  • (5.1) Pointers and Addresses
  • (5.2) Pointers and Function Arguments
  • (5.3) Pointers and Arrays
  • (5.4) Address Arithmetic
  • (5.5) Character Pointers and Functions
  • (5.6) Pointer Arrays; Pointers to Pointers
Thur

(k&r) Chapter 5: Pointers and Arrays

  • (5.7) Multi-dimensional Arrays
  • (5.8) Initialization of Pointer Arrays
  • (5.9) Pointers vs Multi-dimensional Arrays
  • (5.10) Command-line Arguments
  • (5.11) Pointers to Functions
  • (5.12) Complicated Declarations
7 Tue

(k&r) Chapter 6: Structures

  • (6.1) Basics of Structures
  • (6.2) Structures and Functions
  • (6.3) Arrays of Structures
  • (6.4) Pointers to Structures
  • (6.5) Self-Referential Structures
Thur

(k&r) Chapter 6: Structures

  • (6.6) Table Lookup
  • (6.7) Typedef
  • (6.8) Unions
  • (6.9) Bit-fields
8 Tue

(k&r) Chapter 7: Input and Output

  • (7.1) Standard Input and Output
  • (7.2) Formatted Output — Printf
  • (7.3) Variable-length Argument Lists
  • (7.4) Formatted Input — Scanf
Thur

(k&r) Chapter 7: Input and Output

  • (7.5) File Access
  • (7.6) Error Handling — Stderr and Exit
  • (7.7) Line Input and Output
  • (7.8) Miscellaneous Functions
9 Tue Spring Recess None. Enjoy your break!
Thur Spring Recess None. Enjoy your break!
10 Tue

(lpi) Chapter 2: Fundamental Concepts

  • (2.1) The Core Operating System: The Kernel
  • (2.2) The Shell
  • (2.3) Users and Groups
  • (2.4) Single Directory Hierarchy, Directories, Links, and Files
  • (2.5) File I/O Model
  • (2.6) Programs
  • (2.7) Processes
  • (2.8) Memory Mappings
  • (2.9) Static and Shared Libraries
  • (2.10) Interprocess Communication and Synchronization
Thur

(lpi) Chapter 2: Fundamental Concepts

  • (2.11) Signals
  • (2.12) Threads
  • (2.13) Process Groups and Shell Job Control
  • (2.14) Sessions, Controlling Terminals, and Controlling Processes
  • (2.15) Pseudoterminals
  • (2.16) Date and Time
  • (2.17) Client-Server Architecture
  • (2.18) Realtime
  • (2.19) The /proc File System
11 Tue

(lpi) Chapter 3: System Programming

  • (3.1) System Calls
  • (3.2) Library Functions
  • (3.3) The Standard C Library; The GNU C Library (glibc)
  • (3.4) Handling Errors from System Calls and Library Functions
  • (3.5) Notes on the Example Programs in This Book
  • (3.6) Portability Issues
Thur

(lpi) Chapter 4: File I/O: The Universal I/O Model

  • (4.2) Universality of I/O
  • (4.3) Opening a File: open()
  • (4.4) Reading from a File: read()
  • (4.5) Writing to a File: write()
  • (4.6) Closing a File: close()
  • (4.7) Changing the File Offset: lseek()
  • (4.8) Operations Outside the Universal I/O Model: ioctl()
12 Tue

(lpi) Chapter 6: Processes

  • (6.1) Processes and Programs
  • (6.2) Process id and Parent Process id
  • (6.3) Memory Layout of a Process
  • (6.4) Virtual Memory Management
  • (6.5) The Stack and Stack Frames
  • (6.6) Command-Line Arguments (argc, codeargv)
  • (6.7) Environment List
  • (6.8) Performing a Nonlocal Goto: setjmp() and longjmp()
Thur

(lpi) Chapter 7: Memory Allocation

  • (7.1) Allocating Memory on the Heap
  • (7.2) Allocating Memory on the Stack: alloca()

(lpi) Chapter 8: Users and Groups

  • (8.1) The Password File: /etc/passwd
  • (8.2) The Shadow Password File: /etc/shadow
  • (8.3) The Group File: /etc/group
  • (8.4) Retrieving User and Group Information
  • (8.5) Password Encryption and User Authentication
13 Tue

(lpi) Chapter 15: File Attributes

  • (15.1) Retrieving File Information: stat()
  • (15.2) File Timestamps
  • (15.3) File Ownership
  • (15.4) File Permissions
  • (15.5) I-node Flags (ext2 Extended File Attributes)
Thur

(lpi) Chapter 20: Signals — Fundamentals Concepts

  • (20.1) Concepts and Overview
  • (20.2) Signal Types and Default Actions
  • (20.3) Changing Signal Dispositions: signal()
  • (20.4) Introduction to Signal Handlers
  • (20.5) Sending Signals: kill()
  • (20.6) Checking for the Existence of a Process
  • (20.7) Other Ways of Sending Signals: raise() and killpg()
14 Tue

(lpi) Chapter 20: Signals — Fundamentals Concepts

  • (20.8) Displaying Signal Descriptions
  • (20.9) Signal Sets
  • (20.10) The Signal Mask (Blocking Signal Delivery)
  • (20.11) Pending Signals
  • (20.12) Signals Are Not Queued
  • (20.13) Changing Signal Dispositions: sigaction()
  • (20.14) Waiting for a Signal: pause()
Thur

(lpi) Chapter 24: Process Creation

  • (24.1) Overview of fork(), exit(), wait(), and execve()
  • (24.2) Creating a New Process: fork()
  • (24.3) The vfork() System Call
15 Tue

(lpi) Chapter 24: Process Creation

  • (24.4) Race Conditions After fork()
  • (24.5) Avoiding Race Conditions by Synchronizing with Signals
Thur

Course summary

16 Tue
  • Open Lab
  • Evaluations
  • Final project due
None. Enjoy your break!

assignment Assignments

The assignments portion of your final grade consists of three homework-type assignments and one final project. (See the Grading Formula section to learn what percentage of your final grade each is worth.)

Note: Broken links in the list below will be updated once each assignment is assigned a due date.

info Grading

Your grade for this course will be computed using the following formula:

  1. Assignments (45%)
    • Assignment 1 — 15%
    • Assignment 2 — 15%
    • Assignment 3 — 15%
  2. Final project (45%)
  3. Attendance and participation (10%)

To calculate your final grade, convert to decimal the percentages above and the grades you’ve earned. For example, if you got an 80 on the first assignment, a 93 on the second assignment, a 60 on the third assignment, a 100 on your final project, and 100 for attendance, then you’d use the following formula:

(.80 × .15) + (.93 × .15) + (.60 × .15) + (1 × .45) + (1 × .10) = 89%

I do not give grades; students earn them. The grade you earn is based strictly on the outlined formula clearly listed in this section.

This grading formula is unbending and will be adhered to strictly.

Important Note

Please do not try to negotiate a grade with me. By asking me to treat you favorably, you’re requesting that I put you above your classmates. Manage your time well; I do not accept late work.

balance Class Policies

psychology No AI Use in Class

The use of generative ai tools is strictly forbidden in this course. All programming assignments — and any labs — associated with this course must be completed without the assistance of ai-generated content. This policy is in place to ensure that the work submitted is authentically yours and reflects your personal understanding and capabilities. Violations of this policy will be considered academic dishonesty and will be subject to disciplinary actions as outlined in the university’s academic honesty policy.

warning Academic Honesty

Cheating of any kind will not be tolerated in this course; make certain that all the work you submit is your own. Refresh your understanding of the college’s policy on academic honesty.

accessible Students with Disabilities

If you have a documented disability for which you are requesting accommodation, you are encouraged to contact Access-Ability Services as soon as possible by calling 860.768.4312, emailing tlopez@hartford.edu, or by stopping by the Access-Ability Services office in Auerbach Hall, Room 209. If your request for accommodations is approved, an accommodation letter will be emailed to your instructor(s) upon your request. Please discuss your accommodations with the instructor as soon as possible to make appropriate arrangements. Note: Student requests for accommodations must be filed each semester. Visit https://www.hartford.edu/academics/academic-support/accessibility-services/ and click the “Registering” link for more info and a link to a video that walks you through the process.

balance Title IX and Sexual Assault

Sexual violence and other forms of sexual misconduct and harassment, including stalking and intimate partner violence, are prohibited under Title ix, federal and state law, and University of Hartford policy. Information on the University’s policies against sexual violence can be found at https://www.hartford.edu/about/policies/title-ix/. Resources regarding sexual violence can be found at https://www.hartford.edu/about/policies/title-ix/on-off-campus-resources.aspx

Note: University of Hartford faculty, staff, and ras are required to report incidents of sexual misconduct to the Title ix Office (title9@hartford.edu). For further information on The University’s policies and resources, please contact Jason Martinez (860.768.5255; jamartine@hartford.edu) or Justin Bell (860.768.4880; jbell@hartford.edu).

psychology Mental Health and Well-Being

Mental Health is an important aspect of students’ well-being and integral to positive academic experiences and success. If, during the semester, you experience difficulties and would like support, consider contacting the University of Hartford’s caps, or Counseling and Psychological Services, which offers a range of short-term counseling services available to full-time undergraduate students at no additional cost, and to part-time undergraduate and graduate students for a small fee.

caps is located in Gengras Student Union, Room 313 map, and can be reached by calling 860.768.4482 or emailing Liz Inkel at inkel@hartford.edu. Office hours are Monday – Friday, 8:30 AM – 4:30 PM.

info Advice on Succeeding in Class

Read over the following to understand procedures for maximizing your chances of succeeding in class.

door_front Office Hours

I meet students in my office by appt — via Compass — at the times noted below. (Meeting via videoconference is also an option.) If this time slot isn’t feasible, contact me to make an appt — vanegas@hartford.edu.

contact_mail Contact

Nowadays, I only use email for emergency situations, such as a pet emergencies, personal tragedies, etc. For matters related to our course, you’re advised to see me before or after class, during my office hours, or by appointment. My contact info is listed in the Preamble.