Lab 1: Remembering how to C

In 326, C sells C shells down by the C shore. Can’t you C it?

C is the lingua franca of OS development. This lab includes a series of exercises to help get the C flowing again.

Preparation

First, log into gojira and grab a copy of broken.c. The program is named after the brokenness of your professor’s spirit. If you’d like, you can download it directly with wget:

cd /raid/$(whoami)/
cd os-githubusername/user     # e.g., cd os-malensek/user
wget 'https://www.cs.usfca.edu/~mmalensek/cs326/assignments/code/broken.c'

This downloads broken.c to the ‘user’ directory of your OS repo.

Then you need to update the Makefile to build this new program, just like we did in the last lab. It should be called broken so we can run /broken and see the results. Note that the program will most likely crash in the state it has been given to you; that’s part of the “fun.”

Lab Instructions

The exercises in broken.c all have something wrong with them. Your job is to:

  1. Determine what the problem is
  2. Fix the problem
  3. Explain what was wrong (why the bug occurred) and how you fixed it. Edit the comments at the top of each function to give your explanation.

You can work on this lab with other students in class (please limit groups to 5 students max). Discussing the problems with others and experimenting is a good way to figure out what’s wrong. However, the final submission you make should represent your own work and ideas/thoughts – not a copy of someone else’s.

Grading and Submission

To receive 80% credit:

To receive full credit for this lab:

Once you are finished, check your changes into your OS repo. Then have a member of the course staff take a look at your lab to check it off. You may need to retry some of the problems if you missed something – so give yourself some extra time to finish this!