CMPS 105: Systems Programming
Spring 2005

Prof. Scott A. Brandt

Computer Science Department
University of California, Santa Cruz



6/7/05 - Office Hours This Week - I will hold office hours from 9-12 on Wednesday. Feel free to drop by during that time for help with your final project.

6/7/05 - Pthreads - Here is some working pthread code, if anyone wants an example. It also uses semaphores to force the threads to alternate. That isn't necessary, or even useful, unless the two threads are actively accessing shared memory. Remember to compile it with -lpthread -lrt.

5/25/05 - Due dates - Assignment 5 is due Monday, May 30 at midnight. The final assignment will be due Wednesday, June 8 at midnight (and will be posted by Monday).

5/24/05 - Friday - As I announced in class, there will be no class on Friday (5/27/05) as I will be jointly hosting our 3rd Annual Storage Systems Research Center Retreat. In lieu of class, each of you should attend at least one technical talk at the retreat. For homework 10, email me a very brief summary of the talk you attend. Here is the agenda. The retreat will be held in the Simularium on the first floor of E2. One note - although the agenda lists meals, I am regrettably unable to invite you all to join us for that portion of the proceedings.

5/3/05 - The midterm - As I announced in class on Monday, the due date for the midterm is now Friday, 5/5/05.

4/27/05 - My solution to Assignment 3 is available here.

4/27/05 - The midterm is available here. It is due Wednesday, May 4, at midnight.

4/27/05 - My solution to Assignment 2 - is available right here. The code I used to create the files is available here.

4/25/05 - The code demonstrating race conditions in threads is available here.

4/20/05 - The midterm - It was decided in class today that the midterm would be a take-home exam. It will combine programming, like the programming assignments, with questions, like the homeworks. The midterm will be posted on the website by Wednesday, 4/27/05 and will be due a week later.

4/20/05 - Assignment 3 - is due Tuesday, 4/26/05, at midnight.

4/14/05 - My solution to Assignment 1 - is available right here.

4/13/05 - Assignment 2 - the due date for assignment 2 has been extended. It is now due Sunday night 4/17/05 instead of this Thursday night.


