Anda di halaman 1dari 49

INDEX

 MAIN PAGE I

 CERTIFICATE II

 ABSTRACT III

 ACKONWLEDGEMENT IV

 TABLE OF CONTENT V
A Mini Project Report
ON
SIMULATION OF DISK SCHEDULING
ALGORITHMS.
SUBMITTED FOR THE PARTIAL FULFILLMENT OF AWARD OF

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE & ENGINEERING
(U.P. TECHNICAL UNIVERSITY, LUCKNOW)

SUBMITTED BY
AMIT AGARWAL(0706310008)
ANANYA PANDEY(0706310014)
APURVA KUMAR (0706310020)
ARUN KAUSHIK (0706310023)

Under the Guidance of


Mr. Kailash Kumar

DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING


(2009-10)
G.L.A. INSTITUTE OF TECHNOLOGY & MANAGEMENT

2
CERTIFICATE

This is to certify that Amit


Agrawal,Ananya Pandey,Apurva kumar,Arun kaushik have carried out
the project entitled –“Graphical simulation of Disk scheduling
algorithms “- in partial fulfillment for the award of the degree of ‘Bachelor of
Technology’ in ‘Computer Science & Engineering’.
This is the record of the student’s own work carried out by them under our
supervision.
Mr.Kailash kumar
Project Incharge

3
DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING
G.L.A. INSTITUTE OF TECHNOLOGY & MANAGEMENT

ABSTRACT

Disk Scheduling is the process of managing the disk storage in order to achieve
greater efficiency in storage and faster access time. There are many disk
scheduling techniques like First Come First Serve (FCFS), Shortest Seek Time
First (SSTF), Scan, Circular Scan (C-SCAN), Look, etc. This project aims at
understanding different techniques of disk scheduling and their comparison.

Today computers have been used in many different fields. Some years ago, there
were computers with comparatively less disk storage and less main memory
(RAM) .But with the passage of time, uses of computer increased and hence the
configuration also. Now computers with large disk storage capacity are used.
Hence in order to achieve proper utilization of disk storage and fast access time
of the data we store in disks, we require some techniques that would help in
managing the disk drives. In this project, we have provided the user to input
different request times for processes. After providing the input, there is a menu
of different techniques according to which the scheduling is being done. With
the application of each technique we get a scheduling graph. After that
comparison is done and the technique along with minimum throughput is
displayed in front of user.

The purpose of the software requirement specification (SRS) is to define all


functionality, Behavioral requirements, External interface, Attributes and
Performance of the software. Here we have used various Graphical Functions
available in C/C++ (Graphics.h), which enables the user direct interaction with
software.

4
5
ACKNOWLEDGEMENT

We take this opportunity to express our deep sense gratitude and


sincere regard to Mr.Kailash Kumar for his inspiring guidance
and persistent encouragement throughout the course of this project.
Their proper support and guidance provided us the path through which
we came to the successful realization of project.

Submitted by:

AMIT
AGRAWAL(0706310008)

ANANYA
PANDEY(0706310014)

APURVA KUMAR(0706310020)

ARUN KAUSHIK(0706310023)

6
TABLE OF CONTENT

PAG
SI.no CHAPTERS E
NO.
Introduction
1. 7-10

 Feasibility Study
 Technical 11-13
2.  economical
 Operational

3. System & Detailed design 14

4. Coding 15-36

5. Testing 33-36

6. Result & conclusions 37-38

7
7. Refrences & Bibliography 39-40

INTRODUCTION

DISK SCHEDULING

The major responsibility of the operating system is to use the hardware in an


efficient manner for disk drivers, meeting this responsibility entails having fast
access time and bandwidth. We can improve this.

When a process needs input/output to or from the disk, it issues a system call to
the operating system. This requires several pieces of information.

Whatever this operation is input or output, what is the disk address for data
transfer, what is the memory address for the data transfer, what is the number of
bytes to be transferred?

