CSC 539: Operating Systems Structure and Design
Fall 2003

HW1: OS and Computer Structure


  1. Complete the following exercises from the text: 1.4, 1.6, 2.2, 2.9


The following questions concern the simple batch/multiprogramming simulator discussed in class. The simulator reads in a collection of jobs from a file, with each job specified by an arrival time, ID number and job length. It stores the jobs in a queue and processes them in order. By changing constants, the delay time between jobs and the time slice alotted to each job in turn can be adjusted. Source code for the simulator can be viewed and downloaded by clicking on the following links and cut-and-pasting into the Visual C++ .Net editor:   multi.cpp,   Queue.h,   Job.h,   Job.cpp,   JobStream.h,   JobStream.cpp,   jobs.dat.   (If you would like a quick review of useful C++ classes and libraries, some of which may be new to you, see CSC539 REVIEW SHEET: C++ Classes & Libraries.)

  1. Build a C++ project and execute the simulator on the provided job data file (jobs.dat). To simulate a batch environment, set the TIME_SLICE and LOAD_DELAY to be high (1000 and 5, respectively). Likewise, to simulate a simple multiprogramming environment, set these constants to lower values (5 and 1, respectively). Print the log of each execution and hand them in with the assignment.

    Note: you can copy the contents of the output window by right-clicking within the window, selecting Select All from the menu, and then pasting that text into whatever text editor or word processor you choose.

  2. Create a data file with the following jobs, and provide printouts of execution logs using the batch (TIME_SLICE = 1000, LOAD_DELAY = 5) and multiprogramming (TIME_SLICE=5, LOAD_DELAY=1) settings from above. Assume that all jobs arrive at time 1. JOB # LENGTH --------------- 1 20 2 4 3 7 4 31 5 3
  3. Suppose that our only concern was minimizing the time it takes to complete all of the jobs. To minimize the total time, which makes more sense: increasing or decreasing the TIME_SLICE? Justify your answer, with references to specific data where applicable.

  4. While the total time to complete all jobs is relevant in a batch environment, a more meaningful measure in a multiprogramming environment is the average time to completion for all the jobs. Modify the multi.cpp program so that it computes the average time to completion and displays this value at the end. For example, if JOB 1 finished at time 6, JOB 2 finished at time 14, and JOB 3 finished at time 19, then the average time to completion would be (6 + 14 + 19)/3 = 13.

    For each of the job data files above (the provided sample file and the new job data from Exercise 3), report the average time to completion for jobs using the batch and multiprogramming settings.

  5. Which type of environment, batch or multiprogramming, tends to do better with respect to average completion time? Does that environment always do better, or can you cite specific examples where it is actually worse? Justify your answer, with references to specific data where applicable.

  6. Does the order of the jobs affect the average completion time? That is, is it possible to shuffle the order of a collection of jobs and obtain significantly different results? If so, which environment (batch vs. multiprogramming) is more susceptible to order variation? Justify your answer, with references to specific data where applicable.