Thread: Assignments
View Single Post
Old 03-03-2005, 07:05 PM   #8
NeKromancer
Newbie

 
Join Date: Feb 2005
Location: ,
Posts: 21
Send a message via MSN to NeKromancer
Default

Here is an assignment I had done a few years ago.

Quote:

OPTION1: SIMULATION OF A SIMPLE SPOOLING SYSTEM
GOAL:* SCHEDULING POLICIES IMPLEMENTATION

As you are surely aware, each of our labs has a printer and a number of computers.
The users who sit in front of their machines occasionally issue a PRINT command
which causes one of their files to be printed. The users are unaware of each other's
work in general, and who is about to print what and when in particular. Each user
issues her or his print request at whim.

It goes to reason that users cannot access the printer simultaneously - the printouts so obtained would contain gibberish and so would be perfectly useless. The piece of software arbitrating the use of the printer is called the "Spooler". ("SPOOL" is an acronym for Simultaneous Peripheral Operation On-Line).

The spooler works as follows:

The PRINT command submits to the spooler the file to be printed. The spooler queues
the print requests and makes sure that all files get printed in an orderly fashion.

There are a number of possible organizations of the print queue:

1. FIFO: The printouts are produced in the order in which the print requests
were issued. The problem with this approach is that a number of short print jobs
may be made to wait uncomfortably long for a large print job submitted before them.

2. SPJF: Shortest print job first. In this approach the print queue is sorted in
ascending order of printout size (size= pages). This methodology favors short print jobs at the expense of longer jobs, which may languish in queue for uncomfortably long
periods of time. (Actually, some universities like this approach as it forces
the students to conserve paper and to reduce printing cost).

3. PAPQ: Priority-aged print queue. The print queue is sorted in descending order
of print job priority P calculated as follows: P = A + B*T, where A and B are
carefully chosen constants, while T is the amount of time a print request spent
in the queue (counted in terms of the number of print jobs completed since joining
the queue).

In PAPQ model the job with the highest priority is to be printed next.
At the time of joining the queue the priority of each job is A (since T= 0). No job is allowed to linger in the queue indefinitely (its priority increases at rate B as it waits).

4. LBAQ: Length-based aged queue: Similar to PAPQ, but the priority P is
calculated according to the formula P = (A + B*T)/L where L is the length of the
document to be printed (in pages). In this way the priority of each job when
joining the queue is A/L, i.e. shorter jobs are given preference, but the* priority of all
jobs increases in time (although the rate of increase depends again on job size L).

Your task:

Consider the spooling system with a printer capable of printing 40 pages per
minute. The average print job is 4 pages long (assume Poisson distribution
here). It is obvious that the print system is capable of servicing the print
requests provided that they are less frequent than 10 per minute (Why?).

Write a brief program in Java to simulate the behavior of that spooling system
under the following scenarios:

1. FIFO: Plot the average turnaround time and the maximum turnaround time as a function of the print request frequency.

NOTE: Turnaround Time is the time elapsed between the moment the PRINT request
is issued and the moment the requested print job is completed.

2. SPJF: Plot the average turnaround time and the maximum turnaround time as
functions of the print request frequency.

3. PAPQ: Plot the average turnaround time and the maximum turnaround time as
function of the print request frequency, for selected values of parameters A and B.
The values of A to be considered are 0, 1, 2, and 4. The values of B are 1, 2, and 4.
Organize your plots in suitable groups.

4. LBAQ: Plot the average turnaround time and the maximum turnaround time as
function of the print request frequency, for selected values of parameters A and B.
The values of A to be considered are 0, 1, 2, and 4. The values of B are 1, 2, and 4.
Organize your plots in suitable groups.
You don't have to do the whole plotting crap, heh I didn't even bother with it cos I hate math but when I Got this I wrote the actual spooler simulation code and all the data structures for it.
__________________
Rdy to play even older game :P
NeKromancer is offline                         Send a private message to NeKromancer
Reply With Quote