It is desirable that disk drive and disk controller are available; the request can be
serviced immediately. For this requirement, several disk scheduling algorithms
are defined, which are used in accessing and transfer the data.

8
FIRST COME FIRST SERVE SCHEDULING

In this algorithm the head position is known and we follow the order in which
inputs are occurred. For example an ordered disk queue involving tracks are
98,183, 37,122, and 14. The head initially is on 53, and then disk moves from 53
to 98, then to 183, 37, 122, 14 and so on.

SHORTEST SEEK TIME FIRST SCHEDULING

It is reasonably to service the entire request close to the head position before
moving the head far away to service other request.

9
The algorithm selects the request with minimum seek time from the current head
position. Since the seek time increases with the no. of tracks traversed by the
head. It selects the pending request close to the head.

SCAN SCHEDULING

In this algorithm the disk arm starts at one end and moves towards the other end,
servicing requests as it reaches each track until it gets to other end of the disk. At
the other end, the direction of the head is reversed and servicing continues.

CIRCULAR SCAN SCHEDULING


10
Circular scan is a variant of scan algorithm that provides more uniform waiting
time. Like scan scheduling, C-scan moves the head from one end of the disk to
the other, servicing requests along the way. When the head reaches at one end it
immediately returns back to the other end without servicing the request on
reverse trip.

LOOK AND C-LOOK SCHEDULING

Practically neither the scan nor the c-scan is implemented as in both algorithm
movement of disk arm across the full width of the disk commonly; the arm goes
only as far as the final request in each direction. Then it immediately reverses its
direction, without going all the way to trend of the disk. These versions of scan
and c-scan are called look and c-look scheduling because they look for request
before continuing to move in a given direction.

11
FEASIBILITY STUDY

Feasibility study involves study of the system and to look whether the system
does the kind of job expected from it. The objective of the feasibility study is not
to solve the problem but to predict (on the basis of system analysis & problem
definition) that if it does the kind of work expected on it, in a reasonable period
of elapsed time, & consistent with the financial & processing objective and
needs of the organization or any Placement Agency.

Feasibility study analysis is done in respect of the following :


• Economical feasibility (H/w, S/w)
• Technical feasibility (Hardware)
• Operational feasibility (Time bound)

ECONOMICAL:
All the required hardware and the software is easily available in the market,
therefore this project is very economical for it. Also there is no need of special
training for end user or any consultant.

12
Just two or three hours are sufficient for the explanation of method of using this
package. Since the proposed method is to develop the package using C, etc.

TECHNICAL:
Feasibility analysis in case of hardware is to see that whether the required
hardware for the proposed method is available or not, and if not then installation
is feasible or not in terms of cost & time available.

HARDWARE:
Many hardware resources used in the implementation of the project are as
follows,

 Computer based on Pentium processor


(P-4 or Compatible Celeron)

 64 MB RAM(or higher)

 Hard disc space: 10 MB (or higher)


13
SOFTWARE:

 Windows-98/2000/xp

The above mentioned resources are easily available and hence the project is
technically feasible.
By meeting with all these hardware and software requirements ,feasibility
study of our project completes.

OPERATIONAL :
In this case we consider the required time for development of the package. It is
to be checked that if we will be able to develop the package according to
14
proposed method in the given time or not.Since we decide to develop this
project in C this will not require very long time.

SYSTEM AND DETAILED DESIGN

Data flow diagram:-


The DFD is an simple graphical notation that can be used to represent a system
in terms of input data to the system , various processing carried out on these data
and output data generated by system.

Context diagram:-
It is a diagram in which working of whole program is represented by single
process and its interaction with external agents is shown through exchange of
data.

Disk scheduling
No. of movements algorithm total moves

Head position all path travelled

moves

15
Context diagram

SOURCE CODE

CODING
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void fcfs();
void sstf();
void scan();
void cscan();
void look();
void clook();
void common();

