Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

NAME SuhonshU l

RoLL Mo.. o qo5I T!Slo 30


BRANC H TT _Sem

Systemm
rac ealle

ZAVDE
ToPZe
FCFS
STA Non-heep ti ve
|5 ne -emp tive sho teat 6 Finst

Piontty Eheduiry af
5 Kound Kobin Shedling wi'h
Arniel ti'm
h e Bvndes-Bfr robkm
Sonkir Ago th

FTFo Zmptmentoflo
ptimoly
RU ge locemend
#e 970nomF r S Algonhn C Amivel Tm
# inclode <Stdto h>

Vid meain C)
E avtro, av tafsO,
b t 2 0 ) , áyt L20), tat L20),
Pnin C "6n ten fotol nun berr proce ae4")
Sconf C %d", 4»);
prin C"1Etm noces vrat Tme\n ");
7 7 - o ; iknj itt))
E

3wtLo3 o /oiting time ns pr ocesa is O


col Coiting #ime
orCiL; i<n j it+)

Coijiijr+)

pnin "\» hocess \t \fBerst Timne \ feaig Tme \tTm


oneund Time ) Cel. TunnenoUnd Tne
Cia o; irn; ii+)

awtt utLi]
avtat+ tat Lil;
priny C"\» P[vd]\t \ t %A\t\ d\t \%A",
bt i wt LI, tat E}I);

avwt/
aVtat /=
C " » l»Arneye beiing Tme: %d" , avast)
pmin nAvenee Tmnonend 7ime d ', a vot)
Jeteh C)

Ouput q agron
Cnten 7otol nUmber pnoce4sE4 3

Gnten rocess u s t 7me


PLL24
PL)3

roces4 nust Tme oitng Time unnorand 1ime

PLI 24 2

P 24 27
2

A Venoge aiting Time 12


Ave rog e 7unnoround 7/me 23
nogycm STF Non- Preemptive
# inelvde < StJio h>
intmoinC)
int
btL20, pL20 wtL20,
pos tmp totL2o9,i,j.
,

n,
To tef
fel =o
Floo ovg-t1
ag--oT/
Cnsen );
Pint C Enter nUmbe
rocrs s:")
Scanf "%d ', n )
C
pint "n tnten ambn Eust
orCie; i<n j it+)
Tme ))
Epnin "2 %d:", it4)

So g 6ens? 7imes

pesi
onjd+4J*nj ji+)
pos j ;

P Lpes)=Yr
t--0j
fotol t -
atL})
aug- t -Cloet ) totol/n
o1dd-o
/min C" |n Pre ce ss | | Snst rme t aei ding Time | f ")
ni-oj iknj itr)
totol tot CO
toiC3);
3
- tot (flco+) totolni
printC "( Avenege bei ing Time - y-a )

pnin " lnAvenege 7onarovrd Tine =


"1OY- fe7)

Cutut
n t e r nvmben ocrss
ntnter Brust 7ime
:pl:6
P3:2

Pnocess ust time


oiting Tim e
PL2 6
Pt 7
PL /6
Avenege win 7me 7 Ooo oO

Aven oge nun oneor d 77me 3 OCOOU0


# ne-Cmptive Shon Tes Job ms
ineluede <stdio.h
void moin C ))

intenmivel-Time
int , Smoles7 Lt0), buns
Lto), trmypLto) time
j
dovb le oi Time imt
/e= O, 7nnoneond. time
tlcot eenoge o,Cnd
aoing
-

-
t'e
onnono und. tme
nge.
Pin » dn ter he todel
tonf C mber pro cradra )
"d timt)
/inZ
" n Enter Detoik 2d
on Ci- o; ix imi j Pvce1sra \n ", hnit);
i47)
pin "l» éDtor Anvi vel Time
\6")
Sconf

Scenk C"%d ', bers timc CO)


Temn bens 7 ime Li)Dz

en ime = o 7 coun ! =
'mit ime+)
Smo Ues t 4
C1-e; ikimi'tj i}4
ennivel- YmeLiN <> time d l
boru time E:J<
bens _ me LSmels 7) d&
bens -

ime Li)>0
Smolest -i

bonst- 7ime LSmoUrs


CBensT time /SmeUrs o )
Count +
end ime t
heit- t'me =
veit_ tima t Cnd -

anrivel- timtLs'metls r - Yenp


ESmols77/
ronn enOend time = torncroond-time 7 end - enn 1Vol. time

3 LSmelest;
vencge toiding-Aime- aolY- time /limi
avenogd- tunnenevnd- ime = tun narovzd-.ime / m l t
,
A
"n\» Avenoge iting Time T%l7 1 atnepe-
aoiting- timc )
pnC"Avenege Tunnonomd Tme f%lE \n "
7nerovnd- ime )
ge teh C);

Cnter he totol 6 .
q Pnocesse 5
cnter De toils 5
reeesses
C n Abnive me 3
Cnten us 7/mc

Enter Annivc/ nc
ntr nvs Time

