CS 250 - Computer Organization: Software
Homework Project 1: Programming under Linux
Last modified at 7:10 AM on 1/28/02.
Due: beginning of lab, 4/5 Feb.
You will be given some time to work on the programming exercise in your lab period during the
week of 28 January 2002.
You should be able to get a good start on this exercise during the lab session.
I intend for this to be a "hands on" lab period. Do not spend too much time
trying to figure out how to do things. Dive in and give it a try. I want you to
make most of your mistakes during the lab session so that you can complete the
project on your own.
Practice these skills during the week. You will be using them a lot during this semester,
so it is worth your time to get good at it now.
Objectives
- Learn how to work with binary numbers.
- Become familiar with the web site for this class.
- Introduction to Linux.
- Introduction to emacs.
- Learn how to submit projects.
Exercises
The answers to the following exercises are to be written by hand on paper
and submitted at the beginning of lecture on Monday, 4 February.
Show your work and highlight your final answer for each problem.
-
Exercises 2.1 - 2.4, 2.10 - 2.16 in the textbook.
The following programming project is to be submitted in
my drop box as directed:
-
Make sure that your lab computer is running Linux; if not, see the
instructions below for booting into Linux.
-
Open a Terminal window. You should see an icon in the panel at the
bottom of the screen that looks like a computer terminal; click once
on it.
-
Make sure that you are in the "student" directory. You can use the
"pwd" Linux command to see where you are. If not, the "cd" Linux
command with no argument should get you there.
-
Create a new directory for your homework project. Be sure to follow the
naming conventions given in Programming Projects.
-
Use cd to move into your new directory.
-
Create a file named "README" with your favorite editor program. For example, if you
use emacs, the command is:
emacs README
-
For this project your README file should include:
-
The name of this file (README).
-
The class number (cs 250) and project number (1).
-
Your name.
-
Your lab section number.
-
The date the project is due.
Don't forget to save your work often (ctrl-x then ctrl-s)
often as you work.
-
A list of the classes you have taken as prerequisite or recommended
for this class, where you took each class, and the grade you
earned in the class.
Please note that I will enforce the prerequisites for this class. If do not
have the prerequisites, I will disenroll you.
-
The email address where you prefer to receive email related to this
class. (If you prefer not to be on my "spam" list for this class,
state so.)
-
Save your README file. I find it simpler if I quit emacs when
I want to stop working on a file and restart it to work on the next file.
That way I don't have lots of windows all open at the same time. The
system is pretty fast, so you shouldn't lose more than a couple of
seconds.
Don't forget to use ls -l and pwd often to get a feel
for the files you are creating and where you are in the directory
structure.
-
Create a file named "helloWorld.c" and copy the C program from Figure 5.4
in the textbook.
Use your own name and today's date in the documentation header so you
can start getting used to my documentation requirements. (I promise not
to sue you for copying my work on this program.)
-
Compile the source file with the Linux command
gcc -g -c helloWorld.c -o helloWorld.o
The "-c" options causes the compiler to simply compile the source and
produce an object file without linking it. You will learn more about the
details during the first few weeks of the class.
-
Link your new object file, helloWorld.o with the Linux command
gcc helloWorld.o -o helloWorld
-
Run your program with the Linux command
./helloWorld
Depending on how your PATH variable is set up in your account, you may
not have to use "./" before the program name. However, it's safer to simply
get in the habit of using it.
-
Add to the README file so that meets the standards detailed in
Programming Projects.
-
Delete all the files in your directory except "README" and "helloWorld.c".
- Note:
- No makefile is required for this project.
We will probably start working on them next week.
-
Move up one level from your directory with the Linux command
cd ..
-
Create a compressed archive of your directory, which should include only
the README and helloWorld.c files, with the Linux command
tar cvfz your_directory_name.tar.gz your_directory_name
-
Copy your compressed archive to your Linux account.
-
Use the Linux command:
scp archive user_name@linux.cs.sonoma.edu:/home/user_name/archive
-
When asked if you wish to continue, answer "yes."
-
When prompted, enter your linux.cs password.
-
Copy your compressed archive to my deposit directory.
-
Log on to your linux.cs account with the Linux command:
ssh -l user_name linux.cs.sonoma.edu
-
Copy the compressed archive with the Linux command:
cp archive /home/bob/250_drop_hw1_section_no
-
Delete your compressed archive and your directory from the lab computer.
Rebooting a lab computer into Linux when Windows NT is running:
-
If not logged on:
-
Begin Logon.
-
Click on Shut Down...
-
Select Shutdown and Restart and click OK.
If logged on,
use the "Start" menu in the lower, left corner to restart
the computer.
-
You need to watch the screen for the decision to boot into Linux
instead of Windows NT. Make sure that you select Linux.
-
After Linux boots up, make sure that the mouse cursor is in
the Welcome dialog box and log on with the user name "student".
No password is required.