COSC 504: Efficient Computing Methods

Project 3
Spring 2004

Due: Oct 30 @ 5:00 PM
8 points

Implement a class for storing information about UNIX jobs, each of which consist of a user name, a process identifier (PID), a priority, a time, and a command, as the following shows:

root 1 0 15:45:08 -csh
root 167 40 16:43:22 /usr/sbin/inetd -s
maloof 5136 50 17:43:24 /usr/openwin/bin/fbconsole -d :0
maloof 5652 50 09:20:48 sdtperfmeter -f -H -t cpu -t disk -
Lower numbers correspond to higher priorities. You must also overload the stream extraction operator.

Implement a heap as a template class. To make it generic, you can either create a separate template variable for the object's priority, or you can specify that objects stored in the heap must implement a particular method, such as T::getPriority().

The main function should process two commands: insert (I) and remove (R). Insert commands are followed by the information for a job, and should insert the job into the heap based on its priority. Remove commands take no arguments, and should remove the highest priority item from the heap. The main function should print the jobs removed from the heap. Comment lines will begin with the pound character (#).

Instructions for Electronic Submission: At the top of the file main.cc (or the file containing the main function), place the following header comment, with the appropriate modifications:

//
// COSC 173 Project 3
// Name: <your name>
// ID: <GoCard ID>
// E-mail: <e-mail address>
// Instructor: Maloof
// TA: <TA's name>
//
// In accordance with the class policies and Georgetown's Honor Code,
// I certify that, with the exceptions of the class resources and those
// items noted below, I have neither given nor received any assistance
// on this project.
//

Although you may use any C++ compiler to develop your program, it must run on seva, under Unix, and must compile using GNU g++. You must also provide a working UNIX Makefile for your project.

You'll be using the submit program to submit your assignments. To get the submit program, on seva, type

cp /home/maloofm/submit.jar ./

Copies of the submit program from previous semesters will not work, so get a fresh copy.

If you haven't already, place all of your code in a subdirectory named p3. To create this subdirectory, type

seva% mkdir p3
To descend into the directory, type
seva% cd p3
All of the files for your project should be in this directory. The submit program should be above this directory:
seva% ls ..
p3/ submit.jar

If you need to include a message to the TA or me about your submission, then place the message in a file named README. Place the README file in the project's directory.

Before submitting, to reduce the size of the zip file, type 'make clean'.

To move up from the p3 directory, type

seva% cd ..
You should be above the p3 directory:
seva% ls
p3/ submit.jar

(Additional useful Unix commands)

When you're ready to submit, change the name of the directory to your netid. For example, if your netid is maloofm, then rename the directory p3 by typing

seva% mv p3 maloofm
Create a zip file of the directory and its contents by typing
seva% zip -r p3.zip maloofm/*
This command creates a zip file named p3.zip by recursively (-r) copying all of the files (*) from the directory maloofm/.

To submit the zip file type

seva% java -jar submit.jar -a p3 -f p3.zip
p3 is the name of the assignment (-a) and p3.zip is the file (-f) to be submitted for that assignment.

If the program submits the file successfully, you will receive a receipt by e-mail at the address <netid>@georgetown.edu.

Submit your project only once.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., seva) that preserves the modification date and time. If we lose your project or the submission system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.

You can also change the directory's name back to the original name. For example,

seva% mv maloofm p3
Note that changing the name of the directory does not change the dates of the files in the directory. You can also remove the zip file from your directory:
seva% rm p3.zip

The TA who will be grading your projects this semester is listed on the main page. You must submit your project before 5 PM on the due date.

Plan B

Submit is pretty reliable, but it is software. If you're running submit correctly and you see an error message labeled as SEVERE, then it's time to execute Plan B by using mail to submit your project.

To accomplish this, assuming the file you want to submit p3.zip, type at the seva prompt

seva% uuencode p3.zip p3.zip | mail cosc173@cush.georgetown.edu
Briefly, uuencode encodes the binary file p3.zip as an ASCII file that can be transmitted as mail. This form of the uuencode command pipes the ASCII-encoded file through standard input and into (|) the mail command.

When we receive you mail, we will save it to a file and use uudecode to translate the ASCII-encoded file back to the original binary file. Virtually all mail clients automatically encode binary files in this way.