DBMS Implementation Technical Report

Document Sample
DBMS Implementation Technical Report Powered By Docstoc
					OS Project Technical Report
          Spring 2006
    Professor: Scott Graham

    Student: Bo Shao
               Miaohua Xu

      Monday, January 25, 2010
1. Introduction
In a multiprogramming environment that almost all of our current operating systems provide and
support, process scheduling is an essential part because it can have a significant effect on resource
utilization and overall performance of the system. Although many processes appear to the user to
run simultaneously, a single processor can actually execute only one process at any given period. It
is the job of an operating system to decide which process to run at the ready queue at a certain
period. To design a good operating system, one must design a good process scheduler.

It is hard, however, for an operating system to have a good process scheduler because it must fulfill
several conflicting objectives using a given policy: fast process response time, good throughput for
background jobs, avoidance of process starvation, reconciliation of the needs of low- and high-
priority processes, and so on [Ref 1]. When designing a scheduling algorithm or choosing a
scheduling policy, one must combine all these criteria, and get a good balance according to the
requirements of the user and system resources. Because this is a challenging but important job,
many scheduling algorithms have been proposed, revised, implemented and tested, and there might
still be new algorithms come out.

 There are many good and practical scheduling algorithms available nowadays, First-in-first-out
(FIFO) scheduling, Round-Robin (RR) scheduling, Shortest-Process-First (SPF) Scheduling,
Highest-Response-Ratio-Next (HRRN) Scheduling, Shortest-Remaining-Time (SRT) Scheduling,
and so on. But none is the best and each has certain advantages and disadvantages. According to
different requirements, different operating systems choose different scheduling algorithms to best
serve the needs of their customers.

In this OS course project which is mainly for practical purpose, we have only implemented three
basic process scheduling algorithms: First come, first served (FCFS), Round robin (RR) and
Shortest-Job-First (SJR). The algorithms themselves are not hard to implement, but the significant
idea for this project is to enable the application users be able to visually monitor how the system
run the processes using these different algorithms simultaneously, and how the performance of
each algorithm is according to their simulation. In order to reach this goal, we adopted the
visualization technique. Using visualization (the GUI), the VPS (Visualized Process Scheduler)
vividly shows how several scheduling algorithms work simultaneously. Generally speaking, our
VPS has following three main functions:

       Generating simulated processes
       Graphically running the processes using different algorithms simultaneously
       Performance evaluation

 In order to execute scheduling algorithms, a set of simulated processes has to be generated firstly.
Our VPS can let the user randomly generate the processes or customize the processes, and if the
user does not choose any of these, the system will generate a default set of processes. Then the user
can see how the processes run at the same time using these three algorithms and after the
simulation, our VPS will report the evaluation of these three algorithms.

                                                -2 -
2. Specification
2.1 GUI
As shown in the figure below, each large box represents an algorithm and each small column inside
the box represents a process. The length of column is determined by burst time of the process it
represents. By running the processes using the scheduling algorithms, some processes might have
run by CPU for a certain time and have been suspended. The black part inside the column
represents the time left that the CPU needs to finish the process later. The column would be red if
its process is running.

There are many other graphical user interfaces in this VPS system, and they are not described here.

2.2 Algorithms
Up to this moment, we have implemented the following three scheduling algorithms: First come,
first served (FCFS), Round robin (RR) and Shortest-Job-First (SJR).

                                               -3 -
FCFS algorithm is also called first-in-first-out (FIFO). It is fair to certain degree because processes
are dispatched only according to their arrival time, and once a process gets the resource of a
processor, it runs to completion.

Round-robin (RR) algorithm is an improved version of FCFS algorithm. The processes are still
dispatched according to their arrival time, but they are given a limited amount of processor time. If
a process does not complete in such a given time, the processor is given to the next waiting process.

 Shortest-Job-First (SJR) algorithm is also called shortest-process-first (SPF). In this scheduling
algorithm, the system selects the waiting process which is considered to have the shortest running
time needed to complete according to the estimation of the system.

 These are the three basic algorithms. Many current operating systems combine these algorithms or
derive some useful and practical scheduling policies. We implement them to show how they work
and how their performances.

2.3 Evaluation
After simulation and execution, our VPS report the evaluation of the three algorithms described
above. The criteria that we use include:

       CPU utilization - keep the CPU as busy as possible
       Throughput - number of processes that complete their execution per time unit
       Turnaround time - amount of time to execute a particular process
       Waiting time - amount of time a process has been waiting in the ready queue
       Response time - amount of time it takes from the moment a request is submitted to the
        moment the first response is produced (not output, for time-sharing environment)

Please refer to the experiments described later in this report to see the true performances of these

3. Implementation
3.1 Technical environment
C# and GDI+ is the first choice to do graphical programming.

According to Microsoft, "C# is a simple, modern, object oriented, and type-safe programming
language derived from C and C++. C# (pronounced 'C sharp') is firmly planted in the C and C++
family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to
combine the high productivity of Visual Basic and the raw power of C++."

GDI (Graphical Device Interface) created by Microsoft is to help with graphical interface
presentation on Windows platform. It is a set of classes, functions, variables, and constants that

                                                 -4 -
group all or most of the things you need to draw on an application. GDI+ is a system used to
perform drawing and other related graphics operations for the operating systems of Microsoft
Windows family. Its predecessor was the Graphical Device Interface (GDI), which has therefore
been replaced, namely with the new operating systems such as Windows XP and Windows Server
2003. The + in GDI+ indicates that it provides a significant improvement to GDI and adds new
features that were not available in GDI and were hence difficult to produce. GDI+ allows you to
create device-independent applications without worrying about the hardware on which the
application would run. GDI+ provides its functionality through three fronts: vector Graphics,
imaging and Typography [Ref 2].

