Assignment 1 - Scheduling Simulation
Due: January 30, 2001
February 1, 2001
For
this assignment, we will be simulating the CPU scheduling for a computer
architecture with 64K of memory and 3 I/O devices. We will wish to simulate the long-term scheduler, the short-term
scheduler and the I/O scheduler of the computer using the
First-Come-First-Serve algorithm.
The
data will be a list of processes. For
each process, you will be given the job number, the amount of memory required
to run the process, the time the process arrives into the long-term scheduling
queue, the number of the I/O device to be used and the CPU and I/O bursts for
the process. All values will be integer
values. The first line of data will
contain the job number, the memory requirements, the arrival time and the I/O
device number. After those values, the
CPU and I/O bursts will be given and will be terminated by a value of -1. Note the bursts will be alternating between
CPU and I/O bursts, and the first and
last bursts will always be CPU bursts.
The following is an example of data for a single process:
2
18 4 2
5
16 6 9 2 12
4 8 2 15 6
-1
The
above process has job number 2, requires 18K of memory, arrives at time 4, uses
I/O device number 2, has 6 CPU bursts (of length 5, 6, 2, 4, 2 and 6) and 5 I/O
bursts (of length 16, 9, 12, 8 and 15).
You may assume that any process will have fewer than 100 total bursts
(CPU and I/O bursts combined). The
times are in milliseconds. The data
will be given so the processes are sorted by arrival time. Your program must directly read the data
from the file "mp1.data" that will be in the same directory as the
program. (I.E. This means you are to use fopen() and
fscanf() to read in your data.) Check out the following sample
data file.
While
the program is running, you are to print information about the system on the
screen. This information must include
your name, the current time of the simulation, the amount of available memory,
a list of processes that have been submitted but have not been selected by the
long term scheduler (call this the job pool), the processes currently using the
CPU and each of the I/O devices and the processes waiting for the CPU and each
of the I/O devices. You will do this
uses the functions in curses.h.
After
all processes have completed, you are to print out the following information
for each process: the arrival time of
the process, the time the process is selected by the long-term scheduler, the
time the process terminates, the turnaround time for the process and the wait
time for the process. After this has
been printed, you are to print the average wait time for all processes. This information is to be directly printed
to the file "mp1.report" that will be in the same directory as your
program. (I.E. This means you are to
use fopen() and fprintf() to print your results.)
Your
simulation is to assume that no time is spent to execute the various scheduling
algorithms and no time is spent switching to a wait queue. The assignment is expected to be the result
of individual work. You will submit the
project electronically using the turnin command.
A
summary about the curses functions will be given here. Curses is designed to given simple ASCII
character full screen manipulation to a program. More information can be found by using the man pages with the
keyword "curses". When
compiling your program you must explicitly name the curses library on the
command line. The library must also be
included in a #include statement. The
following functions will be needed.
initscr()
- this function is required to initialize the screen for use with the other
curses functions. This function call
must be done prior to using any other curses functions. This function only needs to be called once.
endwin()
- this function is required to return the original terminal state. This must be called before your program
exits.
move
(y, x) - this function musts the cursor to line y, column x on the screen.
clrtoeol()
- this function will erase the information from the line to the right of the
cursor.
printw
(fmt, arg0, arg1, . . . argn) - this function is used to write to the
screen. It begins writing at the
current position of the cursor. The
arguments are the same as the printf() function.
refresh()
- displays all of the written information since the last refresh() function was
called. Note: nothing gets displayed an
the screen until refresh() is called.
Your program should only refresh() the screen once for every millisecond
in the simulation.
Your
program must be able to run in two modes: automatic mode and step mode. Automatic mode will allow your program to
continuously run through the simulation without any interference/interaction
from the user. In order to give the
user time to view the changes to the system after each millisecond, your
program should use the usleep() function to pause the system for about half a
second (I think using the value of about 5000 should allow this to occur) after
the refresh() function is called. Step
mode will allow the user to control the speed of the simulation. After the refresh() function is called, have
the program wait for the user to press the ENTER key before it continues. Be sure in include a prompt that the user
must do this. When the program starts,
ask the user If they wish to enter automatic mode of step mode. See the
second Sample Curses Program for an example of this. Note for step mode: ONLY USE SMALL DATA
FILES! Otherwise you will be stepping
though a lot of code.
Your
program must be written in a good programming style. This is to include in-line
comments, a file header, function headers, blank lines, indentation, meaningful
variable names, readable output, etc.
The first two line of your file must comments stating how you compiled
your program on the EECS department's UNIX machines and how you ran your
program. You must also turnin a make
file that will compile your program. Check out the sample
makefile to be used with the sample curses programs.