CSC 539: Operating Systems Structure and Design
Fall 2002

HW1: OS and Computer Structure

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

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 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++ editor:   multi.cpp,   JobQueue.h,   Queue.h,   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: it is possible to redirect the output of a Visual C++ program to a file instead of to the screen. To do this, select "Settings" under the "Project" menu, then click on the "Debug" tag. In the box labeled "Program arguments:", type a greater-than symbol followed by a file name. For example, typing "> batch.out" would cause program output to be written to a file named batch.out.

  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. JOB # LENGTH --------------- 1 20 2 4 3 8 4 30 5 2
  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.