CSCI 237
Computer Organization
Home | Schedule | Assignments | Links | Williams CS
PRE-LAB Assignment 0
Please complete PRE-LAB Assignment 0 before your scheduled lab period. Note that there is nothing to turn in for this portion of the lab. The purpose of Pre-lab Assignment 0 is to get you familiar with a few of the tools that we will be using (git and ssh), show you how to compile a basic C program, and ensure that there are no hiccups logging in when we arrive to our first Lab meeting.
PRE-LAB Step 1: (Re-)Acclimating to Version Control Systems and Git
Please read these two quick documents that discuss what a version control system is and why you might want to use one (git is just one of many version control systems, but it is the one we will be using in this class). Even if you have already used git in a previous class, I still encourage you to review the main commands (in this class, we'll mostly be using clone, commit, push, and pull). And although understanding the purposes of those commands is essential, there is more to learning git than simply understanding the sequence of commands that you will use to submit your work. By understanding git's implementation and the underlying data structures that it uses, you will be better equipped to "debug" git issues that inevitably crop up from time to time.
For more technical details about git, this document on the git internals, written by Scott Chacon, worth reading before you graduate. It is somewhat long and involved, but it does a good job of explaining the details of the git model and its underlying implementation. I also believe the git internals material mostly appears in Pro Git, another good reference by Scott Chacon.
PRE-LAB Step 2: Accessing the CS Lab Environment
Our labs will be held in TBL 301, which contains about 20 Linux machines. You have one CS account that should work on any machine in any lab (including the Mac Labs). However, that that account is different than the account you use to log into the OIT-managed machines, such as those in libraries.
Your first task is to log in to one of the lab machines. You can do this in one of two ways. Option one is to physically go to the lab, find the most appealing computer, and pull up a chair.
Option two is to log in remotely using ssh. The exact steps depend on your Operating System, but you should open a terminal program, and log into one of the Linux machines using the pattern:
prompt> ssh username@machine.cs.williams.edu
For example, if your username is 27wkj2, and you wanted to log into the machine limia, you would type:
prompt> ssh 27wkj2@limia.cs.williams.edu
And then you would enter your password, followed by enter. Note that you will not see any characters when you type your password: this is a "security feature". If you are successful, the commands you type inside that terminal window will be run on limia, rather than your local machine. To later logout of the ssh session, execute the command exit or press Ctrl-d.
If you cannot remember your username or password, please email csaccounts@williams.edu, and cc cs237staff@williams.edu. We will get your account sorted. This is the most important step to complete before lab.
Now that you are logged in, there are a few git-related items that require a one-time setup. Specifically, you will likely want to set up your git configuration file (this is a one time thing that you will not need to do again).
prompt> git config --global user.email "williams-username@williams.edu" prompt> git config --global user.name "Your Full Name" prompt> git config --global push.default simple prompt> git config --global pull.rebase false prompt> git config --global core.editor emacs
In order to use git on our unix machines you also need to copy a certificate into your home directory and tell git where to find it. This is not something you would do on your personal machines.
prompt> git config --global http.sslCAInfo /home/cs-local-linux/certs/cacert.pem
These commands will create and update your `~/.gitconfig` file. This is a hidden file that keeps all the information git needs to know about your default setup. This hidden file is stored in your home directory and was created/updated by the `git config --global ...` commands you just ran.
PRE-LAB Step 3: Compile and Run a C Program
Once you have gained access to the lab environment, you should try to compile and run a basic C program. I encourage you to try to explore C on your own, but you can start by creating your own version of a simple program that appeared in the first lecture, which can be found here. Here are the basic steps:
prompt> gcc -o test test.cThat command asks gcc to create the output file "test" using the code found in "test.c"
test. This is your compiled program. To run it, type:
prompt> ./testThe "
." signifies the current directory,
so you are essentially typing the path of the executable file.
You should see output print to the screen.
That's it! There is nothing to turn in, and we will build a few C programs together at the start of Lab. However, exploring on your own and repetition are both essential to growing your comfort with any programming language, that is particularly true for C.
prompt> emacs test.cYou will not be able to use your mouse in emacs. Type
Ctrl+x, followed by Ctrl+s to save a file, and
Ctrl+x followed by Ctrl+c to save and close.
prompt> gcc -o output_filename -g input_filename.cThe -g is used for debugging. You will just use a Makefile most of the time, which is a file that specifies recipes for compiling code. However, you should know how to compile a C program without a Makefile, since that knowledge is needed to write the Makefile in the first place...