Announcements

Class announcements will be posted here, on EdSTEM, and/or sent as email. Please check those sources frequently for class announcements.

Class Info

  • Professor: Sukrit Venkatagiri

  • Labs: Jocelyn Corey

  • Class: Tuesday / Thursday, 11:20AM - 12:35PM, Singer 033

  • Labs:

    Section A

    Friday 8:50AM - 10:20AM (S. Venkatagiri)

    SCI 240

    Section B

    Friday 2:00PM - 3:30PM (J. Corey)

    SCI 240

    Section C

    Friday 3:45PM - 5:15PM (J. Corey)

    SCI 240

  • Ninjas: Marlea, Ben, Arden, and Lisa — see CS31 Ninja Sessions.

  • Office Hours:

    • Tuesday 2:30PM - 4:00PM (S. Venkatagiri — SCI 258)

    • Wednesday 1:00 PM - 3:00 PM (J. Corey — SCI 252B)

    • Thursday 2:00PM - 3:30PM (S. Venkatagiri — SCI 258)

  • Textbook: Dive into Systems

  • EdSTEM: Q&A Forum

  • GitHub: Swarthmore GitHub Enterprise

  • Daily Exit Ticket: Google Form

Inclusion Statement

Diversity, inclusion, and a mutual sense of belonging are all core values of this course. All participants in this course must be treated with respect by other members of the Swarthmore CS community. We must all strive, students and faculty both, to never make anyone feel unwelcome or unsafe in any way. Violations of these principles are viewed as unacceptable, and we take them very seriously. If you ever feel discriminated against or otherwise excluded, no matter how minor the offense, we encourage you to reach out to Rich, Kevin, Charlie, one of the college deans, or campus non-discrimination contacts.

Required Materials

  • iClicker: This course uses iClicker devices to facilitate feedback and discussion during class. For many intermediate and upper level CS courses including CS 31, we require that students purchase their own clicker for personal use. Clickers may be purchased at the college bookstore or online. If you purchase your clicker at the bookstore, it is eligible for the TAP program. Please register your clicker online as soon as possible! Even if you have used clickers in other CS courses, you still need to register your clicker for use in this course.

  • Textbook: all readings will come from a free, online textbook: Dive into Systems by Matthews, Newhall, and Webb. (Two of the co-authors are Swarthmore CS faculty!)

Course Overview, Goals, and Structure

This course is a broad introduction to computer science that focuses on how a computer works and how programs run on computers. We examine the hardware and software components required to go from a program expressed in a high-level programming language like C or Python to the computer actually running the program. This course takes a bottom-up approach to discovering how a computer works and introduces parallel and distributed computing with a specific focus on parallelism for multicore and other shared memory systems.

Topics include theoretical models of computation, data representation, machine organization, assembly and machine code, memory, I/O, the stack, the operating system, compilers and interpreters, processes and threads, and synchronization. In addition to parallel programming, we will discuss parallel computers and system-level support for parallel computing.

Prerequisite: Completion of CS21 or its equivalent.

Goals for the Course:

  • To understand how a sequential or parallel program goes from being expressed in a high-level programming language to being run on the underlying system.

  • To understand and analyze the systems costs associated with application performance.

  • To understand the role of the operating system and some of the abstractions it implements to support efficiently running programs.

  • To understand shared memory parallel computing and to be able to "think in parallel" algorithmically.

  • To become proficient in using gdb and valgrind to debug and examine program execution state.

  • To design and implement solutions to large problems using the C programming language.

  • To design and implement parallel solutions to programming problems that require synchronization using pthreads.

Class Structure

  • Readings: Shorter readings serve as a first exposure to new topics, where students learn the basics of the material. These should be read prior to the class meeting for which they are assigned. The reading quizzes are primarly based on these readings. Full required weekly readings complement lecture content. See tips for reading textooks for how to read these.

  • Class meetings: The classroom material will cover the course concepts in depth, and include activites to practice applying concepts learned, and to facilitate student discussion.

  • Exams: There is a midterm exam and a final exam (both closed-book) covering the material in the class meetings (and to a lesser extent on some labs). Some reference materials will be provided with the exams.

  • Labs: There are several lab programming assignments (mostly in C) that will explore various aspects of computer systems.

  • Reading Quizzes: Most class meetings there will be a short quiz primarily based on the shorter assigned readings.

  • Written Homeworks: There are several written homework assignments. Written homeworks are on based on class material and provide good practice for exams.