ntern Annivet 77me


enten Bnvs 7ime 2
Ent Ann ives 77m
ene vs 7/me 6

nten Armie Time S 2


Entrn Bus Time 3

enegc 7unronwnU 77me t


nten Te totel m b e ro crs
Seheduling nn -e-emyptive) grom
Void moin C)
i n t btL2o), PL2o), t [ 2 0 ) , to1[2o7, p r e ) , "1j.n, 70ol

o s , temp t , ay- to
Pin f "6nten Totol Membm Pocrs4:)
Scon C" d", kn );
I n ten Brvst Time 4 pio7ity
on Ci-e i<n it+)
print "]»P£hd) \»', itt);
" /Sens 7ime ):

pmin1 Pnioni ty: ) /


Sconf C "%d", &p )
num ben
Conorn process
3 p*oces< nUmbo in dscending d o
/Sorin4 bens ime pioniy
Sen 7
Csi'ng e lte 7on

en Cir;ikn; irt)

14jonijr)

3
posji
PLiD =p7Lpas)
PrLpos) = temPi
Semp bt L11?
st Ci)-bLpo;
bt tpos =
terpi
trmp-p:
PLi pLpsI
Phpos - Frnp

awtLo-o ueiin ime krfirst nocess i


Coeote areimy tibe.

}<ii/ +)
totol t a t LiI
vy-et = torol/n eiing ine

in "nhocess ltE Runst ime 6ieiting Time \6tmn


an ond Time )z
on i=oj *n ; iit )

fatL) =
tLiD+atE:I; c o l tmneround e

Sotelt - f a t CII

p r i C"[nPLhd) | f If d|E\ tlf%d"pLII, bIL


t E I ] ) totLII) ;

3
ay tot fotel/n S Movg 7enarond time
prri'nt C 7lnAverege iveiig Time d "
pm " /»Avrnege 7unn onom d

Jedeh O;
Sunst Time :
Pionity 3
PL
Bunst 7ime i 5
Pnionity
PL
Bons Time 2
hiomily 2
PLs
vns t Time 3

ion
oces4 Borsi 7ime
Abtng T/me Ton norwnd Tme

PL 2
12
PLs)

2S

Avenoge i ting 7me-0


C
Averege unnonO Und 7ime 16.
Round Kobin Schedoling i t Annrivol Time
Void moin ()
j, nz Time
ntat=o,
1
7emo n, Fey o, ty
H -o, atLto)
Prir Enty Totel
b1Lto3, ntZo
Procers : | " );

len (covn 1- O
Coun 7 <n jtovnt
t+)
prin' C"6ntn ivel Timt
Yod: ", ton d tL)z Bons 7ime Jen procus Won bo
ScenC%d",
S enf C%S',
ta 1Loun
t3);
t Zcown /)=3tdstZlawn)J
Lzoun )
Pin"Lnte Time puen dum l6
Scen C"%4',sy ) ");
in | » nhocess |6 /Tmn
forn time = 0, coun 7
cno
un d Time
ltoi tiog Tine An)
, CTLcovnt
-o
7 ol!0)
<- ty é ntLeoent >0)
E time4 =ht Lcount];
ntCan/= o)
3
else CrLen_1> o)

nt Leoun - tg =

rme 4tfi
nemein C
Pin --P
77 t % d ) t / \ % d \ t / \ h d\n , Covo Irt
m e - a t Lcoon7 2, time -a Zcont J - b6 Lcovn 17) ;

CEt ime a t Loun ) -

8f Lcoen tI
7ime - at Lcan J

=oj
3 Covnt =*n -L)
Coun Oj
ese i Cot2con / +4 ) <- fime)

clse
Coon? =07
Dnin
pint4 A J n
7 UnnOn bun Time =
% , 1r * i . )
Jeteh C) 7

Cnten To tol ocess i


6
Romben s
Cnten Arivo/ T?me end Bums7 Time on o tes s L

4 3
Enten Anrivet 7ime ond Bors 7imeen ne eis Mmbea 2

rocess Nomber3 i 2 8
Enter Amnives Timc omd Runs t 7im en
nd Bms t TimeJ lnoces 4
Nom bo ti 36
Gnh Aivel Time

noeeso Tnnonivnd Time iCo'biny Time


2

' 26
2

Moi tng Tim Sso do 0o


Avrroge
7
7onnonovnd 7me /4booOo0
Er
h e Soundad- Bdter
ProslemProdvcer Cons Um vr
ros)
#inclode <stdio h>
# include < stdi6 . h >

mutex -4, ull= o, cmpy:s, za;

Voi dmoin C)
2 fnt n

Void pro duetr C);


Verd Consumes C)
int woi+ Cin* );
inSiynol (int)
Pint " \»4 oducrn \n2. Cons umenn3- r+))
ahile )

C n \n ntm you choice


i ");
pin

Saiteh Cn)

Cese L 4 lmutex a-2 )4 cmpty !=o)


pn odvden ();

