Bryn Mawr College
CMSC 246: Systems Programming
Fall 2019
Prof. Geoffrey Towell
General Information
Instructor:
Lecture Hours: MW 10:10AM - 11:30AM
Room: Park 336
Lab: Park 231 Mo 1:10PM - 2:30PM (Attendance in Lab is REQUIRED)
Office Hours: T 10:00-11:00AM, W 1:00-2:00PM, or by appointment
Laboratories:
Computer Science Lab Room 231 (Science Building)
Lab Assistant: The TA for the course is Sara Golobish. She will be available in the CS labs (either Park 230 or Park 231) every Thusday and Thursday evening 7-9PM (except as noted below). Class assignments will typically be due either Friday evening. Please be aware that there will be several other TAs in the lab at this time. Try to find Sara for 246 questions.
On the following dates, the hours of the lab assistant will be other than the norm:
- Oct 1: 8-10pm
- Oct 29: Moved to Wed Oct 30 7-9 PM
Texts &
Software
Required Texts
- C Programming: A Modern Approach by K. N. King (2nd edition). W. W. Norton & Company, 2008. Available at the campus bookstore.
- The Linux Command Line: A Complete Introduction by William E. Shotts, Jr. No Starch Press, 2012. Available at the campus bookstore and for free download through both the Bryn Mawr and Haverford libraries.
- In the Beginning was the Command Line by Neal Stevenson, 1999. Click here
Not for purchase...
- Head First C by David Griffiths and Dawn Griffiths. O’Reilly Media, 2012. This is an alternative introduction to C that may be helpful to you. Readings will not be assigned from it, however.
|