Schedule

This is a tentative schedule; it may change as we go. All section numbers refer to the Dive into Systems textbook unless otherwise indicated. You should read the assigned sections before class to prepare for reading quizzes.

WEEK DAY ANNOUNCEMENTS TOPIC & READING ASSIGNMENTS
1

Jan 23

Welcome! (slides)
Read (textbook): 0: Introduction
Watch: The First Computers Were Human (and Mostly Women)

Lab 0: Let's Git It Started 💃

Jan 25

Introduction to C Programming (slides)
Read (textbook): 1.0 - 1.1, 1.4

HW 1: Warming Up with C 🥵

Jan 26

In-Lab Exercise 1

Lab 1: C Arrays and Sorting
Partner Survey

2

Jan 30

Binary and Data Representation (slides, video lecture - Prof. Kevin Webb - switch YouTube account to @swarthmore.edu)
Read (textbook): 4.0 - 4.2

 

Feb 01

Binary Arithmetic (slides)
Read (textbook): 4.3 - 4.6

HW 2: Computer for a Day 🧑‍💻

Feb 02

HW1 due Feb 2nd

Drop/Add Ends

In-Lab Exercise 2

Lab 2: Data Representation and Conversion in C

3

Feb 06

Digital Circuits (slides)
Read (textbook): 5.0 - 5.4.1
Read: Washington Post: The Undocumented Workers Who Built Silicon Valley

 

Feb 08

Lab 2 due Feb 8th

Digital Circuits (continued) (slides)
Read (textbook): 5.4.2 - 5.6
Read: New York Times: Inside America’s Silicon Blockade Against China

HW 3: Short Circuit ⚡️

Feb 09

HW2 due Feb 9th

In-Lab Exercise 3

Lab 3, Part 1: Building Circuits and ALU

4

Feb 13

ISAs and Assembly (slides - Tue and Thur)
Read: Why You Should Learn Assembly Language
Read (textbook): 6.0, 7.0 - 7.3

 

Feb 15

ISAs and Assembly (continued)
Read (textbook): 7.4 - 7.4.3

HW 4: Herding Bytes in Assembly 🐈

Feb 16

HW3 due Feb 18th (Feb 18)

In-Lab Exercise 4

Lab 3, Part 2: Building Circuits and ALU

5

Feb 20

Pointers and Memory (slides)
Read (textbook): 2.1 - 2.3
Read: EDN: Toyota’s Killer Firmware

 

Feb 22

Lab 3 due Feb 22nd

Pointers and Memory (continued)
Read (textbook): 2.4 - 2.5.1

Feb 23

In-Lab Exercise 5, Video Walkthrough (Watch before lab! Switch YouTube account to @swarthmore.edu)

Lab 4: C Pointers and Assembly

6

Feb 27

Functions and the Stack (slides)
Read (textbook): 7.5 - 7.6

 

Feb 29

Lab 4 due Feb 29th

Functions and the Stack (continued)

Mar 01

HW4 due March 2nd (Mar 02)

In-Lab Exercise 6

Lab 5: Maze

7

Mar 05

Arrays, Structs, and Pointers (slides)
Read (textbook): 2.5.2 - 2.7 (skim 2.6)

 

Mar 07

Mid-Term Exam

Mar 08

Lab 5 checkpoint due March 9th (Mar 09)

In-Lab Exercise 7

Lab 5: Maze (continued)

Mar 12

Spring Break

Mar 14

Mar 15

8

Mar 19

Arrays, Structs, and Pointers (continued)

 

Mar 21

Lab 5 due March 21st

Storage and the Memory Hierarchy (slides)
Read (textbook): 11.0 - 11.3

Mar 22

In-Lab Exercise 8, Video Walkthrough (Watch before lab! Switch YouTube account to @swarthmore.edu)

Lab 6: Game of Life!

9

Mar 26

Storage and the Memory Hierarchy + Caching (slides)
Read (textbook): 11.4 - 11.4.1
Read: Just 10 lines of code can steal AI secrets from [...] GPUs

 

Mar 28

Storage and the Memory Hierarchy + Caching (continued)
Read (textbook): 11.4.2 - 11.4.3

Mar 29

Last Day to Declare CR/NC

Lab 6: Game of Life! (continued)

10

Apr 02

Caching (continued)

 

