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


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.


The following programming project is to be submitted in my drop box as directed:
  1. Make sure that your lab computer is running Linux; if not, see the instructions below for booting into Linux.
  2. 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.
  3. 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.
  4. Create a new directory for your homework project. Be sure to follow the naming conventions given in Programming Projects.
  5. Use cd to move into your new directory.
  6. Create a file named "README" with your favorite editor program. For example, if you use emacs, the command is:
    emacs README
    
  7. For this project your README file should include:
    1. The name of this file (README).
    2. The class number (cs 250) and project number (1).
    3. Your name.
    4. Your lab section number.
    5. The date the project is due.

      Don't forget to save your work often (ctrl-x then ctrl-s) often as you work.

    6. 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.
    7. 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.)
  8. 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.
  9. 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.)

  10. 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.
  11. Link your new object file, helloWorld.o with the Linux command
    gcc helloWorld.o -o helloWorld
    
  12. 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.
  13. Add to the README file so that meets the standards detailed in Programming Projects.
  14. 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.
  15. Move up one level from your directory with the Linux command
    cd ..
    
  16. 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
    
  17. Copy your compressed archive to your Linux account.
    1. Use the Linux command:
      scp archive user_name@linux.cs.sonoma.edu:/home/user_name/archive
      
    2. When asked if you wish to continue, answer "yes."
    3. When prompted, enter your linux.cs password.
  18. Copy your compressed archive to my deposit directory.
    1. Log on to your linux.cs account with the Linux command:
      ssh -l user_name linux.cs.sonoma.edu
      
    2. Copy the compressed archive with the Linux command:
      cp archive /home/bob/250_drop_hw1_section_no
      
  19. Delete your compressed archive and your directory from the lab computer.

Rebooting a lab computer into Linux when Windows NT is running:
  1. If not logged on:
    1. Begin Logon.
    2. Click on Shut Down...
    3. Select Shutdown and Restart and click OK.
    If logged on, use the "Start" menu in the lower, left corner to restart the computer.
  2. You need to watch the screen for the decision to boot into Linux instead of Windows NT. Make sure that you select Linux.
  3. 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.