Project 0--CMPSCI 377 (Fall 2006) Worth: 5 points Assigned: Thursday, September 7, 2006 Due: 6:00 pm, Thursday, September 21, 2006 1 Overview This project will give you experience writing a simple C++ program using the STL. You will write a small program that reads a list of processes and execution lengths from a file. You will "run" these jobs for small periods of time until they complete. 2 Process Scheduler Your will be simulating an extremely simple process scheduler. This scheduler takes a list of jobs and schedules them on the CPU. You are responsible for running them in order and printing out the order of events that occur in the system. Processes are run for a "quantum" of time each. If they still have more processing to do, they must wait their turn. Processes are run in a fair FIFO manner. If a process does not need the entire time, it still uses the processor for an entire quantum. A process must have at least some work to do to use a quantum (i.e., having zero work to do, does not use a quantum). All processes are ready to run at time zero. A real process scheduler would be much more complex: not all jobs would begin a t the same time, and not all jobs would be CPU bound. 2.1 Input Your program will be called with two command-line arguments. The first argument specifies the length of the quantum. It will be an integer type. The second argument specifies the input file name. Here is a line of code that reads the file: input >> process_id >> proc_time; The input file contains a series of process ids with the amount of time required by each. 3.2 Output Before running each process, your program should print out the current time, process id, and the amount of time the process needed (this may not be the full quantum). The output should be printed with: cout << time << " " << process_id << " " << required_time << endl; IMPORTANT: Your program should not generate any other output. 3.3 Sample Input/Output Here is an example input file test.in test.in ------- 5 10 2 5 Here is the correct output from the program when run ./scheduler 5 test.in ------------------------------------------------------------------------------- 0 5 5 5 2 5 10 5 5 3.4 Tips Leaking memory is a bug. Use an STL queue to hold the processes. 4 Project Logistics Write your scheduler in C++ using Linux. Use g++ (/usr/bin/g++) to compile your programs. You may use any functions included in the standard C++ library, including (and especially) the STL. You should not use any libraries other than the standard C++ library. We will compile your scheduler with "g++ -o scheduler scheduler.cc". Your scheduler must be in a single file and must be named "scheduler.cc". 6 Grading, Auto-Grading, and Formatting To help you validate your programs, your submissions will be graded automatically, and the result will be mailed back to you. You may then continue to work on the project and re-submit. The results from the auto-grader will not be very illuminating; they won't tell you where your problem is or give you the test programs. The main purpose of the auto-grader is it helps you know to keep working on your project (rather than thinking it's perfect and ending up with a 0). The best way to debug your program is to generate your own test cases, figure out the correct answers, and compare your program's output to the correct answers. This is also one of the best ways to learn the concepts in the project. You may submit your program as many times as you like. However, only the first submission of each day will be graded and mailed back to you. Later submissions on that day will be graded and cataloged, but the results will not be mailed back to you. See the FAQ for why we use this policy. In addition to this one-per-day policy, you will be given 3 bonus submissions that also provide feedback. These will be used automatically--any submission you make after the first one of that day will use one of your bonus submissions. After your 3 bonus submissions are used up, the system will continue to provide 1 feedback per day. Because your programs will be auto-graded, you must be careful to follow the exact rules in the project description. In addition to the auto-grader's evaluation of your programs' correctness, a human grader will evaluate your programs on issues such as the clarity and completeness of your documentation, coding style, the efficiency, brevity, and understandability of your code, etc.. Your final score will be the product of the hand-graded score (between 1-1.12) and the auto-grader score. 7 Turning in the Project Use the submit377 program to submit your files. The full name is /courses/cs300/cs377/cs377/bin/submit377, but you should add /courses/cs300/cs377/cs377/bin/ to your path (see the FAQ) so you don't have to keep typing in the full name. submit377 submits the set of files associated with the project part and is called as follows: submit377 0 ... Here are the files you should submit for each project part: 1) process scheduler (project-part 0) a. C++ program for your process scheduler (name should end in ".cc") example: submit377 0 scheduler.cc The official time of submission for your project will be the time the last file is sent. If you send in anything after the due date, your project will be considered late (and will use up your late days or will receive a zero). Each group member will evaluate the contributions made by each person in the group. The course home page will have a link to a web form where you can enter your evaluation.