Dana Vrajitoru
C151 Multi-User Operating Systems
Homework 5
Due date: Tuesday, September 30, 2008.
Display the content of the environment variable called PATH.
Ex. 1
- Copy the following archive into your c151 folder:
~danav/temp/c151/phil.tar.gz
Decompress this file. You should find a folder called phils. Go to
this folder.
- Identify the source files and the header files in this
folder. Compile each of the source files (.cc) one by one to obtain
the objects. You will need the command g++ with the option -c for
that.
- Link all the objects together and create and executable called
phils. For this part you'll need to like the following libraries in
your program:
libpthread.a
Run the executable to test the program. The program will ask for a
number of iterations. Enter something small, like 10. The program does
a small simulation and outputs some statistics.
- Note that this folder contains a file named Makefile. Identify
some of the units in this Makefile (for yourself to make sure you
understand them)). Find the entry called clean in this
Makefile. Invoke this entry with the make command. Make sure that your
executable and your objects have been deleted.
- Compile the project again using the command make. Make sure the
objects have been recreated as well as the executable. Run the program
again to see if the result is the same.
- Using whatever editor you want, add an entry to the Makefile
called run. List no dependencies for this entry and list just one
command which should contain the name of the executable. Run the
program again using the entry in the Makefile that you have just
created.
- Save the content of your terminal so far into a file called
hw5.txt. You'll have to send it to me by email.
Ex. 2 Write a Makefile compiling the file sum_array.cc that
you copied into your directory for lab3. This
Makefile should contain the following entries:
- default - this entry should list sumar as a dependency and not
invoke any other commands.
- sumar - this should list the file sum_array.cc as a
dependency and call the compiling command seen in the lab 3. Note that
since we only work with one file here, there's no need to create
separate objects.
- clean - this should delete the executable.
Add a comment at the beginning of the Makefile with your name, the
date, and a small comment on what this Makefile is for. Verify that
all the entries work, as well as "make" with no argument.
Send me the Makefile by email, as well as the
Ex. 3 Answer the following question in the email with the
homework submission: what does the following compilation command do?
Exmplain all the elements of the command:
g++ main.o cube.o -I/usr/include/gl -L/usr/lib/gl -lglut -o cube
Send me: From the lab: the Makefile created in class. From
the homework: the file hw5.txt from exercise 1, the Makefile from
exercise 2, and the answer to the question at exercise 3.