Disk Scheduling (1)

  • Upload
    anuj199

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

  • 8/11/2019 Disk Scheduling (1)

    1/57

    ACKNOWLEDGEMENTACKNOWLEDGEMENT

    The satisfaction and euphoria that accompany the successfulcompletion of any task ould !e !ut incomplete ithout the mention of thepeople ho made it possi!le hose constant "uidance and encoura"ementcroned our e#orts ith success$%irstly & ould like to thank "od for his !lessin" to all on earth$

    We ish to place on record our "rateful ' sincere thanks to Mr.Channakeshava (rincipal of the )$)$($T* and Tiptur for pro+idin" us the

    facility and support$

    We con+ey our sincere re"ards to our pro,ect "uide Miss$)anthoshKa+itha M$N Department of Computer science for her encoura"ement and"uidance$We are +ery "rateful to

    Mrs$ Gayathri -

    Mrs$ Tulase Mr$ Girish )

    We ould also like to mention our special thanks to all sta# mem!ersand la! assistants of* Department of Computer science for their support$

    We consider our pri+ile"e to e.press our "ratitude and respect to allthose ho "uided as in the completion of this pro,ect$

    Last !ut not the least e ould like to thank our family mem!ers* ourfriends and ell ishers for their +alua!le help and time they spared inmakin" thin"s easier and possi!le$

    1

  • 8/11/2019 Disk Scheduling (1)

    2/57

    CONTENT)CONTENT)

    )ynopsis

    &ntroduction

    /ardare and )oftare 0e1uirements

    A!out 2C3

    Al"orithms of Disk )chedulin"

    4$ % C % )5$ ) ) T %6$ )CAN7$ C8)CAN

    Graphical Notation of Al"orithms

    )oftare &mplementations

    4$ )ource code

    )nap )hots

    Conclusion

    Limitations and )cope for &mpro+ements

    9i!lio"raphy

    2

  • 8/11/2019 Disk Scheduling (1)

    3/57

    SYNOPSIS

    This pro,ect is a!outDisk Scheduling.Disk schedulin" means

    selectin" one of the &:O re1uest out of num!er of re1uests made !y a

    num!er of processes for ser+icin"$

    When some data has to !e riter in to or read from the disk* it issues

    a system call to the operatin" system$ This system call ill contain

    information a!out the type of the operation ;read:rite

  • 8/11/2019 Disk Scheduling (1)

    4/57

    HARDWARE AND SOFTWARECONFIGRATION

    Software Constraints:

    Turbo C and Graphics Routines.

    Hardware Constraints:

    &nput = 4>7 keys key!oard$

    Memory re1uirements = 65 M9 0AM$

    (rocessor 0e1uired = (entium and /i"her

    deri+ati+es$

    /ard Disk = 4> G9

    %loppy Disk = 4$77 M9

    O:) 0e1uired = Windos ?@ or hi"her deri+ati+es$

    Display = EGA:-GA compati!le color$

    (rinter = 465 column Dot Matri. and &nk ,etprinter of any make$

    4

  • 8/11/2019 Disk Scheduling (1)

    5/57

    5

  • 8/11/2019 Disk Scheduling (1)

    6/57

    A!OT "C#

    C is a pro"rammin" lan"ua"e de+eloped at At and Ts 9ell

    la!oratories of B)A in 4?5$ &t as desi"ned and ritten !y a man named

    Dennis 0itchie$ C can !e"in to replace the more familiar lan"ua"es of that

    time like (L:&* ALGOL etc$(ossi!ly hy c seems so popular is !ecause it is relia!le* simple and

    easy to use $C is a procedural oriented pro"ram ;pop

  • 8/11/2019 Disk Scheduling (1)

    7/57

    lan"ua"es ha+e !een desi"ned to "i+e a !etter pro"rammin"

    eciency* i$e$ faster pro"ram de+elopment

    9< Machine oriented lan"ua"es or Lo le+el lan"ua"es= Theselan"ua"es ha+e !een desi"ned to "i+e a !etter machine

    eciency* i$e$ faster pro"ram e.ecution$

    C stands in !eteen these to cate"ories$ That3s hy it is often

    called a Middle le+el lan"ua"e* since it as desi"ned to ha+e !oth= a

    relati+ely "ood pro"rammin" eciency ;as compared to machine oriented

    lan"ua"es< and relati+ely "ood machine eciency ;compared to pro!lem

    oriented lan"ua"es

  • 8/11/2019 Disk Scheduling (1)

    8/57

    Finclude HlenameI does not search the source directory.

    E*'/+les3

    Finclude Hstdio$hIFinclude main$h

    S)/e )4 he he'de( 5les used36

    4< FincludeHstdio$hI

    5< FincludeHconio$hI

    6< FincludeHmath$hI

    7< FincludeHstdli!$hI

    @< FincludeHtime$hI

    J< FincludeHctype$hI

    < FincludeHdos$hI

    < FincludeH"raphics$hI

    $% 7include8sdi).h936

    stdio$h Denes types and macros needed for the )tandard &:O (acka"e

    dened in Kerni"han and 0itchie and e.tended under BN& )ystem -$Denes the standard &:O predened streams stdin*

    stdout* stdprn* and stderr* and declares stream8le+el &:O routines$

    The functions of )TD&O$/ used

    fclose "etc "etchar "ets "et printf putc putchar

    puts put scanf

    8

  • 8/11/2019 Disk Scheduling (1)

    9/57

    ,% 7include8c)ni).h936

    conio$h Declares +arious functions used in callin" the DO) console

    I:O ()uines.The functions of conio$h used

    c"ets clrscr cprintf cputs cscanf "etch

    "ette.tinfo

    "oto.y putch te.t!ack"round te.tcolor te.tmode

    -% 7include8/'h.h936

    math$h Declares prototypes for the math functions* denes the macro

    /BGE-AL* and declares the e.ception structure used !y matherr$

    The functions of math$h used

    po;< s1rtA;* the head ill ser+ice 6 and then 47$ At cylinder >* the

    arm ill re+erse and ill mo+e toard the other end of the disk* ser+icin"

    the re1uests at J@*J* ?* 455* 457* and 46$ &f a re1uest arri+es in the

    1ueue ,ust in front of the head* it ill !e ser+iced almost immediately are1uest arri+in" ,ust !ehind the head* it ill !e ser+iced almost

    immediately a re1uest arri+in" ,ust !ehind the head ill ha+e to ait until

    the arm mo+es to the end of the disk* re+erses direction* and comes !ack$

    The )CAN al"orithm is sometimes called the ele+ator al"orithm* since

    the disk arm !eha+es ,ust like an ele+ator in a !uildin"* rst ser+icin" all

    the re1uests "oin" up* and then re+ersin" to ser+ice re1uests the other

    ay$

    Assumin" a uniform distri!ution of re1uests for cylinders* consider

    the density of re1uests hen the head reaches one end and re+erses

    direction$ At this point* relati+ely fe re1uests are immediately in front of

    the head* since these cylinders ha+e recently !een ser+iced$ The hea+iest

    density of re1uests is at the other end of the disk$ These re1uests ha+e also

    aited the lon"est* so hy not "o there rstV That is the idea of the ne.t

    al"orithm$

    1ueue ?* 46* 6* 455* 47* 457* J@* Jhead starts at @6

    14 37 53 65 67 98 122 124 183 199

    22

  • 8/11/2019 Disk Scheduling (1)

    23/57

    SCAN S+0#N

    #C,- #*&/0"-G

    C6SCAN SCHEDING @C SCAN%

    Circular scan ;C8)CAN< schedulin" is a +ariant of )CAN desi"ned to pro+ide

    a more uniform ait time$ Like )CAN* C8)CAN mo+es the head from one

    23

  • 8/11/2019 Disk Scheduling (1)

    24/57

    end of the disk to the other* ser+icin" re1uests alon" the ay$ When the

    head reaches the other end* hoe+er* it immediately returns to the

    !e"innin" of the disk* ithout ser+icin" any re1uests on the return trip$ The

    C8)CAN schedulin" al"orithm essentially treats the cylinders as a circularlist that raps around from the nal cylinder to the rst one$

    1ueue ?* 46* 6* 455* 47* 457* J@* Jhead starts at @6

    14 37 536567 98 122 124 183 199

    C #C,- #*&/0"-G

    OO SCHEDING

    As e descri!ed them* !oth )CAN and C8)CAN mo+e the disk arm

    across the full idth of the disk$ &n practice* neither al"orithm is

    24

  • 8/11/2019 Disk Scheduling (1)

    25/57

    implemented this ay$ More commonly* the arm "oes only as the nal

    re1uest in each direction$

    Then* it re+erses direction immediately* ithout "oin" all the ay to

    the end of the disk$ These +ersions of )CAN and C8)CAN are called LOOKand C8LOOK schedulin"* !ecause they look for a re1uest !efore continuin"

    to mo+e in a "i+en direction$

    1ueue ?* 46* 6* 455* 47* 457* J@* Jhead starts at @6

    14 37 53 6567 98 122 124 183199

    0$$+ #C*&/0"-G

    S)4'(e I/+le/en'i)ns

    SORCE CODE

    25

  • 8/11/2019 Disk Scheduling (1)

    26/57

  • 8/11/2019 Disk Scheduling (1)

    27/57

    sette.tstyle;*/O0&YD&0*6>*4@>*DELL& (0A)AD$M >*4>*MANUB (0AKA)/ >*54>*-A0ADA0AUB>*57>*-&UAZ KBMA0$-*5@*Jth )EM* C:)>*5?@*)$U$(OLZTEC/N&C>*64@*9ANGALO0E*5

  • 8/11/2019 Disk Scheduling (1)

    28/57

    for;i4 iH,o!s iXX< ::)O0T for;,4 ,H,o!s ,XX\* int ,o!s*4@*6?*J*5*7*5?**4>Q*^a"4*

    ))T%[4>\P>**4>*J*7*4@*5*5?*6?Q*)CAN[4>\P>*J*7**4>*4@*5*5?*6?Q*C)CAN[4>\P>**4>*4@*5*5?*6?*7*JQ*

    linecolor4@*discno7>lon" int choicechar strin"[4>\

    +oid cylender;*(0OUECT ON== D&)K )C/EDBL&NG ;)CANAl"orithm*>*J6?*7?*/O0&YD&0*>*;>*>**7>*Z

  • 8/11/2019 Disk Scheduling (1)

    37/57

    QQproced 4::close"raph;*i*J6?*iQ:: %BNCT&ON TO CALCBLATE )CALE %O0 G0A(/scale;\ if ;;minXma.< I 5@< P scaledi# ;;;minXma.*no*>*Cyl*/O0&YD&0*>

  • 8/11/2019 Disk Scheduling (1)

    38/57

    sette.tstyle;>* -E0TD&0* 4> char head[4>\ for;i4 iH,o!s iXX< :: (0&NT) _BEBE P setcolor;44 Q

    scan_;int ,o!s* int 1ueue[6>\