Time: MWF 3:30-4:40
Location: Baskin 156
Instructor: Prof. Scott A. Brandt (
Office / Office Hours: E2 347B / W 1:00-3:00
TA: None
TA Office/Office Hours: N/A
Lab Hours: TBD
Prerequisites: CMPS 101 and CMPE 12C/L
Required Text: Advanced Programming in the Unix Environment, W. Richard Stevens
Optional Texts: UNIX Systems Programming for SVR4, David A. Curry
  Practical UNIX Programming: A Guide to Concurrency, Communication, and Multithreading, Kay. A. Robbins and Steven Robbins
Course Web Page:

Course Objectives

This course will cover the fundamentals of systems programming including standard tools, shell programming, file I/O, files and directories, system data files and information, unix processes, process control, synchronization, signals, event-driven programming, terminal I/O, daemons, interprocess communication, basic network programming, and basic user-interface programming. We will also discuss program efficiency, portability, and related issues.


  • There will be weekly homework assignments worth a total of 10% of your grade.
  • There will be 6-8 programming assignments worth a total of 40% of your grade.
  • There will be a midterm exam approximately halfway through the quarter worth 20% of your grade.
  • There will be a comprehensive final exam worth 30% of your grade.

    Overall grading will roughly follow a 90/80/70/60 scale, but I may adjust the curve upward or downward as appropriate.

    Note: You must average above 50% on the homework/programming assignments and on the exams in order to pass the class. Lower than 50% on either portion of the class will result in a failing grade regardless of the overall score. Be aware that this is a necessary but not sufficient condition for passing the class — averaging above 50% does not guarantee a passing grade.


    Homeworks will be questions taken from the book and are mostly intended to make sure that everyone is reading the book and understanding the material from each chapter. Homework will be graded on a 0/1/2 scale. No homework or homework that does not demonstrate comprehension of the material will receive a 0. Homework that demonstrates reasonable comprehension of the material will receive a 1. Homework that is extremely well done (i.e. I couldn't have done it better myself) will receive a 2. A 1 represents full credit, so 2's will be rare.

    Three things you should know about homework in my classes:

    1. Even though each homework is only worth 1% of your grade, the homeworks as a whole are worth 10% of your grade. This is equivalent to a full increment.
    2. It is my experience that those people who do well on the homeworks do well on the exams, and people who do not do well on the homeworks do poorly on the exams. You are therefore strongly encouraged to do the homework.
    3. The homework problems are a relatively small subset of the problems in the book. If you want to do really well on the exams, I encourage you to do some or all of the other problems in the book and discuss the answers with others in the class. Feel free to discuss these on the class newsgroup as well.

    Programming Assignments

    This is a programming oriented course and the programming assignments are a key component of the course. If all goes as planned, you will be implementing a number of systems programs including a shell, a chat program, and others. Everything will be written in C to run on the Solaris operating system running on the Sun computers in some of the UCSC computer labs and on (which you can log into remotely).

    A very important point: The operating systems we are using, Solaris, is different from the one described in the book. Almost all of the functions exist, and almost all of them are the same, but there may be differences. To deal with this, you are going to have to become conversant with the man (short for "manual") program in Unix. man is used to read the manual page for Unix library functions and systems programs. If you haven't used man before, try it now on man itself by typing "man man" one one of the CATS systems (for instance,

    The programming assignments will be evaluated on several factors:
  • Documentation: your code must include a design document describing your solution and must be well-commented.
  • Correctness: your code must do what it is supposed to do.
  • Structure: your code should be broken into natural functions and modules.
  • Style: your code should be easy to read, well indented, well commented, and use clear, self-explanatory variable and function names.
  • Your grade for each assignment will be based on your design (40%) and your code (60%). Good design and documentation are absolutely crucial for this class because of the difficulty of the concepts.

    You may work on your programming assignments on any computer you wish but your assignments must work in the environment on the CATS system. The tools (simulator, cross-compiler, assembler) are installed on the CATS instructional cluster (Solaris machines). If you choose to work on another matchine, we will be unable to help you when difficult problems arise. The reason is that systems programs are often specific to a particular operating system and the problems may be specific to a particular machine.

    Due dates and lateness:

  • Homeworks and programming assignments are at midnight on the date specified.
  • Late homeworks and programming assignments will not be accepted unless due to true emergencies.
  • Graded homeworks and programming assignments will be returned as soon as possible, usually within one week.


    Class attendance is mandatory. I will post homeworks, assignments, and important dates on the class web page, but this is provided as a courtesy and is not always complete. It is your fault if you miss something important because you skipped class.

    Lab attendance is also mandatory. You will miss important material on the programming assignments if you do not attend. This is where the programming assignments will get discussed in detail.

    Office hours are optional. They are your chance to ask the professor and the TAs questions about the material being covered, the programming assignments, etc.

    Academic Honesty: Collaboration vs. Cheating

    This really should not be an issue, but recurring events have made the following necessary.

    You are encouraged to discuss the course material and concepts with other students in the class. However, all work that you submit must be your own. Under no circumstances may you look at anyone else's code or show anyone else your code. And while you may discuss the concepts and techniques used in the programming assignments, you may not discuss implementation details of the assignments themselves.

    If you are caught copying or otherwise turning in work that is not solely your own, you will fail the course and a letter will be sent to your Department, the School of Engineering, and to your Provost and academic preceptor.

    The bottom line is that you are expected to conduct yourself as a person of integrity — you are expected to adhere to the highest standards of academic integrity. This means that plagiarism1 in any form is completely unacceptable. As a (soon to be) computing professional, I encourage you to consult the code of ethics appropriate to your discipline2.

    Plagiarism will be assumed until disproved on work that is essentially the same as that of other students. This includes identically correct, incorrect, off-the-wall, and highly unusual duplicate answers where the probability of a sheer coincidence is extremely unlikely. All parties to this unacceptable form of collaboration will receive the same treatment.

    You should bring a picture identification with you to all examinations and be prepared to show it upon request.

    If you are unsure of what is and is not allowed by this policy, talk to the professor or TA.

    1 pla-gia-rize vt. to steal and pass of as one's own (the ideas or words of another) to present as one's own an idea or product derived from an existing source - pla-gia-riz-er n. (source: Webster's New World Dictionary).
    2 The Association for Computing Machinery is, the IEEE is and the IEEE Computer Society is

    Getting Answers to your Questions

  • Attend class and labs regularly
  • Check the class web page frequently - we will post as much information as we can
  • Read the class newsgroup: ucsc.class.cmps105
  • Meet with the professor and TAs during office hours
  • Email the professor and TAs
  • Please do not drop by or call on the phone outside of office hours. As much as we enjoy teaching, we also have other responsibilities. During class, lab, and office hours, we are yours, but at other times we would prefer it if you only drop by if you have previously arranged an appointment.

    Class Schedule

    This is a loose schedule for the class. This page lists all assignments, due dates, and reading material by date. This schedule is tentative, and will be adjusted periodically to reflect how far we've gotten in class. In other words: This schedule is subject to change through the quarter. Assignment dates and due dates may be modified depending on the pace of the class.

    Dear Class,
    It seems that despite the disclaimer above, too many
    people expected the class to exactly match the tentative
    schedule, especially those people who have been skipping
    class. To avoid any further confusion, I thought it best to
    just remove it entirely. Please attend class to find out when
    things will be due.

    Your Professor,

    Telephone: (831) 459-5042 / FAX: (831) 459-4829 /