CS360 -- Systems Programming

James S. Plank --- Spring, 2019

General Information

Professor: James S. Plank Teaching Assistants: John Reynolds (jreyno40), Chris Dean (cdean16), and Charlie Rizzo (crizzo).

Class TT 2:10-3:25 in Min Kao 524.


The weekly schedule

Here is the weekly schule of class, labs and office hours, rendered as ASCII art:
        Monday                           Tuesday       Wednesday     Thursday     Friday
10:30 |                                |             |             | John 317   |             |
11:00 |                                |             |             | John 317   |             |
11:30 |                                |             |             | John 317   |             |
12:00 | Charlie 217                    |             | Charlie 217 | John 317   | Charlie 217 |
12:30 | Charlie 217                    | Chris 217   | Charlie 217 | Chris 217  | Charlie 217 |
 1:00 |                                | Chris 217   | Charlie 217 | Chris 217  | Charlie 217 |
 1:30 | Lab 418 (John, Chris)   S:1:25 | Chris 217   | Chris 217   | Chris 217  | Chris 217   |
 2:00 | Lab 418 (John, Chris)   E:2:15 | Class 524   | Chris 217   | Class 524  | Chris 217   |
 2:30 | Lab 418 (John, Charlie) S:2:30 | Class 524   | Chris 217   | Class 524  | Chris 217   |
 3:00 | Lab 418 (John, Charlie) E:3:20 | Class 524   | John 317    | Class 524  | John 317    |
 3:30 | Lab 418 (John, Charlie) S:3:35 |             | John 317    |            | John 317    |
 4:00 | Lab 418 (John, Charlie) E:4:25 |             | John 317    |            | John 317    |
 4:30 | Charlie 217                    |             | John 317    |            | John 317    |
 5:00 | Charlie 217                    |             |             |            |             |


The grading policies are as follows.

Lecture Notes

There are lecture notes for each lecture. These are available on this web site and on bitbucket as a public repository. The idea is to make it easier for you to download, compile and execute the example programs. The lecture notes give you a hard reference for the things that we talk about in class, since we don't have a textbook.

All programs that I go over in class are online, on this web site, and on bitbucket. To get them on our lab machines, look in /home/plank/cs360/notes. To get them in bitbucket, go to a fresh directory, and then do:

UNIX> git clone https://jimplank@bitbucket.org/jimplank/cs360-lecture-notes.git
You can then cd to cs360-lecture-notes, and you'll have the lecture notes and programs on your machine. I suggest that whenever you want to reference the notes and programs, you start with git pull so that you can get any updates that I have made.

The point here is that you don't have to try to copy programs and notes in class, as that's a waste of your time.


Lab attendance is mandatory (see grading above). You don't have to attend the lab for which you are assigned -- you may attend any of them. In the beginning of the labs, the TA's will go over general things that you need to know, either for class or for the next lab. If they finish early, they will allow you to leave. However, This is a very good time to get an early start on the lab, and use the TA's to answer questions.

The homeworks are where you are going to learn the most in this class. They are going to require far more than 3 hours per week. Thus, you will have to use evenings or weekends to get machine time. Work this out.


Sorry, but I usually use the word "lab" for both lab sessions and homeworks. It's typically not hard to disambiguate.

Your TA's will tell you how to submit the labs.

You may talk with the TA's, other students, or me about your homeworks, but do the programming on your own. Copying other students' code is considered plagiarism.

The TA's will grade your code on the department lab machines. That means that before you submit your code, you should test it on the lab machines (hydras). If it works on your Ubuntu laptop, Windows laptop, your Macbook or your Pi, that is no guarantee that it will work on the lab machines. Port it and test.

The Textbook, and Its Code

The previous textbook for this class is "Advanced Programming for the Unix Environment," by Richard Stevens (updated by Stephen A. Rago). However, this is not required. It is a wonderful reference book for Unix hacking, and it contains much valuable information. My only complaint with it is that it goes so much into issues of portability and Unix standards, that sometimes you get lost in the overload of information. This happens --- after a while, you'll figure it out. Reading the textbook is kind of like reading man pages: It takes a while to figure out how to get information from it, but once you do, it becomes an extremely valuable reference.

