0% found this document useful (0 votes)
63 views28 pages

Os Record

The document discusses several CPU scheduling algorithms and memory management techniques. It provides implementations of first come first serve, shortest job first, round robin algorithms. It also covers implementations of mutual exclusion using semaphores, interprocess communication using semaphores, memory allocation with pages, page replacement algorithms like FIFO and LRU, shared memory management, file locking, banker's algorithm, deadlocks, file directory and paging. For each concept, it provides the aim, algorithm and results.

Uploaded by

smsanthoshi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views28 pages

Os Record

The document discusses several CPU scheduling algorithms and memory management techniques. It provides implementations of first come first serve, shortest job first, round robin algorithms. It also covers implementations of mutual exclusion using semaphores, interprocess communication using semaphores, memory allocation with pages, page replacement algorithms like FIFO and LRU, shared memory management, file locking, banker's algorithm, deadlocks, file directory and paging. For each concept, it provides the aim, algorithm and results.

Uploaded by

smsanthoshi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 28

CPU SCHEDULING ALGORITHMS

AIM: To write a program to perform CPU sc e!"#i$g a#gorit ms% &'irst come first ser(e &S ortest )o* first &+Ro"$! ro*i$

ALGORITHM: i, 'irst Come 'irst Ser(e -% Start .% Get t e $"m*er of process a$! t eir *"rst time% /% I$itia#i0e t e waiti$g time for process - as 1% 2% T e waiti$g time process - as 1 are ca#c"#ate! as fo##ows3 4% for 5i6.7i86$7i99, P:i;6P:i&-;9*t%P:i; <% T e waiti$g time of a## processes are s"mme! a$! t e$ a(erage waiti$g time is ca#c"#ate!% =% Stop% ii, S ortest )o* first -% Start .% Get t e $"m*er of process a$! t eir *"rst time% /% T e processes are sorte! accor!i$g t eir *"rst time% 2% I$itia#i0e t e time waiti$g for process - as 1% 4% T e waiti$g time for ot er process are ca#c"#ate! as >t%P:i; 6P:i&-;9*t%P:i&-; <% T e waiti$g time of a## process are s"mme! a$! t e$ a(erage waiti$g time is ca#c"#ate!

=% Stop% iii, Ro"$! ro*i$ -% Start .% Dec#are t e (aria*#e% /% Rea! ?"a$t"m $"m*er3 Tota# $"m*er of process% 2% Ca#c"#ate tota#6tota#9*:i;7 4% Ca#c"#ate a(erage waiti$g a$! a(erage t"r$ aro"$! time% <% Pri$t a(erage waiti$g a$! a(erage t"r$ aro"$! time% =% Stop%

RESULT: T "s t e a*o(e programs for CPU Sc e!"#i$g A#gorit ms 'irst come first ser(e3 s ortest )o* first3 Ro"$! ro*i$ are e@ec"te! s"ccessf"##A a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' MUTUAL EBCLUSION PROCLEM USING DEDDARES ALGORITHM

AIM: To write a program to imp#eme$t t e m"t"a# e@c#"sio$ pro*#em "si$g DeFFerEs A#gorit m%

ALGORITHM: -% Start .% Dec#are two (aria*#es% /% Dec#are t e (aria*#es t"r$$ee!:; s are! to *e "se! *A two process 2% Dec#are a$! !efi$e !wait a$! !sig$a#% 4% Dec#are t e f"$ctio$s to t e co$c"rre$t arraA of two processes% <% If !wait5$ee!:1;,t e$ i$creme$t s are!993pri$t p- is i$it critica# sectio$% =% If !wait5$ee!:-;,t e$ !ecreme$t s are!993pri$t p. is i$it critica# sectio$% G% Stop t e process

RESULT: T "s t e a*o(e programs for m"t"a# e@c#"sio$ pro*#em "si$g DeFFerEs A#gorit m is e@ec"te! s"ccessf"##A a$! t e res"#ts are (erifie!%

INTERPROCESS COMMUNICATION PROCLEM USING SEMAPHORES

AIM: To write a program to imp#eme$t t e I$ter process comm"$icatio$ pro*#em "si$g semap ores%

ALGORITHM: -% Start .% Dec#are t e (aria*#e for pro!"cer a$! co$s"mer% /% Dec#are t e str"ct"re to o#! items3 semap ore (aria*#e set% 2% Rea! t e $"m*er of items to *e pro!"ce! a$! co$s"me!% 4% Defi$e t e pro!"cer f"$ctio$ <% Defi$e co$s"mer f"$ctio$ =% Ca## t e proce!"re for pro!"cer a$! co$s"mer o$ce a## pro!"cers comp#etes co$s"mer% G% Stop t e process

RESULT: T "s t e a*o(e programs for i$ter process comm"$icatio$ "si$g semap ores is imp#eme$te! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' 'IRST 'IT3 CEST 'IT ALGORITHM 'OR MEMORH MANAGEMENT

AIM: To write a program to imp#eme$t first fit3 *est fit a#gorit m for memorA ma$ageme$t

ALGORITHM: -% Start t e process% .% Get t e segme$t si0e3 N"m*er of process to *e a##ocate! a$! t eir correspo$!i$g si0es% /% Get t e optio$ If t e optio$ is -3 ca## first fit% If t e optio$ is .3 ca## *est fit% Ot erwise e@it%

2% 'or first fit a##ocate process to first possi*#e a(ai#a*#e segme$t w ic is free a$! set t e f#ag as -3 so t at $o$e of t e process to *e a##ocate! to segme$t% 4% 'or *est fit3 t e segme$t accor!i$g to t eir si0e a##ocate t e process to t e segme$t w ic is e?"a# to or straig t greater t a$ t e process si0e a$! set f#ag as -% <% Stop t e process

RESULT: T "s t e program for 'irst fit3 *est fit a#gorit m for memorA ma$ageme$t is imp#eme$te! a$! res"#ts are (erifie!%

IMPLEMENTATION O' MEMORH ALLOCATION >ITH PAGES

AIM: To write a program to imp#eme$t t e memorA a##ocatio$ wit pages%

ALGORITHM: -% Start t e process% .% I$itia#i0e t e frame si0e% /% Get t e N"m*er of process to *e a##ocate! i$ t e memorA% 2% Get t e N"m*er of pages to *e a##ocate! to eac process% 4% A##ocate t e frame to eac process accor!i$g to t eir page re?"ireme$t *"t $ot e@cee!i$g t e #imit% <% 'rame a page ta*#e wit pi!3 page a$! frame% =% Pri$t t e $"m*er of frame remai$i$g i$ t e memorA% G% Stop t e e@ec"tio$%

RESULT: T "s t e program to imp#eme$t memorA a##ocatio$ wit pages as *ee$ imp#eme$te! a$! res"#ts are (erifie! s"ccessf"##A%

IMPLEMENTATION O' PAGE REPLACEMENT USING 'I'O

AIM: To write a program to imp#eme$t t e page rep#aceme$t "si$g 'irst i$ 'irst o"t 5'I'O, a#gorit m

ALGORITHM: -% Start t e process% .% E$ter t e si0e for t e frame% /% E$ter t e refere$ce stri$g% 2% C ecF if t e refere$ce stri$g is a#rea!A referre! or $ot% 4% C ecF if t e page frame is f"## or $ot% <% If it is f"## gi(e$ stri$g rep#ace t e first refere$ce page% =% Stop t e process%

RESULT: T "s t e program for imp#eme$ti$g 'I'O page rep#aceme$t a#gorit m as *ee$ e@ec"te! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' LEAST RECENTLH USED ALGORITHM 'OR PAGE REPLACEMENT

AIM: To write a program to imp#eme$t t e page rep#aceme$t "si$g #east rece$t#A "se! a#gorit m%

ALGORITHM: -% Start t e process% .% E$ter t e si0e of t e frame% /% E$ter t e refere$ce stri$g 2% Get t e N"m*er of pages to *e a##ocate! to eac process% 4% C ecF if t e page frame is f"## or $ot% <% If it is f"## gi(e$ stri$g rep#ace t e #east rece$t#A "se! page% =% Stop t e process%

RESULT: T "s t e program to imp#eme$t page rep#aceme$t "si$g #east rece$t#A "se! a#gorit m is e@ec"te! s"ccessf"##A a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' SHARED MEMORH MANAGEMENT

AIM: To !emo$strate t e imp#eme$tatio$ of s are! memorA segme$t

ALGORITHM: -% Dec#are a Str"ct"re% .% Dec#are s are! memorA (aria*#e for ser(er a$! c#ie$t% /% Create a s are! memorA% 2% A!!ress space of s are! memorA is assig$e!% 4% Ca## S are! memorA co$tro# w ic ret"r$s to t e c#ie$t t e c"rre$t str"ct"re for t e specifie! s are! memorA segme$t ser(er% <% Pri$t ISer(er process writi$g t e !ataJ Loop for5i617i8*"ffs"m&seg07i99, Kptr6(a#"e La#"e&(a#"e9=% Pri$t IC#ie$t Process Rea!i$g (a#"eJ G% Stop t e e@ec"tio$%

RESULT: T "s t e program to imp#eme$t s are! memorA ma$ageme$t as *ee$ imp#eme$te! s"ccessf"##A a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' 'ILE LOCDING

AIM: To !emo$strate t e imp#eme$tatio$ of 'i#e #ocFi$g co$cept%

ALGORITHM: -% Defi$e t e fi#emo!e3 "ser rea!3 "ser write3 gro"p rea!3 gro"p write3 a$! ot er rea!% .% Defi$e f"$ctio$ mA#ocF a$! mA"$#ocF% /% Dec#are fi#e !escriptio$3 se?"e$ce $"m*er3 process i!e$tifier si0e of fie#! $"m*er #i$es% 2% Get t e process i!% 4% Dec#are a$! !efi$e #ocF str"ct"re for mA#ocF a$! mA"$#ocF to !escri*e t e page of #ocF a$! *Ate ra$ge t e fi#e to #ocF% <% Ca## mA#ocF to t e fi#e% =% Rewi$! *efore rea!3 t e$ rea! N6rea!5f!3#i$e3ma@#i$e, G% Pri$t pi! a$! se?"e$ce $"m*er% M% Rewi$! *efore write operatio$ a$! "$#ocF t e fi#e% -1% Stop t e e@ec"tio$%

RESULT: T "s t e program to imp#eme$t t e co$cept of fi#e #ocFi$g as *ee$ imp#eme$te! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' CANDERES ALGORITHM

AIM: To write a program to imp#eme$t t e Ca$FerEs A#gorit m%

ALGORITHM: -% Start t e program% .% Get t e $"m*er of process a$! reso"rce% /% Get t e $"m*er of a##ocate!3 ma@im"m a$! a(ai#a*#e reso"rce to eac process% 2% Get t e process se?"e$ce% 4% Ca#c"#ate t e (a#"e for $ee! w ic i$!icate f"rt er re?"ireme$t of reso"rce for process% <% Case! o$ t e gi(e$ se?"e$ce $ee! wit a(ai#a*#e reso"rce% =% If a## t e re?"est are satisfie! !isp#aA ISAstem Is i$ Safe stateJ% G% If $ee! e@cee!s t e a(ai#a*#e reso"rce t e$ !isp#aA IT e sAstem is i$ "$safe stateJ% M% Stop t e e@ec"tio$%

RESULT: T "s t e program to imp#eme$t t e co$cept of Ca$FerEs A#gorit m as *ee$ imp#eme$te! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' DEADLOCD

AIM: To write a program to imp#eme$t t e co$cept of !ea!#ocF%

ALGORITHM: -% Start% .% I$itia#i0e t e (aria*#e% /% Get t e $"m*er of process% 2% Get t e co#"m$ matri@ wit t e (a#"es of i N ) c:i;:);% 4% Get t e a##ocatio$ matri@ wit (a#"es i N ) p:i;:);% <% Get t e reso"rce (ector wit i (a#"es ":i;% =% Get t e a(ai#a*i#itA (ector wit i (a#"e a:i;% G% I$creme$t t e (a#"e of p:i;:); a$! F *A -% M% Stop%

RESULT: T "s t e program to imp#eme$t t e co$cept of Dea!#ocF is s"ccessf"##A comp#ete! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' 'ILE DIRECTORH

AIM: To write a program for imp#eme$ti$g t e co$cept of fi#e !irectorA%

ALGORITHM: -% Start% .% Dec#are t e str"ct"re !irect% /% Get t e c"rre$t worFi$g !irectorA% 2% If co"$t 8613t e$ t ere is $o fi#e i$ !irectorA% 4% Get t e $"m*er of fi#es% <% >rite t e fi#e "si$g f#as *"ffer% =% If5empe$trA,661 ret"r$ fa#se e#se ret"r$ tr"e%

G% I$itia#i0e t e ptr% M% Stop%

RESULT: T "s t e program to imp#eme$t fi#e !irectorA as *ee$ imp#eme$te! a$! t e res"#ts are (erifie!%

IMPLEMENTATION O' PAGING

AIM: To write a program to imp#eme$t t e co$cept of pagi$g%

ALGORITHM: -% Start% .% Dec#are page !irectorA a$! page ta*#e% /% I$itia#i0e t e (aria*#e% 2% Set t e *acFgro"$! co#or gree$ for page fa"#t% 4% If 5prese$t, p"ts 5prese$t, e#se 5$ot prese$t, <% Set foregro"$! CacFgro"$! p"ts sAstem a#te! =% I$itia#i0e pageO!ir6pageOta*#e i$creme$t (a#"e of Di(% G% Dec#are str"ct"re ea!er6firstO ea!er se$! of memorA%

M% Pri$t t e page ta*#e3 page !i( a$! t eir a!!ress% -1% Stop%

RESULT: T "s t e program to imp#eme$t t e co$cept of Pagi$g as *ee$ e@ec"te! a$! t e res"#ts are (erifie!%

You might also like