// multi.cpp Dave Reed 9/20/03 // // SIMPLE multiprogramming simulator. A collection of jobs are read in from // a file, and then executed using timesharing. A job can be preemtped when // it requests an I/O operation, or when its time slice expires. /////////////////////////////////////////////////////////////////////////////// #include #include "Job.h" #include "JobStream.h" #include "CPUScheduler.h" using namespace std; const string JOB_FILE = "jobs.dat"; // FILE CONTAINING JOB DATA int main() { JobStream ArrivingJobs(JOB_FILE); // CREATE THE JOB INPUT STREAM CPUScheduler CPU; // CREATE THE CPU SCHEDULER int time = 0; // INIT THE SYSTEM CLOCK while (CPU.JobsRemaining() || ArrivingJobs.JobsRemaining()) { time++; // AS LONG AS JOBS TO PROCESS // INCREMENT THE CLOCK while (ArrivingJobs.JobHasArrived(time)) { // ENTER ANY NEW JOBS AND CPU.AddNewJob(ArrivingJobs.GetJob(), time); } CPU.Execute(time); // EXECUTE A CPU CYCLE } cout << "DONE PROCESSING" << endl; return 0; }