Apr 04

Lab 6 due Apr 4th

Operating Systems (slides)
Read (textbook): 13.0 (13.1 is also interesting / relevant, but not required.)

HW 6: Short On Cache 💰

Apr 05

In-Lab Exercise 9

Lab 7: String Lab

11

Apr 09

Operating Systems (continued), Processes (slides)
Read (textbook): 13.2

 

Apr 11

Lab 7 due Apr 11th

Processes (continued) (slides)
Read (textbook): 13.2

Apr 12

In-Lab Exercise 10

Lab 8, Part 1: Implementing a Unix Shell

12

Apr 16

Virtual Memory (slides)
Read (textbook): 13.3 - 13.3.2
Read (textbook): 13.3.3 - 13.3.4

 

Apr 18

Virtual Memory (continued)
Read: Making an image with generative AI uses as much energy as charging your phone

Apr 19

HW6 due Apr 19th

In-Lab Exercise 11

Lab 8, Part 2: Implementing a Unix Shell

13

Apr 23

Parallel Applications and Threading (slides)
Read: The Concurrency Revolution (Note: this article is from 2005)

HW 7: Zombies 🧟‍♀️ and Virtual Memory 💾

Apr 25

Lab 8 due Apr 25th

Race Conditions and Synchronization (slides)
Read (textbook): 14.1, 14.3 & 14.3.1

Apr 26

In-Lab Exercise 12

Lab 9, Part 1: pthreads Game of Life

14

Apr 30

(EXTRA)
Other Synchronization & Thread Design Patterns
Read (textbook): 14.3.3
Deadlock and Other Parallel Problems (EXTRA)

 

May 02

(EXTRA)

May 03

HW7 due May 3rd

Lab 9, Part 2: pthreads Game of Life

May 09

Final (7:00-10:00pm, Singer 033)

Lab 9 due May 10th (May 10)

Grading

Grades will be weighted as follows:

Percentage Course Activity

5%

Class participation

5%

Reading quizzes

5%

Written homework assignments (8 HWs)

30%

Labs assignments (9 labs)

25%

Midterm Exam

30%

Final Exam

CS31 Labs

Lab Sessions on Fridays

The weekly lab meetings, on Fridays, are structured with about 1/3 presentation (typically an introduction to the weekly lab assignment and practice learning programming tools for carry out the lab), and about 2/3 for working on the lab assignment. Weekly lab meeting attendance is mandatory and it is expected that you attend the entire lab and that you work on CS31 content during lab.

All lab assignments, with the exception of Lab 2, will be done with a partner. You will be assigned a partner for the first few lab assignments. In later labs, we will let you choose your own partner.

About the CS Labs

We encourage you to work in one of the CS labs when possible (vs. remotely logging in), particularly when working with a partner. The CS labs (rooms 240, 256, 238 and the Clothier basement) are available for you to use for CS course work. With the exception of times when a class, or lab, or ninja session is scheduled in one of these rooms, you may work anytime in a CS lab on CS course work. The overflow lab (238) is always available.

CS lab machines are for CS course work only. There are other computer lab/locations on campus that are for general-purpose computer use. Please review the CS Lab Rules about appropriate use of CS labs.

Accessing the CS labs after hours

You can use your ID to gain access to the computer labs at nights and on the weekends. Just wave your ID over the onecard reader next to the lab doors. When the green light goes on, just push on the door handle to get in (the door knob will not turn). If you have issues with the door locks, send an email to local-staff@cs.swarthmore.edu. If the building is locked, you can use your ID to enter the door between Martin and Cornell library. For this class, your ID will give you access to the labs in rooms SCI 238, 240, 256, and the Clothier basement from 7:00 AM to midnight.

CS31 Lab assignments

Lab assignments will typically be posted on Friday and will be due the following Thursday evening. You are strongly encouraged to start early, attend the ninja session, and ask questions early if you get stuck (EdSTEM, office hours, ninja sessions). For some assignments you will work individually. For others you must work with a partner.

We will use Swarthmore’s GitHub Enterprise for managing each lab assignment. You will submit your lab solutions electronically using git. You must do a git add, commit, and push before the due date to submit your solution on time. You may push your assignment multiple times, and a history of previous submissions will be saved. You are encouraged to push your work regularly. You do not need to already know how to use git. We provide instruction on using git for CS31 with the first lab assignment.