void main()
{
int ch;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(3,0,4);
outtextxy(30,50,"WHICH ALGORITHM YOU WANT TO USE");
settextstyle(3,0,2);

16
outtextxy(150,140,"1..............First Come First Serve");
outtextxy(150,160,"2............Shortest Seek Time First");
outtextxy(150,180,"3..............SCAN");
outtextxy(150,200,"4..............Circular SCAN");
outtextxy(150,220,"5..............LOOK");
outtextxy(150,240,"6..............Circular LOOK");
outtextxy(150,260,"7..............EXIT");
outtextxy(100,290,"Enter your choice");
scanf("%d",&ch);
closegraph();
switch(ch)
{
case 1:fcfs();
break;
case 2:sstf();
break;
case 3:scan();
break;
case 4:cscan();
break;
case 5:look();
break;
case 6:clook();
break;
case 7:exit(0);
default:printf("\nYou have entered wrong choice.");
getch();
}
}

void fcfs()
{
int gd=DETECT,gm;
int head,n,i,j,k,temp,d,sum=0,cal,end;
int left,right,top,bottom,start,size,x1=0,y1=0,x2=0,y2=0;
17
int a[10],b[10],c[10];
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
printf("\nEnter the no. of head movements(<=9)");
scanf("%d",&n);
printf("\nEnter the head movements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
n=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(b[j]>b[j+1])
{
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
}
}
18
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"FCFS");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
for(i=0;i<n;i++)
{
if(head==b[i])
{
break;
}
}
cal=(start+((c[i]-1)*size))+20;
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
x1=cal;
y1=bottom+20;
line(x1,y1-5,x1,y1+5);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
sprintf(ch,"%d",sum);
19
outtextxy(310,400,ch);
delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
for(i=0;i<n-1;i++)
{
setcolor(0);
outtextxy(310,400,ch);
for(j=0;j<n;j++)
{
if(a[i]==b[j])
break;
}
d=abs(head-a[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
setcolor(15);
outtextxy(310,400,ch);
cal=(start+((c[j]-1)*size))+20;
x2=cal;
y2=y1+20;
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
line(x2,y2-5,x2,y2+5);
x1=x2;
y1=y2;
head=a[i];
}
getch();
closegraph();
20
}

void sstf()
{
int gd=DETECT,gm;
int left,top,right,bottom,start,size;
int i,j,k,l,m,n,temp,head,cal,d,sum=0,min=1000;
int a[10],b[10],c[10];
int x1=0,y1=0,x2=0,y2=0;
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
printf("\nEnter the no. of head movements(<=9)");
scanf("%d",&n);
printf("\nEnter the moves\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(;i<10;i++)
a[i]=0;
for(i=0;i<10;i++)
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
n=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
21
{
if(b[j]>b[j+1])
{
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
}
}
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"SSTF");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
for(i=0;i<n;i++)
{
if(head==b[i])
{
break;
}
22
}
cal=(start+((c[i]-1)*size))+20;
x1=cal;
y1=bottom+20;
line(x1,y1-5,x1,y1+5);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
m=n-1;
delay(1000);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
d=abs(head-a[j]);
if(d<min)
{
min=d;
l=j;
}
}
for(j=0;j<n;j++)
{
if(a[l]==b[j])
{
k=j;
break;
}
}
sprintf(ch,"%d",sum);
setcolor(15);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
line(x1,y1-5,x1,y1+5);

cal=(start+((c[k]-1)*size))+20;
23
x2=cal;
y2=y1+20;
if(x1!=0&&x2!=0&&y1!=0&&y2!=0&&x1!=x2)
line(x1,y1,x2,y2);
outtextxy(310,400,ch);

setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
head=a[l];
sum=sum+min;
for(j=l;j<m;j++)
{
a[j]=a[j+1];
}
a[m-1]=0;
min=1000;
m=m-1;
x1=x2;
y1=y2;
delay(1000);
setcolor(0);
outtextxy(310,400,ch);
}
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
setcolor(15);
outtextxy(310,400,ch);
getch();
closegraph();
}

