Add to Favorites    Make Home Page 2799 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » Disk scheduling

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Disk scheduling
Author Rathish
Author Email rathish_kannan [at] yahoo.co.in
Description this code show how the disk scheduling is done in OS.

Category C » Beginners / Lab Assignments
Hits 396368
Code Select and Copy the Code
#include<stdio.h> #include<conio.h> #include<math.h> #include<graphics.h> main() { int gd=DETECT,gm,x,y,a1,x1,y1,a,b; int req[30],head,i,k,move,n,ch,t1,t2,max,min,g[30],c,h; initgraph(&gd,&gm,"z:\tcpp\bgi"); /*int req[30],head,i,k,move,n,ch,t1,t2,max,min,g[30],c,h;*/ clearviewport(); printf("(1) LOOK (2) CLOOK (3) FCFS (0) EXIT Enter your choice: "); scanf("%d",&ch); while(ch) { printf("Enter the current head position: "); scanf("%d",&head); h=head; printf("Enter the number of requests: "); scanf("%d",&n); k=0; move=0; printf("Total number of cylinders: 200. "); printf("Enter the requests (1 to 200): "); req: for(i=0;i<n;i++) { scanf("%d",&req[i]); if(req[i]>200||req[i]<1) { printf("Enter requests only between 1-200."); goto req; } } switch(ch) { case 1: outtextxy(270,10,"SEEK PATTERN FOR LOOK"); max=req[0]; min=req[0]; t2=1; c=0; for(i=1;i<n;i++) { max=max>req[i]?max:req[i]; min=min<req[i]?min:req[i]; } if(max<=head) t2=0; while(k<n) { t1=0; for(i=0;i<n;i++) { if(t2) { if(req[i]&&req[i]>=head) { if(req[i]<req[t1]) t1=i; if(req[i]==max) { t2=0; g[c]=1; c++; } } } else { if(req[i]&&req[i]<=head) { if(req[i]>req[t1]) t1=i; if(req[i]==min) { t2=1; g[c]=200; c++; } } } }/*for*/ printf("%d ",req[t1]); g[c]=req[t1]; c++; move+=abs(head-req[t1]); req[t1]=0; k++; head=req[t1]; if(head==max) t2=0; }/*while*/ break; case 2: outtextxy(270,10,"SEEK PATTERN FOR CLOOK"); max=req[0]; min=req[0]; t2=1; c=0; for(i=1;i<n;i++) { max=max>req[i]?max:req[i]; min=min<req[i]?min:req[i]; } while(k<n) { t1=0; if(!t2) head=min; for(i=0;i<n;i++) { if(req[i]&&req[i]>=head) { if(req[i]<req[t1]) t1=i; else if(req[i]==max) { head=1; g[c]=1; c++; } } }/*for*/ printf("%d ",req[t1]); move+=abs(head-req[t1]); head=req[t1]; g[c]=req[t1]; c++; req[t1]=0; k++; if(head==max) t2=0; }/*while*/ break; case 3: outtextxy(270,10,"SEEK PATTERN FOR FCFS"); for(i=0,c=0;i<n;i++,c++) { printf("%d ",req[i]); move+=abs(head-req[i]); head=req[i]; g[c]=req[i]; } break; }/*switch*/ printf("Order of servicing: "); printf("%d: ",h); for(i=0;i<n;i++) printf("%d ",g[i]); printf(" Total Head Movements: %d ",move); x=getmaxx(); y=getmaxy(); rectangle(0,20,x-5,y-5); a1=(x-30)/10; b=110; a=h+(3*a1); y1=125; fillellipse(a,b,2,2); for(i=0;i<n;i++) { int x1=g[i]+(3*a1); fillellipse(x1,y1,2,2); line(a,b,x1,y1); a=x1; b=y1; y1+=15; } getch(); clrscr(); clearviewport(); printf(" (1) LOOK (2) CLOOK (3) FCFS (0) EXIT Enter your choice: "); scanf("%d",&ch); }/*while*/ getch(); }/*main*/

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1206


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review