3.2 Classes and Interfaces
We have 3 forms: the main form, set input processes dialog and aboutInfo dialog. These classes are
generated respectively.

3.2.1 Class Form1
Representing the main form, it has the following major functions (parameter omitted because of
not enough space):

         Methods                                         Description
void init()                 Initializes all variables
void panel1_Paint()         Draws the whole window
void DrawColumns()          Draws the boxes that represent processes
Void                        Draws turnaround time, waiting time and response time for each
DrawTurnWaitResp()          process for all algorithms
void DrawCPU()              Draws the CPU image
int fcfsGetNextRunProc()    Calculates the next process after a time unit elapses, based on
                            current environment, using FCFS algorithm
int sjfGetNextRunProc()     Calculates the next process after a time unit elapses, based on
                            current environment, using SJF algorithm
int rrGetNextRunProc()      Calculates the next process after a time unit elapses, based on
                            current environment, using RR algorithm
void Timer_Tick()           Be called when a time unit elapses. It will call the calculating
                            functions and paint functions.
void generateReport()       Generate report after all processes finish.

The running data flow is:

                                              -5 -
    start               Init()                             Proc. Finished / generateReport()   Stop


fcfsGetNextRunProc     sjfGetNextRunProc     rrGetNextRunProc        panel1_Paint

                                                       DrawColumns         DrawTurnWaitResp     DrawCPU

Moreover, we have the facility of Pause/Resume, Speed UP/Down, Next step (available when
paused). The implementation is trivial, so we do not document them here to avoid being distracted
from the main data flow.

3.2.2 Class setInputDlg
The form provides 3 radio buttons:

           Using default setting. The program will using the 9 default processes, with burst time of 2,
            32, 8, 15, 4, 3, 11, 9, 24
           Using the process in the textbox. The program will read data from the textbox, parse them
            to integer. Because of fault tolerance when the convention failed, the program will report a
            failure and keep live.
           Please generate a set of process for me. The program will read number of processes, min
            burst time and max burst time, and generate a set of processes of the number and range
            designated. The burst time are uniform distributed.

3.2.3 Class aboutInfoDlg
The class provides information of the authors, classes that the authors are taking, as well as the
professor’s name.

3.3 File Organization
All of the files (including source code and executive program) are in the same directory. They are:

                                                            -6 -
               File                                           Description
Vcs.exe                               Final executive file
untitled.bmp                          Image file to show CPU. Must be in the same directory of
about.cs     about.resx               Source file and resource file for aboutInfoDlg
Form1.cs      Form1.resx              Source file and resource file for main form
SetInput.cs   SetInput.resx           Source file and resource file for setInputDlg
vcs.csproj    vcs.csproj.user         C# project file
vcs.sln                               C# source file
App.ico                               Program icon file
AssemblyInfo.cs                       C# system file. Generated by C#, never touched by us

4. Experiments
Double clicking vcs.exe leads us to the main from. Select “Set up” menu, then set input dialog is
popped up:

We select “using default setting”, which means using 9 default processes, with burst time of 2, 32,
8, 15, 4, 3, 11, 9, and 24. Clicking OK button brings us back to main form. Click “Run”, then the
program will animatedly show how the processes are executed. See the screenshot:

                                               -7 -
The main form vividly shows the time elapsed, which processes finished, which process is
executing, which processes are to be executed, and detailed burst time information. In the upper
figure, we see that for FCFS, the earliest 2 processes are done and the third one is being executing.
For SJF, a bunch of short job has been done. For RR, the first 6 jobs have got the chance to run 10
time units. Among them, the jobs shorter than or equal to 10 were done, and the others left some
burst time to be executed.

We can speed up or lower down, as well as pause it. In pause mode, we can execute step by step.

After a certain time, all of the processes are done.        Then the program generates a report
automatically. Here is the result for this case:

                                                -8 -

Process     1      2       3        4        5         6         7         8        9     AVG

FCFS:       2      34      42       57       61        64        75        84       108   58.55556

SJF:        2      108     17       52       9         5         37        26       76    36.88889

RR:         2      108     20       81       34        37        82        56       106   58.44444


Process     1      2     3      4        5        6         7         8         9         AVG

FCFS:       0      2     34     42       57       61        64        75        84        46.55556

SJF:        0      76    9      37       5        2         26        17        52        24.88889

RR:         0      76    12     66       30       34        71        47        82        46.44444


Process     1      2       3    4        5        6         7         8         9         AVG

FCFS:       0      2       34   42       57       61        64        75        84        46.55556

SJF:        0      76      9    37       5        2         26        17        52        24.88889

RR:         0      2       12   20       30       34        37        47        56        26.44444

CPU utilization:

FCFS: 100%

SJF:      100%

RR:       100%


FCFS: 0.0825688073394495

                                         -9 -
SJF:    0.0825688073394495

RR:     0.0825688073394495

5. Future Work
Up to this moment, we have only implemented the three basic scheduling algorithms we described
above. The other scheduling algorithms we mentioned or ever not mentioned so far are very
important and useful as well. In the future, we should try to implement them in our VPS and
integrate them seamlessly into our friendly GUI.

Another function we should provide is, when there are many algorithms implemented and available
in our VPS, we should let the user specify which algorithms they want to run in a specific

Finally, we can improve the output format of the performance evaluation report. The users will be
able to use pie chart, line chart, bar chart, and so on to visually compare the performances of each
algorithm chosen for an experiment.

[1] Daniel P. Bovet & Marco Cesati Understanding the Linux Kernel

[2] http://www.functionx.com/vcsharp/gdi/introduction.htm

                                               - 10 -