ese ");
int 3f sful!!
bheok
(mutex r-4 )4A
ul-o))
Cose2
Con &Um tn C),

hinlfZ "B is empy !!");


Cose 3 :
ei tlo)
bneek
Fntte+ Cint s)
retunn - - s );
3
in ? gnel Cint s )

retenn Ct S)

Void pnadveer ()

mutes =
oit CmUtr )
ynol Cu );
ampty = o t C epy )

prminL " in/roducn prodvers he ittm %d", « )


muTex Signol Cmuten )
void Consmn C)

mutex =/oit Cmutx )

empy gnelCenoiy )
Prin " {nconsumer Consum em , X);
mutex = signel Cuter );
Prodveerz
ConaUmen
3 Zt
ente yoe Choice :L

nodver prodvces he iteo


ntn youn hoce 2

Prrodeer prodee he em 2
nter Yo Choiee 1
rodvee7 prodvces h iYem
En tn Vovn Choice

En Torn Youn chv'ee 2

Cons men Cons cmas m2

Cnten ovr Choice : 2

Consomen Cons Cmes Ter 2


Cn ten yo hoice
# inchl x Stdo >
int moin K)

nt

olee s Ls
,2S

,n mexsLs7 =2 ES ,5, 3 , E3, 2,23,E7,e2


S2, 2 2 23, 2a, 3, 3 3 S;
int
ovwl Ls) =

3, , 2S5
ind »), dns
Ln], nd= 0j
or CkEO; ken ki4)

need LILn3
O i ki it)E
m y+/)
meed E I 3 L } ) = mor

S nt :
y O
or C o; kes j t
Lon 74
C4ti -= o)
lorn o

neok

y 2*o)
ans indi+ J

r y o7 ycm yt

Pin Folloang s e SFE Segunee \n


o7C=o; ixn -4 / i1+)

print C "Ph d->",


ms IU)
in Ptds, ons L1);
ne tunn ( o ;

output
itree
FoUocy
PL-> P3 P >fo-'2
FIFo Zmplementation
# nelvcle <Sho -h >

Void m oin ()
ovwil, count =o
nt a
Lso], momc Lto), no, * ,
J:
the he
emenee
shigí \o")
1pnir en t ength
Scen hd n )
\n )
pin C "l» cntr he ne/erente Siny:

Scen h d ' boT3) ;


7 entez he number nemis
pin C
SCen C "%d" 4no);

/rome L i I - -L;

1 n Striny lF/ogenmes
\n
k itt)
on Ciz ; =n;

2in

a voil 0
oC k oj k*no ) k t t ,
Cfromd LkI== aCi)|
avoil LS
Caver:= o)

nO

hd o :3);
prinT7
pin
oge Foul'Ts , oont )
Prin
getch C);

outpu
Fromr4
fhe numberz

Sting /nom

L
2

2
lege Fovt 6
#Optmot iy
inelvde stJio h 2

moin C

int no- - o
pnint
nomt
n Terr umbe
n0- oges fromtsL 1, P9g
romrs )
Sonf C od ", Aro romes
/inC n e n nember
Scor Cpd", tno
Peges: )
-yyegs);
ind n ter
/ raneneke S
ng: )7
on i / < no
P)
Seen 'Yd yesL)
Jon o homes i)E
g4 7
oms

nom es

bn cok }
y =1

no- nomc1
n on ) =-L )
oults +
/noma

bneok
no- zomts
tmp -1)
pas

oy s o)
- -

mOx empo
0i
no- -omcs
Ctem jÍ>mox)
mox ern

n o- -

Ad\&
I n Toted olts
nomed
Entr nwmber

Gnter numbe 3 2L325 /3

eneneeShin
cnter

3
2 3

5 3

3
#LRU Age
Reploce men?
nclude xS+dio h >
in ndLk VC n t time LI, int n) E
int nini'nmum ime Lo-pos- O

time Z1) < min i'mum)


minimUm

33
ne tunn os
int moin C

Tnt no--7r - no- homnaLte) P99eaLa)


Coun fen = o
y, /loy2,j Posfods = oj
Pin Chtr nom ber omes
d " , Aro - Freme )
por in Cn
e ombr gs

"d no--Ys
E n t e r inence sing )
gs 4)E

Scer
E
izo; jk ro- mes
-
emes L
=

(i= o na
stnL d",
Ages LiI)
Seen
romes 1)
(i:0
nem es Z )

3
oriz
nO- romea
S
Couner t4
me )=oon ten
2 1
ncok

o)
O n6- CL omes

Covn ts +
)E
me Cov ters 7
breok S
L o y : r o ) E pos = indLR ime no- poms
we
Covn ter 4 ovls 44 omc4 os 1 2Ys;
Tinepus = can ta
3 prin " ln )

prn " |n ln 7otel e g o s Yod',ots J

output
ntn umber omes :3
nter nUmbo c
Entor neferCn ce Snmy S 756 73

5-1

3
7otol g 1 fovl 4.

You might also like