|
Syllabus
Course Description: This is a course in systems programming using the C programming language in the Linux environment. C undergirds the world of modern computers and runs on anything. Learning C will also teach you how a computer really works under the hood and it will power your knowledge of programming and system building on any platform.
A secondary goal of this course is to give you a chance to learn some fundamental technologies in widespread use. As a computer scientist, you will be expected to know about Makefiles, version control, and command-line execution in the Linux environment.
By the end of this course, you will be able to…
- Write standalone programs in the C programming language
- Understand computer memory management and pointers
- Work with linked structures (lists, trees, and graphs)
- Use the Linux command line
- Become familiar with programming tools and environment in Linux
During the course, you will…
- Code lots of C programs
- Setup and use Make files, and other Linux tools
- Learn how to debug
- (Possibly) learn keep your work safe with Git
Course Philosophy:
In order to learn any programming skill, you must simply do it. Reading a book or watching me code will not help you get better. This course is thus programming-intensive. You will be expected to spend a significant amount of time weekly (6-8 hours) outside of class programming to complete the homework assignments. If you run into a snag, the programming burden may prove to be even higher. Of course, programming is fun, so the time should fly by.
Class time in CS246 will be spent primarily working with peers to solve small programming problems, conduct peer reviews, and complete other exercises. It is expected that you complete the reading before class and come with questions; I will try to avoid spending large chunks of class time repeating what the book says so well.
Important Dates
- First lecture: Sept 4
- Exam 1: Oct 9
- Exam 2:
Nov 20Nov 13
- Exam 3: Self-scheduled during exam week.
Assignments
- Assignment #1 (Due on Friday, Sep 13): Click here for details.
- Assignment #2 (Due on Friday, Sep 20): Click here for details.
- Assignment #3 (Due on Friday, Sep 27): Click here for details. (for making large arrays, please see This program)
- Assignment #4 (Due on Friday, Oct 4): Click here for details. If you are attending Grace Hopper send me an email for a free 2 day extension.
- Assignment #5 (Due on
Friday, Oct 25 Sunday Oct 27 by 5pm): Click here for details
- Assignment #6 (Due Sunday Nov 3 before midnight): Click here for details 10/29: I updated slightly the submission directory. This change means that the submit program will not work.
- Assignment #7 (Due Sunday Nov 10 before midnight): Click here for details
- Assignment #8
(Due Wednesday, Nov 27 before midnight): Monday Dec 2 prior to MidnightClick here for details Due date changed
- Assignment #9 Saturday, December 14, before midnight Click here for details
Labs
Lectures
- Week 1
Sept 4
Introduction & administrivia. Meeting Linux & C: WIMP vs CLI, basic shell commands. a brief history of the evolution of C, a quick overview of C (aka C for Java programmers), writing, compiling, and running C programs.
Overview of C: Printf() and scanf(), conditionals and loops. Writing basic C programs.
Lecture materials
Assignment #1 (Due on Sep 12): Click here for details.
Read: Chapters 1-6 from King. Chapters 1-4 from Shotts.
- Week 2
Continuing overview of C: scanf, printf, loops, arrays, types, pass by value.
ctype library (and more generally generally using libraries)
Read: Chapters 7-9 from King. Chapters 5 from Shotts.
Sep 9 Materials
Sep 11 Materials
- Slides
- types.c Shows interchanability between int and char
- c2ftable.c a table of celcius to fahrenheit conversions
- c2floop.c The scanf looping problem
- shoutj.c Program to take user input and upper case it.
- Week 3
Continuing overview of C: more with arrays. More with C libraries. .h files. UNIX: paths, which and redirection
Read: Chapters 7-9 from King. Chapter 5-6 from Shotts.
Sep 16 Materials
- shoutc.c Uppercase, C style. Chars as numbers. Pointer math.
- sprint.c Printing of uninitializied portions of char array.
- stddev.c Random number generation (srand and rand), functions in C. Linking in libm gcc -lm stddev.c
Sep 18 Materials
- c2fsafe2.c c2fsafe2.h c2f using only getchar. Also, use of local .h file
- rmcm.c 2-d arrays, row major allocation of 2-d arrays, more pointer math. Issue encountered in class fixed.
- p1.c Alternate form of main for getting command line arguments
- p2.c Reading from stdin when stdin is not the keyboard for instance a.out < p2.c or cat p2.c | a.out
- Week 4
Continuing overview of C: references, pointers and arrays. functions and pass by reference. string.h .h files and Makefiles UNIX: paths, which and redirection
Makefiles (simple) makefile tutorial
Read: Chapters 11-13 from King. Chapter 6-8 from Shotts.
Sep 23 Materials
- timer.c getting the runtime for a function
- ttest.c Compute the value of the T test. Then looking meaning using a T-Test table.
- p1.c Global Variables
- p3.c Pass by value in C
- p7.c Try to return an array from a function. Not allowed.
- strcatovr.c Using strcat from the string.h library and the problem of writing beyond the end of the array.
Sep 25 Materials
- strokex.c Example of strtok from string.h library
- mystrtok.cMy implementation of the strtok function. This one is more limited than teh library function in that it tokenizes on a single character
- p1.c Read from a test file. This has several slightly different reading methods> usage a.out filename [1-5]
- p2.c Timing of just writing to array. Poiter vs array style. Usage a.out [1,2] where 1 is array-style and 2 is pointer
- Makefile A very simple makefile. This makefile assume that tests files are in the same directory ttest.c ttest.hbasestats.cbasestats.h
- Makefile2 An equivalent makefile, but with variables
- makefile tutorial
- Week 5
Continuing overview of C: multidimensional arrays and pointers thereto. Heap space and stack space. Recursion. Other topics from chapters 1-14, Macros and the preprocessor UNIX: permissions and processes.
Read: Chapters 14 from King. Chapter 9-10 from Shotts.
Sep 30 Materials
- p3.c passing multi dimensional arrays into functions
- p4.c creating multi dimensional arrays that vary in length.
- binsearcha.c Recusrion, binary search and the stack
Oct 2 Materials
- istail.c nottaillong.c Doing a lot of recusrion. Change the stack size using ulimit -s unlimited
- p2.c l04.c strcpy and strcat. p2 cwas not discussed in class. It has lots of examples. l04 includes the use of #if to condifitionally include / exclude some code (this is a change from what I showed in class).
- Week 6
Review and Midterm 1
October 7 Materials
- p1.c Implementing a logging system using defines.
- aaa.c The inadvisability of casting pointers to a different type
- p3.c A couple of trace c output of the c program
- atof.cConvert string to float. (You should really use strtof from stdlib.h).
- Week 7
c: Structs, unions and enumsetc
Unix: regular expressions!
Read: Chapters 16 from King. Chapter 19 from Shotts.
Oct 21
Oct 22 Materials
- sunion.c Simple use of union conparing storage required by union and equivalent struct
- countn.c a complete implementation of Mondays lab
- weather.c Not shown in class. This creates a structure containing structures to hold the temperature data set.
- enumunion.c Using enum, union and struct to store string and numbers in a single array.
- wmoney.c Wizard money
- Week 8
c: Dynamic memory allocation
Unix: Archiving
Read: Chapters 17 from King. Chapter 18 from Shotts.
Oct 28
- rot13 === tr n-za-m a-z
- passbyval.c pass by value discussion
- reader1.cRead a file, line by line into dynamically allocated memory
- valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes EXECUTABLE
- reader2.c Revised version of reader1.c tha deals with the issues flagged by valgrind
Oct 30 Materials
- Week 9
c: Dynamic structures, function pointers:
Unix: network information, text processing:
Read: Chapters 17 from King. Chapter 16 and 20 from Shotts.
Nov 04
- myspeedbash script for getting the transfer speed of a file
- easysort.cSimple use of qsort
- weather2.c weather data reader using structs within structs. All in single file
- weather5sort.c WeatherDataSort.cWeatherDataSort.h weather data, broken up into struct and driver groupsings along OO style lines. Also, sorting weather data using qsort
- weather5sel.c WeatherDataSel.cWeatherDataSel.h weather data, broken up into struct and driver groupsings along OO style lines. Changed for writing a semi-generic selection method, that allows user to write a qsort like comparator method that is passed into the selection method
- MakefileMy makefile for the day
Nov 06
- pscptiny bash script for using scp. Uses bash command line args
- stack.cC implementation of a stack ... closely follows King
- queue.cA queue implementation that closely follows stack
- queuevoid.cA queue implementation using all void* pointers to make it full generic. This implementation is in no way tied to an underlying type, so it can, at the same time, store pretty much anything.
- Week 10
Review and midterm 2
In class answers Questions with answers for the "in class" questions.
- Week 11
c: Bitwise Operations; King ch 19
Huffmann codes
Nov 18
Nov 20
- Week 12
c: a little more with bits, King ch 19
Unix: bash scripting: king ch 24-29
Nov 25
- Week 13
In the beginning; text processing
Dec 2 discussion of sections 1-5 of "in the beginning was the command line"
Dec 4 -- Text Processing
Course Policies
Communication
Attendance and active participation are
expected in every class. Participation includes asking questions,
contributing answers, proposing ideas, and providing constructive
comments.
As you will discover, I am a proponent of two-way communication
and I welcome feedback during the semester about the course. I am available to answer questions, listen to concerns, and
talk about any course-related topic (or otherwise!). Come to
office hours! This helps me get to know you. You are welcome to
stop by and chat. There are many more exciting topics to talk
about that I won't have time to cover in-class.
Please
stay in touch with me, particularly if you feel stuck on a topic
or assignment and can't figure out how to proceed. Often a quick
e-mail, phone call or face-to-face conference can reveal solutions
to problems and generate renewed creative and scholarly energy. It
is essential that you begin assignments early.
Grading
There will be 6-8 assignments,
weighted equally in the final grading (see below). Assignments must be
submitted according to the instructions provided in each assignment.
At the end of the semester, final grades will be calculated as a
weighted average of all grades according to the following weights:
Exam 1: 16%
Exam 2: 16%
Exam 3: 18%
Lab Attendance: 10%
Assignments: 40%
Total: 100%
Midterms will be in class. Closed book, closed notes, no electronic devices.
The final will be self-scheduled during exam week. It is intended to be more of a third mid-term than a true final.
Incomplete grades will be given only for verifiable medical
illness or other such dire circumstances.
Technology in the classroom
The class meetings/lectures will be a place to learn the concepts that are a part of the syllabus. I will, in the course of a lecture, write code on the board, and/or even do some live coding in class. The objective of this is to illustrate to you how to go about applying the concepts in practice. It is NOT a place for you to open your laptops and start to code with me. In fact, you are encouraged NOT to bring your laptops to class to use them for any purpose. It is distracting to other students. Phone (smart or otherwise) and tablet use during class meetings is also strongly discouraged. Listen, understand, ask questions, and take notes in a notebook if you need to. You will learn more! You will be doing coding in the labs under my supervision.
The assignments in this course are a place for you to exercise your learning of the concepts and apply them in actual working programs. The best way to get the most of of this course is to try out and code the concepts learned in the class (outside the class!). Do not be afraid to try things! This will improve your understanding and raise questions that you should feel free to bring forward in class. A quick word of advice: stay abreast of the material covered in class, and start your assignments on the day they are announced.
ALL work submitted for grading should be entirely YOUR OWN. Sharing of programs, code snippets, etc. is not permitted under ANY circumstances.
Submission, Late Policy, and Making Up Past Work
All work must be turned in either in hard-copy or electronic
submission, depending on the instructions given in the
assignment. E-mail submissions, when permitted, should request
a "delivery receipt" to document time and date of submission.
Extensions will be given only in the case of verifiable medical
excuses or other such dire circumstances, if requested in advance
and supported by your Academic Dean.
No assignment will be
accepted after it is past due.
No past work can be "made up" after it is due.
No regrade requests will be entertained one week after the graded work is returned in class.
Exams
There will be three exams in this course. The exams will be
closed-book and closed-notes. The exams
will cover material from lectures, homeworks, and assigned
readings.
Study Groups
I encourage you to discuss the material and work together to
understand it. Here are some thoughts on collaborating with other
students:
- The readings and lecture topics can be group work. Please discuss
the readings and associated topics with each other. Work
together to understand the material. I highly recommend forming
a reading group to discuss the material -- I will explore many
ideas and it helps to have multiple people working together to
understand them.
- It is fine to discuss the topics covered in the homeworks, to
discuss approaches to problems, and to sketch out general
solutions. However, you MUST write up the homework answers,
solutions, and programs individually without sharing specific
solutions, mathematical results, program code, etc. If you
made any notes or worked out something on a white board with
another person while you were discussing the homework, you
shouldn't use those notes while writing up your answer.
- Under ABSOLUTELY NO circumstances should you share computer
code with another student, printed, electronic, or otherwise. Similarly, you are not
permitted to use or consult code found on the internet for any
of your assignments.
- Exams, of course, must be your own individual work.
If you have any questions as to what types of collaborations are
allowed, please feel free to ask.
Links
Learning Accommodations
Students requesting accommodations in this course because of the impact of disability
are encouraged to meet with me privately early in the semester with a verification letter.
Students not yet approved to receive accommodations should also contact Deb Alder,
Coordinator of Accessibility Services, at 610-526-7351 in Guild Hall, as soon as possible,
to verify their eligibility for reasonable accommodations. Early contact will help avoid
unnecessary inconvenience and delays.
This class may be recorded.
Created on August 1, 2019.