Sie sind auf Seite 1von 3

DiskSchedulingAlgorithms

ThistutorialispreparedforthosethatneedassistanceinDiskSchedulingAlgorithms.
INTRODUCTION
Inoperatingsystems,seektimeisveryimportant.Sincealldevicerequestsarelinkedinqueues,the
seektimeisincreasedcausingthesystemtoslowdown.DiskSchedulingAlgorithmsareusedto
reducethetotalseektimeofanyrequest.
PURPOSE
Thepurposeofthismaterialistoprovideonewithhelpondiskschedulingalgorithms.Hopefully
withthis,onewillbeabletogetastrongergraspofwhatdiskschedulingalgorithmsdo.
TYPESOFDISKSCHEDULINGALGORITHMS
Althoughthereareotheralgorithmsthatreducetheseektimeofallrequests,Iwillonlyconcentrate
onthefollowingdiskschedulingalgorithms:
FirstComeFirstServe(FCFS)
ShortestSeekTimeFirst(SSTF)
Elevator(SCAN)
CircularSCAN(CSCAN)
LOOK
CLOOK
Thesealgorithmsarenothardtounderstand,buttheycanconfusesomeonebecausetheyareso
similar.WhatwearestrivingforbyusingthesealgorithmsiskeepingHeadMovements(#tracks)to
theleastamountaspossible.Thelesstheheadhastomovethefastertheseektimewillbe.Iwill
showyouandexplaintoyouwhyCLOOKisthebestalgorithmtouseintryingtoestablishlessseek
time.
Giventhefollowingqueue95,180,34,119,11,123,62,64withtheReadwriteheadinitiallyatthe
track50andthetailtrackbeingat199letusnowdiscussthedifferentalgorithms.

1.FirstComeFirstServe(FCFS)

Allincoming

requestsareplacedattheendofthequeue.Whatevernumberthatisnextinthequeuewillbethenext
numberserved.Usingthisalgorithmdoesn'tprovidethebestresults.Todeterminethenumberofhead
movementsyouwouldsimplyfindthenumberoftracksittooktomovefromonerequesttothenext.
Forthiscaseitwentfrom50to95to180andsoon.From50to95itmoved45tracks.Ifyoutallyup
thetotalnumberoftracksyouwillfindhowmanytracksithadtogothroughbeforefinishingthe

entirerequest.Inthisexample,ithadatotalheadmovementof640tracks.Thedisadvantageofthis
algorithmisnotedbytheoscillationfromtrack50totrack180andthenbacktotrack11to123then
to64.Asyouwillsoonsee,thisistheworsealgorithmthatonecanuse.

2.ShortestSeekTimeFirst(SSTF)

Inthiscaserequestisservicedaccordingtonextshortestdistance.Startingat50,thenextshortest
distancewouldbe62insteadof34sinceitisonly12tracksawayfrom62and16tracksawayfrom
34.Theprocesswouldcontinueuntilalltheprocessaretakencareof.Forexamplethenextcase
wouldbetomovefrom62to64insteadof34sincethereareonly2tracksbetweenthemandnot18if
itweretogotheotherway.Althoughthisseemstobeabetterservicebeingthatitmovedatotalof
236tracks,thisisnotanoptimalone.Thereisagreatchancethatstarvationwouldtakeplace.The
reasonforthisisiftherewerealotofrequestsclosetoeachothertheotherrequestswillneverbe
handledsincethedistancewillalwaysbegreater.

3.Elevator(SCAN)

Thisapproachworkslikeanelevatordoes.Itscansdowntowardsthenearestendandthenwhenit
hitsthebottomitscansupservicingtherequeststhatitdidn'tgetgoingdown.Ifarequestcomesin
afterithasbeenscanneditwillnotbeserviceduntiltheprocesscomesbackdownormovesbackup.
Thisprocessmovedatotalof230tracks.Onceagainthisismoreoptimalthantheprevious
algorithm,butitisnotthebest.

4.CircularScan(CSCAN)

Circularscanningworksjustliketheelevatortosomeextent.Itbeginsitsscantowardthenearestend
andworksitwayallthewaytotheendofthesystem.Onceithitsthebottomortopitjumpstothe
otherendandmovesinthesamedirection.Keepinmindthatthehugejumpdoesn'tcountasahead
movement.Thetotalheadmovementforthisalgorithmisonly187track,butstillthisisn'tthemose
sufficient.

5.CLOOK

ThisisjustanenhancedversionofCSCAN.Inthisthescanningdoesn'tgopastthelastrequestinthe
directionthatitismoving.Ittoojumpstotheotherendbutnotallthewaytotheend.Justtothe
furthestrequest.CSCANhadatotalmovementof187butthisscan(CLOOK)reduceditdownto
157tracks.
Fromthisyouwereabletoseeascanchangefrom644totalheadmovementstojust157.Youshould
nowhaveanunderstandingastowhyyouroperatingsystemtrulyreliesonthetypeofalgorithmit
needswhenitisdealingwithmultipleprocesses.
NOTE:
Itisimportantthatyoudrawoutthesequencewhenhandlingalgorithmslikethisone.Onewould
haveahardtimetryingtodeterminewhichalgorithmisbestbyjustreadingthedefinition.Thereisa
goodchancethatwithoutthedrawingstherecouldbemiscalculations.

Das könnte Ihnen auch gefallen