Working with Partners

For partnered lab assignments, you should follow these guidelines:

  • The expectation is that you and your partner are working together side by side in the lab for most, if not all, of the time you work on partnered lab assignments.

  • You and your partner should work on all aspects of the project together: initial top-down design, incremental testing and debugging, and final testing and code review.

  • If you are pair programming, where one of you types and one of you watches and assists, then you should swap roles periodically, taking turns doing each part.

  • There may be short periods of time where you each go off and implement some small part independently. However, you should frequently come back together, talk through your changes, push and pull each other’s code from the git repository, and test your merged code together.

  • You should not delete or significantly alter code written by your partner when he or she is not present. If there is a problem in the code, then meet together to resolve it.

  • If there is any issue with the partnership, contact the professor.

Taking time to design a plan for your solution together and to doing incremental implementation and testing together may seem like it is a waste of time, but in the long run it will save you a lot of time by making it less likely that you have design or logic errors in your solution, and by having a partner to help track down bugs and to help come up with solutions to problems.

Partnerships where partners work mostly independently rarely work out well and rarely result in complete, correct and robust solutions. Partnerships where partners work side-by-side for all or most of the time tend to work out very well.

You and your partner are both equally responsible for initiating scheduling times when you can meet to work together, and for making time available in your schedule for working together.

CS31 Ninja Sessions

The CS31 Ninjas are student mentors who will assist students in class and lab, and who run evening study sessions each week. You are encouraged to participate in Ninja evening study sessions to get friendly assistance on lab assignments and help with preparing for exams.

  • Weekly Evening Ninja Session: Wednesdays 6:00 PM - 10:00 PM (SCI 256)

  • The CS31 Ninjas: Marlea, Ben, Arden, and Lisa

  • Ninja Coordinator: Lauri Courtenay

Absence / Assignment Extension Policy

To help with cases of minor illnesses, athletic conflicts, or other short-term time limitations, we will drop your 3 lowest reading quizzes and participation grades.You are still responsible for the material, and you should review any missed materials via the class recordings as soon as you can.

All students start the course with 2 late days to be used on homework assignments and 3 late days to be used on lab assignments* at your discretion, no questions asked. No more than 2 late days can be used on a single homework or lab assignment.

To use your late day(s), you must email your professor before the due date for the lab and indicate how many late days you intend to use. When you use late days, you should still expect to work on the newly-released lab during the following lab section meeting. The professor will always prioritize answering questions related to the current lab assignment.

Your late days will be counted at the granularity of full days and will be tracked on a per-student (NOT per-partnership) basis. That is, if you turn in an assignment five minutes after the deadline, it counts as using one day. For partnered labs, using a late day counts towards the late days for all partners.

If you feel that you need an extension on an assignment or that you are unable to attend class for two or more meetings due to a medical condition (e.g., extended illness, concussion, hospitalization) or other emergency, you must contact the Dean’s office and your instructors. Faculty will coordinate with the deans to determine and provide the appropriate accommodations. For illnesses, students should consult the College’s medical excuse policy for the latest guidance on how you can coordinate with the student health and wellness center and your dean in order to provide us with the necessary information.

Late days cannot be used for any written or in-class homework assignments that are not associated with a lab assignment.

Academic Accommodations

If you believe you need accommodations for a disability or a chronic medical condition, please contact Student Disability Services via email at studentdisabilityservices@swarthmore.edu to arrange an appointment to discuss your needs. As appropriate, the Office will issue students with documented disabilities or medical conditions a formal Accommodations Letter. Since accommodations require early planning and are not retroactive, please contact Student Disability Services as soon as possible.

For details about the accommodations process, visit the Student Disability Services website.

You are also welcome to contact any of the course staff privately to discuss your academic needs. However, all disability-related accommodations must be arranged, in advance, through Student Disability Services.

To receive an accommodation for a course activity you must have an official Accommodations Letter and you need to meet with the course professor to work out the details of your accommodation at least two weeks prior to any activity requiring accommodations.

Academic Integrity

Academic honesty is required in all your work. Under no circumstances may you hand in work done with or by someone else under your own name. Discussing ideas and approaches to problems with others on a general level is encouraged, but you should never share your solutions with anyone else nor allow others to share solutions with you. You may not examine solutions belonging to someone else, nor may you let anyone else look at or make a copy of your solutions. This includes, but is not limited to, obtaining solutions from students who previously took the course or solutions that can be found online. You may not share information about your solution in such a manner that a student could reconstruct your solution in a meaningful way (such as by dictation, providing a detailed outline, or discussing specific aspects of the solution). You may not share your solutions even after the due date of the assignment.