All of the code in the textbook is available online in the directory /home/~plank/cs360/book_examples. This code was ported by a student a few years back, and I don't know if anyone made use of it. I never looked at it. However, if you are reading the book and would like to try its programs, that is the place to look.

Unix Man Pages

An extremely valuable set of resources in this class are the Unix man pages. These can be viewed online, by typing ``man xxx,'' where you want to learn about xxx. For example, try ``man cat'' to learn about all the things you can do with the program cat You will find that there are Unix tools for doing many things you'd like to do. The routines sprintf, sscanf, strcmp, strdup, atoi, and of course malloc will all be of great use to you throughout the semester. Read up on them. If you'd like to know if there is a man page on a certain topic, try ``man -k topic.'' Or read the man page for man....


The point of Piazza is two-fold: So, make a Piazza account and sign in to the class if you are not already signed up (I cut and pasted emails in their enrollment box).

Do not post code to Piazza, please.

I am not a fan of using Piazza to send private messages to me and the TA's, especially with code attached. Debugging is an interactive activity, so I believe that when you send code on Piazza, asking for us to find your problem, you are not learning how to debug.

TA's and Help

The primary place for you to receive help with your labs is during lab time and during the TA's office hours. The TA's have office hours every day from monday through friday -- use them!

Over the weekend, you're back on your own, and again you should solicit help and support from your classmates. You may try to email the TA's, but again, they may not respond. They have lives too.

Also, feel free to use piazza to communicate with your fellow students.

I shouldn't have to write this, but history requires me to. While I love you, and the TA's love you, this class is not our only responsibility during the semester. Similarly, you are taking other classes, so this class is probably not your only responsibility. Think about that when you do things. For example, a few years ago, a student resubmitted a late lab whose score was obviously going to be lower than his first submission. He submitted it because he was proud of finishing it, and wanted the TA to know. The TA, who was swamped with other classes, simply regraded the submission and gave the student the lower score. The student was outraged -- all he wanted was a pat on the back!! Who was at fault? Everybody had good intentions. However, the student should have used the proper channels -- if he wanted an "attaboy," he should have emailed the TA seperately or gone through office hours. This may seem picky, but a matter like this cost everyone time and emotional drama. Including me. The bottom line is to think about your actions before you do them.

Help Each Other!

You are all brothers and sisters in this class. While I'm not the biggest fan of interpersonal interaction and conversation, even I will admit that you learn many unexpected and valuable things through interaction. This is both when you are soliciting help and providing it. I encourage you to try to help each other.

My Pet Peeves

I go over these on the first day of class, but I figure it's time to write them down so that you have reference material. Every teacher has his/her own style, and after 25+ years of teaching, I know mine pretty well. This list doesn't apply to all teachers -- just me.

My Non-Pet Peeves

Commenting Your Code

You will be graded on commenting and indentation. Something like 15%. You should comment your code by blocks of comments at the beginning of your files, and before subroutines. Variables should be commented inline. You may also want to comment large blocks of code. You should not comment with a ``running commentary'' to the right of your code, because that is often useless, hard to maintain, and disconcerting. I have seen comments like the following:
  if (i == 0) {               /* If i equals zero */
    return;                   /* then return */
  } else {                    /* otherwise */
    exit(1);                  /* exit with a value of one */
The above is an extreme example, but don't let it happen to you.

Here's an example of what I would consider a well documented program (And, in 1998, it was a fine C program. It will generate some compiler warnings now).

#include <stdio.h>

/* sumnsquared.c
   Jim Plank
   August 23, 1998

   This program prompts for and reads a value n from standard
   input, and then calculates and prints the sum of squares
   from one to n.  It uses a for loop instead of using the 
   closed form expression.

  int n;                   /* The value */
  int sum;                 /* The running sum of squares */
  int i;                   /* An induction variable */

  /* Prompt for and read in a value of n */

  printf("Enter a value n: ");
  if (scanf("%d", &n) != 1) {
  /* Calculate sum for each value of i from one to n */

  sum = 0;
  for (i = 1; i <= n; i++) sum += (i*i);

  /* Print the final summation */

  printf("%d\n", sum);

Here's a guide on indentation that you may want to follow.