CS360 -- Systems Programming

James S. Plank --- Spring, 2018

General Information


Professor: James S. Plank Teaching Assistants: John Reynolds (jreyno40), Ksenia Burova (kburova), Michael Goin (mgoin) and Chris Dean (cdean16).


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

Labs:

Grading is roughly 50% labs, 50% exams. Please see the final grades web page to see how grades were assigned last time I taught the course.

Lab grading policy is simple: You lose 10% of your grade for each day your lab is late. You may not submit your lab more than five days late.

Lab questions should be directed to the TA's first, and then me.


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 |                                | Michael 338 |             | Ksenia 317 |                         |
11:00 | Chris 338                      | Michael 338 | Chris 338   | Ksenia 317 | Chris 338               |
11:30 | Chris 338                      | Michael 338 | Chris 338   | Ksenia 317 | Chris 338               |
12:00 |                                | Michael 338 |             | Ksenia 317 | Ksenia 317 starts 12:15 |
12:30 |                                | John 317    |             | John 317   | Ksenia 317              |
-1:00 |                                | John 317    |             | John 317   | Ksenia 317              |
-1:30 | Lab 418 (Ksenia, Chris) S:1:25 | John 317    |             | John 317   | Ksenia 317              |
-2:00 | Lab 418 (Ksenia, Chris) E:2:15 | Class 524   |             | Class 524  | Ksenia / John 317       |
-2:30 | Lab 418 (John, Chris)   S:2:30 | Class 524   |             | Class 524  | John 317                |
-3:00 | Lab 418 (John, Chris)   E:3:20 | Class 524   |             | Class 524  | John 317                |
-3:30 | Lab 418 (Ksenia, John)  S:3:35 |             | Michael 338 | Chris 338  | Michael 338             |
-4:00 | Lab 418 (Ksenia, John)  E:4:25 |             | Michael 338 | Chris 338  | Michael 338             |
-4:30 |                                |             | Michael 338 | Chris 338  | Michael 338             |
------|--------------------------------|-------------|-------------|------------|-------------------------|

Lecture Notes

There are lecture notes for each lecture. These are available on this web site. Additionally, I am putting the lecture notes and programs on bitbucket, to make it easier for you to download, compile and execute the example programs.

web with a pointer hanging off the class home page. The point of lecture notes is to 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 online, 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. (In 2018, while I'm doing the move to bitbucket, I won't have lecture notes done until each lecture has been given, so you'll have to pull often.)

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


Labs

Besides the first week, whose lab will probably take the entire session, lab attendance is mandatory in the beginning, during which time the TA's will go over general things that you need to know. After that, you may leave or stay as you see fit. This is a very good time, however, 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.


Homeworks

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 Ubunto 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 nominal 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....

Piazza

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.


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 20+ 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.
   */


main()
{
  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: ");
  fflush(stdout);
  if (scanf("%d", &n) != 1) {
    exit(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.