In your solutions, you are permitted to include material which was distributed in class, material which is found in the course textbook, and material developed by or with an assigned partner. In these cases, you should always include detailed comments indicating on which parts of the assignment you received help and what your sources were.

Use of or consultation with generative AI (e.g., chatGPT or GitHub CoPilot) is considered to be unauthorized collaboration with another source and is a violation of our academic integrity policy.

When working on tests, exams, or similar assessments, you are not permitted to communicate with anyone about the exam during the entire examination period (even if you have already submitted your work). You are not permitted to use any resources to complete the exam other than those explicitly permitted by course policy. (For instance, you may not look at the course website during the exam unless explicitly permitted by the instructor when the exam is distributed.)

Failure to abide by these rules constitutes academic dishonesty and will lead to a hearing of the College Judiciary Committee. According to the Faculty Handbook:

"Because plagiarism is considered to be so serious a transgression, it is the opinion of the faculty that for the first offense, failure in the course and, as appropriate, suspension for a semester or deprivation of the degree in that year is suitable; for a second offense, the penalty should normally be expulsion."

This policy applies to all course work, including but not limited to code, written solutions (e.g. proofs, analyses, reports, etc.), exams, and so on. This is not meant to be an enumeration of all possible violations; students are responsible for seeking clarification if there is any doubt about the level of permissible communication.

The general ethos of this policy is that actions which shortcut the learning process are forbidden while actions which promote learning are encouraged. Studying lecture materials together, for example, provides an additional avenue for learning and is encouraged. Using a classmate’s solution, however, is prohibited because it avoids the learning process entirely. If you have any questions about what is or is not permissible, please contact your instructor.

Exam Integrity

Students must strictly adhere to the following policy, which applies to all exams taken in a Computer Science course at Swarthmore:

Exam takers must place all non-essential items at the front of the room (or other designated area). Unless otherwise permitted, students may not have any electronic devices or course materials in their possession during the entirety of the exam. This includes cell phones, tablets, laptops, smart watches, course notes, articles and books, among others. These items should be placed at the front of the room near the proctor. If you need to leave the room during the exam, you must obtain permission from an instructor first. Any non-permitted discussion or aide in regards to exam material will result in immediate forfeiture of the exam and a report to the College Judiciary Committee. Please discuss any concerns or accommodations with your instructor prior to starting the exam.

How to Succeed in CS31

  • Attend class and actively participate in class. The primary introduction to course material is through class lecture. Additionally, we often do exercises during class. Showing up is necessary, but not sufficient to success in the course: ask questions, participate in class discussions and in class activities, and take notes.

  • Read the material before you come to class. Don’t worry about total comprehension, but at least get a feel for what we will be covering that week. If you have some understanding of the material coming into class, it will be easier for you to follow the lecture and to ask questions during class. See the tips for reading CS textbooks for guidelines on getting the most out of assigned readings.

  • Start the lab assignments early. I realize this one is not always easy to do, but if you can get in the habit of doing this, you will be much better off. As the labs get longer and more difficult, starting early will give you plenty of time to mull over the lab problems even when you aren’t actively writing your solution.

  • Practice, practice, practice. The only effective way to learn the material and pass the exams is to consistently do the labs and written assignments, and to practice example problems presented in class and in the book. Forming study groups to go over practice problems and to review lecture and reading notes is a great way to prepare for exams.

  • Seek help early and often. Because course material builds on previous material, it is essential to your success in this class that you keep up with the course material. There are a lot of sources of help: ask questions during lecture; ask your classmates (make sure you have read the "Academic Integrity" section below first); get help during lab sessions; come to office hours; use the class EdSTEM page for lab Q&A, and attend ninja study sessions.

  • Attend Study Sessions. The student Ninjas hold evening sessions each week. You are encouraged to participate in these sessions. The Ninjas will provide friendly assistance on your lab assignments and can also help answer questions about in-class exercises.

  • Take hand written lecture notes. In lecture the professor often draws diagrams on the board, some of which you will need to reproduce. Taking notes with paper and pen (vs. on the computer) will allow you to copy these diagrams.

Handy Resources