void scan()
{
int gd=DETECT,gm;
int head,n,i,j,k,temp,d,sum=0,cal;
24
int left,right,top,bottom,start,size,x1=0,y1=0,x2=0,y2=0;
int a[10],b[10],c[10];
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
printf("\nEnter the no. of head movements(<=7)");
scanf("%d",&n);
printf("\nEnter the head movements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
b[i+1]=0;
n=n+2;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(b[j]>b[j+1])
{
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
25
}
}
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"SCAN");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
for(i=0;i<n;i++)
{
if(b[i]==head)
{
k=i;
break;
}
}
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
for(i=k;i>=0;i--)
{
sprintf(ch,"%d",sum);
head=b[i];
26
cal=(start+((c[i]-1)*size))+20;
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
x2=cal;
y2=bottom+((k-i+1)*20);
setcolor(15);
outtextxy(310,400,ch);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
line(x2,y2-5,x2,y2+5);
d=abs(head-b[i+1]);
sum=sum+d;
delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
setcolor(0);
outtextxy(310,400,ch);
}
for(i=k+1;i<n;i++)
{
d=abs(head-b[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
setcolor(15);
outtextxy(310,400,ch);
cal=(start+((c[i]-1)*size))+20;
x2=cal;
y2=bottom+((i+1)*20);
setcolor(15);
line(x2,y2-5,x2,y2+5);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
27
floodfill(cal,(top+10),WHITE);

delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
head=b[i];
setcolor(0);
outtextxy(310,400,ch);
}
setcolor(15);
outtextxy(310,400,ch);
getch();
closegraph();
}

void cscan()
{
int gd=DETECT,gm;
int head,n,i,j,k,temp,d,sum=0,cal,end;
int left,right,top,bottom,start,size,x1=0,y1=0,x2=0,y2=0;
int a[10],b[10],c[10];
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
//printf("\nEnter the end position");
//scanf("%d",&end);
printf("\nEnter the no. of head movements(<=7)");
scanf("%d",&n);
printf("\nEnter the head movements\n");
28
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
//b[i+1]=0;
//b[i+2]=end;
n=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(b[j]>b[j+1])
{
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
}
}
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"CSCAN");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
29
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
for(i=0;i<n;i++)
{
if(b[i]==head)
{
k=i;
break;
}
}
cal=(start+((c[k]-1)*size))+20;
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
x1=cal;
y1=bottom+20;
line(x1,y1-5,x1,y1+5);
delay(1000);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
for(i=k+1;i<n;i++)
{
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
d=abs(head-b[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
cal=(start+((c[i]-1)*size))+20;
30
x2=cal;
y2=y1+20;
setcolor(15);
outtextxy(310,400,ch);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
line(x2,y2-5,x2,y2+5);
x1=x2;
y1=y2;
delay(1000);
setcolor(0);
outtextxy(310,400,ch);
head=b[i];
}
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
for(i=0;i<k;i++)
{
d=abs(head-b[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
setcolor(15);
outtextxy(310,400,ch);
cal=(start+((c[i]-1)*size))+20;
x2=cal;
y2=bottom+((i+k+1)*20);
setcolor(15);
line(x2,y2-5,x2,y2+5);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
delay(1000);
31
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
head=b[i];
setcolor(0);
outtextxy(310,400,ch);
}
setcolor(15);
outtextxy(310,400,ch);
getch();
closegraph();
}

void look()
{
int gd=DETECT,gm;
int head,n,i,j,k,temp,d,sum=0,cal;
int left,right,top,bottom,start,size,x1=0,y1=0,x2=0,y2=0;
int a[10],b[10],c[10];
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
printf("\nEnter the no. of head movements(<=8)");
scanf("%d",&n);
printf("\nEnter the head movements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
32
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
//b[i+1]=0;
n=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(b[j]>b[j+1])
{
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
}
}
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"LOOK");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
33
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
for(i=0;i<n;i++)
{
if(b[i]==head)
{
k=i;
break;
}
}
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
for(i=k;i>=0;i--)
{
sprintf(ch,"%d",sum);
head=b[i];
cal=(start+((c[i]-1)*size))+20;
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
x2=cal;
y2=bottom+((k-i+1)*20);
setcolor(15);
outtextxy(310,400,ch);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
line(x2,y2-5,x2,y2+5);
d=abs(head-b[i+1]);
sum=sum+d;
delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
34
setcolor(0);
outtextxy(310,400,ch);
}
for(i=k+1;i<n;i++)
{
d=abs(head-b[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
setcolor(15);
outtextxy(310,400,ch);
cal=(start+((c[i]-1)*size))+20;
x2=cal;
y2=bottom+((i+1)*20);
setcolor(15);
line(x2,y2-5,x2,y2+5);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);

delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
head=b[i];
setcolor(0);
outtextxy(310,400,ch);
}
setcolor(15);
outtextxy(310,400,ch);
getch();
closegraph();
}

35
void clook()
{
int gd=DETECT,gm;
int head,n,i,j,k,temp,d,sum=0,cal,end;
int left,right,top,bottom,start,size,x1=0,y1=0,x2=0,y2=0;
int a[10],b[10],c[10];
char ch[5];
clrscr();
left=top=70;
start=left;
size=50;
printf("\nEnter the head position");
scanf("%d",&head);
printf("\nEnter the no. of head movements(<=7)");
scanf("%d",&n);
printf("\nEnter the head movements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
b[i]=1000;
c[i]=0;
}
for(i=0;i<n;i++)
b[i]=a[i];
b[i]=head;
n=n+1;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(b[j]>b[j+1])
{
36
temp=b[j+1];
b[j+1]=b[j];
b[j]=temp;
}
}
c[n-i-1]=n-i;
}

initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(270,20,"CLOOK");
outtextxy(170,400,"Total Moves =");
settextstyle(0,0,0);
for(i=0;i<n;i++)
{
right=left+50;
bottom=top+50;
sprintf(ch,"%d",b[i]);
setfillstyle(SOLID_FILL,BLUE);
rectangle(left,top,right,bottom);
floodfill((left+10),(top+10),WHITE);
outtextxy((left+15),(top+15),ch);
left=left+51;
}
common();
for(i=0;i<n;i++)
{
if(b[i]==head)
{
k=i;
break;
}
}
cal=(start+((c[k]-1)*size))+20;
setfillstyle(SOLID_FILL,RED);
37
floodfill(cal,(top+10),WHITE);
x1=cal;
y1=bottom+20;
line(x1,y1-5,x1,y1+5);
delay(1000);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
for(i=k+1;i<n;i++)
{
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
d=abs(head-b[i]);
sum=sum+d;
sprintf(ch,"%d",sum);
cal=(start+((c[i]-1)*size))+20;
x2=cal;
y2=y1+20;
setcolor(15);
outtextxy(310,400,ch);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
line(x2,y2-5,x2,y2+5);
x1=x2;
y1=y2;
delay(1000);
setcolor(0);
outtextxy(310,400,ch);
head=b[i];
}
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
for(i=0;i<k;i++)
{
d=abs(head-b[i]);
38
sum=sum+d;
sprintf(ch,"%d",sum);
setcolor(15);
outtextxy(310,400,ch);
cal=(start+((c[i]-1)*size))+20;
x2=cal;
y2=bottom+((i+k+1)*20);
setcolor(15);
line(x2,y2-5,x2,y2+5);
if(x1!=0&&x2!=0&&y1!=0&&y2!=0)
line(x1,y1,x2,y2);
setfillstyle(SOLID_FILL,RED);
floodfill(cal,(top+10),WHITE);
delay(1000);
setfillstyle(SOLID_FILL,MAGENTA);
floodfill(cal,(top+10),WHITE);
x1=x2;
y1=y2;
head=b[i];
setcolor(0);
outtextxy(310,400,ch);
}
setcolor(15);
outtextxy(310,400,ch);
getch();
closegraph();
}
void common()
{
rectangle(420,340,440,360);
floodfill(425,350,WHITE);
outtextxy(450,345,"Unscaned Cylinder");
setfillstyle(SOLID_FILL,RED);
rectangle(420,370,440,390);
floodfill(425,380,WHITE);
39
outtextxy(450,375,"Cylinder being scaned");
setfillstyle(SOLID_FILL,MAGENTA);
rectangle(420,400,440,420);
floodfill(425,410,WHITE);
outtextxy(450,405,"Scaned cylinder"); }

TESTING
Testing is the process of exercising a program with the specific intent of finding
undiscovered errors prior to delivery to the end user.

Although software testing is itself an expensive activity, yet launching of


software without testing may lead to cost potentially much higher than that of
testing, especially in systems where human safety is involved.
In the software life cycle the earlier the errors are discovered and removed, the
lower is the cost of their removal.
We have tested the program’s responses to every possible valid and invalid
input.
Here, complete testing is just not possible, although, we may wish to do so.

Levels of Testing
There are 3 levels of testing:
1. Unit Testing
2. Integration Testing
3. System Testing

Unit Testing

The size of a single module is small enough that we can locate an error fairly
easily. The module is small enough that we can attempt to test it in some
demonstrably exhaustive fashion. Confusing interactions of multiple errors in
widely different parts of the software are eliminated.

40
Integration Testing

The purpose of unit testing is to determine that each independent module is


correctly implemented. This gives little chance to determine that the interface
between modules is also correct, and for this reason integration testing must be
performed. One specific target of integration testing is the interface: whether
parameters match on both sides as to type, permissible ranges, meaning and
utilization.

System Testing

Of the three levels of testing, the system level is closet to everyday experiences.
A common pattern in these familiar forms is that we evaluate a product in terms
of our expectations; not with respect to a specification or a standard.
Consequently, goal is not to find faults, but to demonstrate performance.
Because of this we tend to approach system testing from a functional standpoint
rather than from a structural one. Since it is so intuitively familiar, system
testing in practice tends to be less formal than it might be, and is compounded
by the reduced testing interval that usually remains before a delivery deadline.

41
RESULT AND CONCLUSIONS

 The goal of our project that is finding path travelled and no. of moves in
disk using different DISK SCHEDULING ALGORITHM and its graphical
simulation is being achieved.
 Disk Scheduling is the process of managing the disk storage in order to
achieve greater efficiency in storage and faster access time. There are
many disk scheduling techniques like First Come First Serve (FCFS),
Shortest Seek Time First (SSTF), Scan, Circular Scan (C-SCAN), Look,
etc. This project describes different techniques of disk scheduling

42
ABOUT LANGUAGE

 C is a general-purpose, block C is a general-purpose, block


structured, procedural, imperative computer programming
languagestructured, procedural, imperative computer
programming language

 C has also greatly influenced many other popular languages,


especially C++, which was originally designed as an extension
to C.

 The language was designed to encourage machine-


independent programming.

 The language has become available on a very wide range of


platforms, from embedded microcontrollers to
supercomputers.

REFERENCES
43
Graphics using C by Yashwant Kanitkar

Let us C by Yashwant Kanitkar


Project using C by Yashwant Kanitkar

 www.google.com

Operating System Concepts by Silberschatz

Galvin
Gagne

44
SELECTION OF ALGORITHM

INPUT INFORMATION

45
GRAPHICAL SIMULATION

46
47
48
49

Anda mungkin juga menyukai