CSC 539: Operating Systems Structure and Design
Fall 2002

HW2: System Simulation with I/O Interrupts


In HW1, you compiled and modified a simulation of a simple system. User jobs were assumed to be loaded all at once, and executed in order. By setting constants, either batch processing (large load delay between jobs, large time slices) or multiprogramming (small load delay between jobs, small time slices) could be simulated. For this assignment, you will extend this simulation program to model two new features of the system:

  1. user jobs may originate at different times, and
  2. input/output operations may generate interrupts, allowing other jobs to be loaded and executed.

User jobs will be entered in a file, as before, but the format of the file will be slightly more complex. Each line in the file defines a single job, starting with the origination time for the job, a colon, the job ID number, and the lengths of CPU bursts for that job. For example:

3: 1 6 3 5: 2 4 4 4 12: 3 10

Here, Job #1 originates at time 3. The job requires 6 units of computation, followed by an I/O operation, followed by another 3 units of computation. Job #2 originates at time 5, and requires 3 CPU bursts of 4 units each, separated by I/O operations. Job #3 originates at time 12 and requires 10 units of computation (with no I/O operations).

  1. A batch simulator that handles this new type of data file is provided for you in the following files:   batch.cpp,   JobQueue.h,   Queue.h,   PriorityQueue.h,   jobsIO.dat. The details of this program will be discussed in class. Similar to HW1, you are to add code to the batch.cpp program so that the average time to completion for jobs is computed and displayed at the end of the simulation.

  2. Using the default settings (LOAD_DELAY = 5, IO_DELAY = 3), run the batch simulator on the sample data file and print a log of the execution. Recall that you can direct the output of a Visual C++ program to a file instead of the screen by entering the appropriate arguments in the "Debug" tag under the "Project" menu.

  3. Next, create a copy of your multi.cpp program named multiIO.cpp which integrates the two new features of the system: different job origination times and I/O interrupts. You will need to borrow several elements from the batch.cpp program, including the queue of bursts for each job and a priority queue of jobs based on origination times. Your program will need to recognize when there are no current jobs, and also be able to interrupt an active job when an I/O operation is needed, allowing wating jobs to get access to the CPU. For example, the execution log given the sample data file above and default settings of TIME_SLICE = 5, LOAD_DELAY = 1, and IO_DELAY = 3 would begin as: 3: LOAD JOB 1 4: START JOB 1 9: TIMEOUT JOB 1 9: LOAD JOB 2 10: START JOB 2 14: I/O JOB 2 14: LOAD JOB 1 15: START JOB 1 16: I/O JOB 1 16: LOAD JOB 3 17: START JOB 3 . . .
  4. Using the default settings (TIME_SLICE = 3, LOAD_DELAY = 1, IO_DELAY = 3), run the multiprogramming simulator on the sample data file and print a log of the execution.

  5. Suppose you had a sequence of large, CPU-bound jobs. That is, all of the jobs were of roughly the same size and consisted of large blocks of computation with few I/O operations. Which system (batch or multiprogramming) would you expect to perform better? Justify your answer, with references to specific data where applicable.

  6. Suppose you had a mixed sequence of I/O-bound jobs. That is, job lengths varied and each job contained many I/O operations. Which system (batch or multiprogramming) would you expect to perform better? Justify your answer, with references to specific data where applicable.