<<

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 TINU -1 ORTNI D TCU OI N 1 tahW. si xisop nats d ?dra nialpxE eht tnere tesbus of xisop .dradnats etirW o erutcurts o f rgorp am to f retli tuo non - xisop mo tnailp sedoc from su er rgorp am.

60( m )skra ( C- 0102 ).

:snA ehT I EEE eicos ty f demro a laiceps ksat fo ecr c la del OP SI .X oT c etaer a tes of sdradnats for epo r noita sy smets etni r af c nie g.sev lare bus stoor are OP S OP,1.XI SI b1.X OP DNA OP SI 1.X c

OP SI 1.X eettimmoc rp o sesop si dnats a dr for b esa SO API siht si dnats ra d eificeps s rof nitalupinam g selif a dn .ssecorp It si wonk n sa I EEE 1.3001 - .0991 t eh OP SI .X 1B eettimmoc esoporp s a s te fo nats d dra APIs of r RT SO fretni a ec th ese in edulc I . sihT is nwonk sa I EEE nats dard 4.3001 - eht.3991 OP S c1.XI dnats a dr e seific itlum edaerht d nimmargorp g tni e fr a ec .

OP_ enifed# OP_ SI OS_X U CR E OP_ enifed# OP_ SI ECRUOS_C_X 03991 9L .maertsoih h.dtsinu I tn niam )( { OP_ fedfi# OP_ SI REV_X S NOI ”<

orp a etirW.2 a rgorp am c ro ++c xisop oc m lp e tnem rgorp am ot hc e kc f llo ow gni il m sti : un)i m reb o f kcolc cit ks ixaM)ii mum n um reb o f dlihc sessecorp ixaM)iii mum htap gnel th xaM) imum un m reb fo sretcarahc ni f eli eman xaM)v imum un mber o f nepo f seli rep ssecorp . 80( m )skra Dec /9002 M ya 02 21 :snA

OP_ enifed# OP_ SI OS_X U CR E

Dept.of CS&E,SJBIT egaP 1

GNIMMARGORP METSYS XINU enifed# OP_ METSYS SI ECRUOS_C_X GNIMMARGORP 03991 9 L SC01 26 .maertsoih h.dtsinu I tn niam )( { I tn r ;se If(( =ser sy ocs n )XAM_NEPO_CS_(f ==-1) orrep r “( sy ocs n )”f ;

er((fi s ochtap= n P_,”/“(f C XAM_EMAN_ ) == - )1 orrep r tap“( h fnoc ” ;) esle ”<

If(( =ser sy nocs i _CS_(f CL ==)KCP_K -1) orrep r “( sy ocs n )”f ;

er((fi s= sy fnocs C_CS_,”/“( H LI D XAM_ ) == - )1 orrep r “( sy ocs n )”f ; esle ”<

er((fi s ochtap= n P_,”/“(f C )XAM_HTAP_ ==-1) orrep r tap“( h fnoc ” ;) esle ”<

nialpxE.3 t eh c omm no tcarahc e scitsir o f API a dn ebircsed eht rre or s t suta sedoc

60( m )skra yaM 9002 / yaM 2102

snA :

ehT APIs ruter n an tni e reg v eula ti idni c eta ht e te noitanimr sutats fo th rie fi.noituce na API snruter eulav -1 ti snaem API f delia dna eht labolg elbairav onrre si tes htiw na orre r resu.edoc p secor s se niam llac eht roorep noitcnuf ot tnirp aid g citson ssem a eg fo uliaf re to dradnats tuptuo or ti may c lla ts r orre r uf n noitc a dn giv se ti e onrr sa a llavutc arg nemu t

Dept.of CS&E,SJBIT egaP 2

GNIMMARGORP METSYS XINU ,eulav eht ts rMETSYS rre or uf n noitc GNIMMARGORP snruter sem as g e rts i n g dna eht u s re p secor s ot tnirp SC01 aht 26 t egassem .

oc sutats rorrE sutats oc ed gninaem SECCAE S a ssecorp seod ton ah ve sseca pe noissimr ot p mrofre an A a aiv noitarepo aiv a A PI. REPE M a API w sa detrtoba eb ac esu eht nillac g rp o ssec t’seod vah e resurepus eht resurepus p gelivir e NEONE T na dilavni elif eman w sa deificeps ot na A PI BADF A ipA saw c della htiw a n dilavni elif rotpircsed EI TN R a A PI e x noituce saw ba o detr eud ot a s ig lan etni rr noitpu GAE AIN a API saw etroba d b suace e emos sy ets m r cruose e ti deriuqer w sa iraropmet ly anu v ehT.elbalia API dluohs eb dellac a niag retal . MEMONE a API w sa detroba be ac u es ti dluoc ton etacolla dyana im c omem ry EIO I O/ rre or cco u derr ni na API ex noituce EPI EP a A PI detpmetta ot etirw atad ot erpip hcihw h sa no daer re EFAULT a A PI saw sap s de na vni a dil sserdda ni eno fo sti arg tnemu s EXEONE C a iPA dluoc ton e x etuce a rp og mar aiv o fo eht ex ce A PI CE H LI D a ssecorp t’seod ah ve any dlihc orp c sse hcihw ti nac tiaw .no

.4 gnirB tuo eht impo ecnatr of gnizidradnats eht INU X .SO tahW stcepsa of c rgorp amm gni egaugnal ah ev neeb s dezidradnat ni ISNA ?c htiW ius t elba xe am lp e gnirb tuo eht two i pm tnatro id ff ecnere n/b K R& C dna CISNA w hti tcepser ot f noitcnu nipytotorp g a nd sretniop ot f noitcnu . 80( m )skra Dec- aM/90 y - .21

:snA

ehT I EEE eicos ty fo mr ed a laiceps ksat of r ec cal del OP SI .X oT c aer te a s te fo sdradnats rof epo r noita syst sme fretni a nic g. eveS r la us b stoor ra e OP SI OP,1.X SI b1.X NA D OP SI 1.X c

OP SI 1.X eettimmoc rp o sesop si dnats a dr for b esa SO API siht si dnats ra d eificeps s APIs rof nitalupinam g selif a dn .ssecorp It si wonk n sa I EEE 1.3001 - .0991 t eh OP SI .X 1B eettimmoc esoporp s a s te fo nats d dra APIs of r RT SO fretni a ec th ese in edulc I .CP sihT is nwonk sa I EEE nats dard 4.3001 - eht.3991 OP S c1.XI dnats a dr ps e seific itlum edaerht d nimmargorp g tni e fr a ec .

psa rojam ehT rojam psa e tc a r :e

Dept.of CS&E,SJBIT egaP 3

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 x F noitcnu otorp ty ip ng x troppuS fo eht tsnoc dna elitalov atad ifilauq e sr x troppuS diw e ahc r setca a dn ilanoitanretni z noita x timreP noitcnuf sretniop ot eb desu tuohtiw ered ef icner ng

NA SI C stpoda uf n noitc otorp ty ip ng hw e er uf cn noit noitinifed dna lced a noitar edulcni a,eman rg tnemu ad ta type dna nruter eulav d ata typ .e sihT en selba otsreilmoc kcehc f ro noitcnuf sllac ni resu p smargor taht ssap dialvni .on fo ra g stnemu ro elbitapmocni arg tnemu atad ty ep .

F ro e x lpma e

isnU g den ol ng of o c( h ra * elbuod,tmf )atad ;

NA SI C eificeps s taht fu noitcn retniop may be us de ekil uf n noitc .eman No red e ef r iecne s n dedee wh ne illac ng a f noitcnu esohw sserdda is deniatnoc ni a retniop . Ex elpma ht e niwollof g tnemetats ed f eni a noitcnuf retniop rtpnuf hcihw sniatnoc eht sserdda fo :oof noitcnuf :oof

Ex nret diov elbuod(oof x y ,z tsnoc *tni ;)rtpl

rtpcnuf*( dioV rtpcnuf*( ) ,elbuod( c tsno ni ;oof=)*t

.5 etirW a ++c orp gram ot tsil eht lautca seulav of eht follow ni g metsys noc f noitarugi lim sti no a nevig xinu OS. )i m xa imum .on o f dlihc sessecorp taht nac eb c detaer . )ii m xa imum .on o f f eli s taht nac eb denepo ylsuoenatlumis . )ii m xa imum .on o f sem s ega seueuq taht nac eb dessecca . 60( m )skra Dec- aM/01 y- .21 :snA OP_ enifed# OP_ SI OS_X U CR E OP_ enifed# OP_ SI ECRUOS_C_X 03991 9L .maertsoih h.dtsinu I tn niam )( { I tn r ;se If(( =ser sy ocs n )XAM_NEPO_CS_(f ==-1) orrep r “( sy ocs n )”f ;

er((fi s ochtap= n P_,”/“(f C XAM_EMAN_ ) == - )1 orrep r tap“( h fnoc ” ;) esle

Dept.of CS&E,SJBIT egaP 4

GNIMMARGORP METSYS XINU ”<

If(( =ser sy nocs i _CS_(f CL ==)KCP_K -1) orrep r “( sy ocs n )”f ;

er((fi s= sy fnocs C_CS_,”/“( H LI D AM_ X) == - )1 orrep r “( sy ocs n )”f ; esle ”<

er((fi s ochtap= n P_,”/“(f C )XAM_HTAP_ ==-1) orrep r tap“( h fnoc ” ;) esle ”<

} fid eht tsiL .6 tsiL eht fid f secnere teb w nee ISNA C dna K & R ialpxE.C n 50( m skra )

yaM - eD/60 c- yaM/60 -08 ceD/ - 90 .

:snA

fid rojam ehT rojam fid f ere n ec n/b NA SI C dna K&R C a er :

x F noitcnu otorp ty ip ng x troppuS fo eht tsnoc dna elitalov atad type ifilauq e sr x troppuS ediw ahc r setca a dn ilanoitanretni z noita x timreP noitcnuf sretniop ot eb desu tuohtiw ered ef icner ng

NA SI C stpoda uf n noitc otorp ty ip ng hw e er uf cn noit noitinifed dna lced a noitar edulcni a,eman rg tnemu ad ta type dna nruter eulav d ata typ .e sihT en selba otsreilmoc kcehc f ro noitcnuf sllac ni resu p smargor taht ssap dialvni .on fo ra g stnemu ro i elbitapmocn arg tnemu atad ty ep .

F ro e x lpma e

isnU g den ol ng of o c( h ra * elbuod,tmf )atad ;

NA SI C eificeps s taht fu noitcn retniop may be us de ekil uf n noitc .eman No red e ef r iecne s dedeen wh ne illac ng a f noitcnu esohw sserdda is deniatnoc ni a retniop . Ex elpma ht e

Dept.of CS&E,SJBIT egaP 5

GNIMMARGORP METSYS XINU niwollof g METSYS tnemetats ed f eni a GNIMMARGORP noitcnuf retniop rtpnuf hcihw sniatnoc eht sserdda SC01 26 fo :oof noitcnuf :oof

Ex nret diov elbuod(oof x y ,z tsnoc *tni ;)rtpl

rtpcnuf*( dioV rtpcnuf*( ) ,elbuod( c tsno ;oof=)*tni

nialpxE .7 nialpxE a yn f evi rre or sutats edoc f e ro r ror .on 50( ma )skr eD c- 01 .

A :sn

ehT APIs ruter n an tni e reg v eula ti idni c eta ht e te noitanimr sutats fo th rie ex fi.noituce na API snruter eulav -1 ti snaem API f delia dna eht labolg elbairav onrre si tes htiw na orre r resu.edoc p secor s se niam llac eht roorep noitcnuf ot tnirp aid g tson ci ssem a eg fo uliaf re to dradnats tuptuo or ti may c lla ts r orre r uf n noitc a dn giv se ti e onrr sa a llavutc arg nemu t ,eulav eht ts r rre or uf n noitc snruter sem as ge rts ing dna eht us re p secor s ot tnirp aht t egassem .

oc sutats rorrE sutats oc ed gninaem SECCAE S a ssecorp d seo ton ah ve sseca pe noissimr ot p mrofre an A a aiv noitarepo aiv a A PI. REPE M a API w sa detrtoba eb ac esu eht nillac g rp o ssec t’seod vah e resurepus eht resurepus p gelivir e NEONE T na dilavni elif eman w sa deificeps ot na A PI GAE AIN a API saw etroba d b suace e emos sy ets m r ose cru e ti deriuqer w sa iraropmet ly anu v ehT.elbalia API dluohs eb dellac a niag retal . MEMONE a API w sa detroba be ac u es ti dluoc ton etacolla dyan ima c omem ry EIO I O/ rre or cco u derr ni na API ex noituce

Dept.of CS&E,SJBIT egaP 6

INU X METSYS GNIMMARGORP SC01 26 TINU - 2 NU IX SELIF

nialpxE .1 nialpxE t eh fid f tnere f eli sepyt aliava b el ni XINU ro P XISO tsys em. 80( m skra ) yaM( - D/80 ec- aM/80 y-1 yaM/0 - 21 ) :snA eR g lu ar F :eli sihT may eb rehtie et xt ro anib ry f eli dna may eb ex atuce b el dedivorp eht ex noituce ir g sth fo eht f eli ra e s te dna siht are nettirw by us ,re c na eb c detaer isu ng iv .rotide It si ev ry elf x elbi ot c ,etaer r ,dae etirw idom, fy dna omer v de by s cificep syst me .sdnammoc otceriD ry :elif It si ekil a elif redlof taht iatnoc ns rehtona ,selif nidulcni g ridbus e otc ry elif .s It sah owt sdleif f emaneli dna edoni .rebmun A otcerid ry may be detaerc isu ng ridkm dnammoc sa ridkm namus/rsu/ eht otcerid ry elif si edisnoc r de ot eb pme ty fi it e elif rehto on sniatnoc on rehto elif e cx tpe ”.“ dnA ”..“ selif . FI OF elif : It si a sp ice al epip ived ce lif e cihw h sedivorp a ropmet ary bu eff r of r owt or orp erom orp c sse ot etacinummoc by itirw ng tad a ot a dn idaer ng ad ta morf b fu .ref T he is ze fo eht fub f re etaicossa d htiw FIFO elif si if x de ot PI _E BUF. On ec the I CP beg sni th ne no ly omem ry lliw be acolla et d of r FIFO elif dna ti eb semoc phy lacis ly ex itsi gn . iruD ng I CP eht atad nettirw ot FI OF may ex deec eht PIP UB_E F neht w retir rp o ssec lliw eb dekcolb daer a litnu a daer er ekam a r ae .d It c na eb rc e deta isu ng ofif/ved/ ofifkm ofif/ved/ 5

tcarahC er ived ce :elif It erper s stne ht e phy lacis ecived taht stimsnart ad ta ni a hc a car t re desab nam n re . Ex elpma enil ,retnirp elosnoc . For a rah d ksid seht e a er us de ot r wa da at refsnart b wte e ne orp c sse dna .ksid SO lliw lacitamotua ly ekovni pa rp etairpo ived ce p ot noitcnuf revird noitcnuf ot p e ofr rm eht atad snart f .re

B kcol ived ce :elif It erper s stne a phy lacis d ecive taht stimsnart da at kcolb ta a E.emit x elpma polf py id sk .sevird

Dept.of CS&E,SJBIT egaP 7

INU X METSYS GNIMMARGORP SC01 26 It c na eb rc e deta by

511 c 1kdc/ved/ donkm 1kdc/ved/ c 511 5 rof hc ara retc d e eciv lif e

of 51 051 b 1kdb/ved/ donkm 1kdb/ved/ b 051 51 of r kcolb ved i ec lif e

dnoces argum tne ot eht c dnammo si ’c‘ rof ahc rac ret ecived elif dna ‘b’ of r kcolb cived e .elif rehtO ra g stnemu er p tneser rojam dna ronim n .rebmu A rojam bmun er si na edni x of eht rek n le lbat e taht sniatnoc eht serdda s fo d ive ce vird er fun snoitc wonk n ot eht sy mets . enO ived ce revird nac es evr am ny ived c se dna ht ey r eriuqe ronim bmun er ot evres for ht e .secvied roniM rebmun i s dessap sa ra g tnemu ot ecived vird er nehw ti si c a .dell

.2 W tah si na A P ?I How si ti d fi f tnere f or m c yrarbil f cnu ?snoit W yh gnillac na A PI si more t i em usnoc m ni g neht gnillac na u res fu .noitcn 60( ma )skr M( ay- ceD/70 -08)

:snA

inU x sedivorp a tes ffo ap snoitacilp orp gr gnimma afretni ce hcihw may be dellac by esu r margorp ot mrofrep syst me cificeps .snoitcnuf T eseh cnuf snoit wolla sresu noitacilppa ot tcerid ly m etalupina sy ts em stcejbo hcus sa selif a dn ssecorp taht nac be d eno by gnisu c arbil ry uf n .snoitc F htru e eromr c arbil ry oitcnuf ns llac eseht APIs ot mrofrep ot lautca dekrow tnavda a eg suht sresu may use eseht s PA Is id r tce ly ot by p ssa revo he da of nillac g a c arbil ry itcnuf o .sn

tsoM APIs ca c sse rek n le lanretni ruoser c .se T uh s nehw na APIs ekovni by a rp o ssec ht e ex noituce etnoc xt fo eht ssecorp si ctiws h by eht lenrek f mor esu r edom to lenrek om d .e W neh na APIs ex noituce setelpmoc a su er rp co sse si ehctiws d cab k ot resu edom . T sih etnoc xt nihctiws g rof PA I c lla usne r se taht rp o ssec a ssecc k lenre d ta a ni dellortnoc rennam dna iminim z se any ahc n ec of ur n wa ay a noitacilpp mad age ni ht e sy mets . Hence API si erom emit oc usn m ni g.

Dept.of CS&E,SJBIT egaP 8

INU X METSYS GNIMMARGORP SC01 26 .3 ebircseD eht XINU lenreK troppus f ro f .seli ( 60 ma )skr aM( y- eD/70 c- yaM/80 - 21 )

:snA

lenreK h sa eht lif e lbat e taht peek kca of lla o denep selif ni the sy ts e .m erehT si osla sniatnoc taht elbat edoni elbat taht sniatnoc eht effid r tne setubirtta fo eht selif er ce tn ly ac esec d.

W neh a resu ex setuc a ,dnammoc a rp o ssec is rc e deta by eht k lenre to ac rry tuo eht dnammoc ex noituce and eht orp c sse sah sti nwo atad rts u erutc na d ti sah na elif rotpircsed TDF.elbat sah a XAM_NEPO seirtne dna drocer lla eht selif denepo by ht e .ssecorp W neh op ne uf n noitc si ellac d eht ke nr el lliw evoloser ht e htap n em ot eht elif .edoni

If the elif edoni si ton dnuof ro eht ssecorp al c sk etairporppa pe noissimr ot sseca eht atad edoni atad , If o p ne c lla sliaf neht ti snruter -1.

orp ehT orp c sse rof siht a re as :swollof

x ehT lenrek lliw es a hcr t eh ssecorp F TD dna lo ko rof eht tsrif desunu tne ry.If tne taht ,dnuof taht tne ry lliw eb ised g den ot er f ecne .elif edni ehT edni x ot eht tne ry w i ll eb ter u denr t o eht p or c sesse a s eht elif ed s tpirc or fo t he elif denepo elif . x ` eht ke lenr lliw nacs eht elif elbat ni ti s lenrek ecaps ot dnif na a desunu entry taht eb nac eb issa gn de ot eht r fe nere ce elif . If na desunu tne ry si of u neht,dn eht niwollof g ve e stn lliw .rucco rp eht)a rp o sessec F TD ne rt y lliw eb tes ot tniop ot siht elif elbat e tn ry. eht)b FT tne ry lliw tnoc a ni eht tnerruc elif tniop re fo eht nepo elif . dna siht si na a eht morf tesffo morf eht eb g ninni g fo eht hw.elif e er r dae ( )ro etirw sa ot be enod . )c eht FT tne ry lliw eb tes ot po tni ot eht edoni elbat tne ry hw e er eht edoni rocer d of eht elif si derots .

Dept.of CS&E,SJBIT egaP 9

INU X METSYS GNIMMARGORP SC01 26 )d FT tne ry iatnoc n an nepo edom th ta ht e lif e si enepo d of r r dae - no ly w, etir - no ly.c lla rof eht.htob edomnepo deificeps rf mo eht nillac g secorp s sa na rra ug tnemu ot nepo uf nct noi .llac )e hT e re ef r ne ce tnuoc in eht elif bat le tne ry si s te ot dna.1 ti ke pe rt a kc fo oh w am ny elif d rotpircse rf om a ny p r seco s se a re r e ef r nir g eht tne ry. r eht )f eht r e ef r ne ce tnuoc fo t eh ni – omem ry oni de fo t eh elif si rcni e desa by 1 . ehT fig. swohs eht ,TDF eht lenrek elif bat le dna t eh edoni elbat a retf eht p or ssec sa denepo eerht selif x,y,z for daer no ly cba, for daer/etirw dna, cba for tirw e no ly eht. r fe e ner ce tnuoc ni a elif edoni re droc s ep seific woh am ny elif t ertne,elba s era itniop ng ot the lif e edoni re i.droc f eht tnuoc si ton ti,0 snaem taht 1 ro rom e rp sseco a er c u tnerr ly po e nin g eht elif rof a ssecc . If eht rp o ssec llac eht kees sy mets llac ot gnahc e elif retniop ot a d ereffi nt tesffo rof en xt daer epo r eht,noita lenrek lliw esu eht elif rotpircsed ot eht in ed x ht. e ssecorp FDT ot dnif ht e retniop ot ht e t elba tne ry th ne ke lenr ca c sse siht ot get retniop tniop ot elif edoni re droc dna neht ti ch kce for a fi.elif eht lif e ty ep is elbatepmoc htiw se t,ke he rek n le lliw ahc n eg eht elif retniop ni eht FT ac gnidroc ficeps eulav eht ot eht eulav ficeps i de ni eht keesl a rgum .tne Wh ne eht ssecorp sllac a esolc noitcnuf ot eht esolc na nepo ,elif eht qes u ecne fo a stneve a re sa wolleb . x ehT rek n le stes eht oc rre nidnops g TDF tne ry ot be desunu . x It d ce r stneme eht er fer ecne tnuoc ni eht co err s nidnap g F TD tne ry by fi.1 ht e fer e ner ce tnuoc si llits non -z ore neht g oto tsal .pets x ehT elif elbat ne try si dekram desunu . x CR ni eht oc r idnapesr ng elif doni e lbat e tne ry is ed c etnemer d by i.1 f ht e nuoc t non llits non -z ore ti g oto tsal .pets x If eht drah knil tnuoc of eht edoni si ton z ore it snruter eht c lla er htiw seccus s esiwrehto.sutats edoni ta elb tne ry lliw edam nu u des dna ollaed c seta lla hp y lacis elif eht fo egarots ksid egarots fo eht elif ,as lla eht htap seman ah ve neeb omer v de by emos p ssecor . x It r snrute ot eht orp c sse htiw 0 no sseccus sutats .

Dept.of CS&E,SJBIT egaP 01

INU X METSYS GNIMMARGORP SC01 26

F eli sed c rotpir elbat elif t lba e edoni lbat e ps lenreK ps ace

=cr r =cr 1 cr = 1 yx z

r wr r c=1 cr = 2 cba

=cr w =cr 1

aps ssecorP aps ec

er=cR fer ecne nuoc t no daer=R no ly W etirw= no ly RW daer tirw e

Dept.of CS&E,SJBIT egaP 11

INU X METSYS GNIMMARGORP SC01 26 .4 tahW era AP ?sI hW en uoy esu eht m? Why ra e eht AP sI erom emit snoc um gni yrarbil eht naht eht yrarbil fu ?noitcn 30( m )skra ( yaM - eD/60 c- yaM/60 -07 ceD/ - 80 ) :snA inU x sedivorp a tes ffo lla snoitacilppa rp og ar m nim g retni f ca e hcihw am y eb c della by resu rp ogr ma ot frep o mr sy mets ps e cific fu itcn .sno esehT oitcnuf ns wolla resu s noitacilppa ot tcerid ly m etalupina sy mets tcejbo s hcus sa selif dna ssecorp taht nac be enod by isu ng c rbil ary .snoitcnuf F omrehtru er c arbil ry snoitcnuf lac l eseht APIs ot mrofrep ot lautca wo kr ed tnavda a eg suht sresu may use seseht APIs id r tce ly to by sap s daeh revo daeh of c nilla g a c arbil ry uf n .snoitc tsoM APIs ca c sse rek n le lanretni ruoser c .se uhT s nehw na APIs ekovni by a rp o ssec ht e ex noituce etnoc xt fo eht ssecorp si ctiws h by eht lenrek f mor esu r edom to lenrek om d .e W neh na APIs ex noituce setelpmoc a su er rp co sse si ehctiws d cab k ot resu edom . sihT etnoc xt nihctiws g rof PA I c lla usne r se taht rp o ssec a ssecc k lenre d ta a ni dellortnoc rennam dna iminim z se any ahc n ec of ur n wa ay a noitacilpp mad age ni ht e sy mets . eH nce API si erom emit usnoc m ni g.

.5 tahW era eht API c nommo carahc t citsire s tsiL.? yna fo ru seulav of eht abolg l gnola onrre elbairav onrre gnola wi ht rieht m ae gnin w revereh eht AP sI f .lia 50( ma )skr yaM( -0 )5

:snA

ehT APIs ruter n an tni e reg v eula ti idni c eta ht e te noitanimr tats su fo th rie ex fi.noituce na API snruter eulav -1 ti snaem API f delia dna eht labolg elbairav onrre si tes htiw na orre r resu.edoc p secor s se niam llac eht roorep noitcnuf ot tnirp aid g citson ssem a eg fo uliaf re to dradnats tuptuo or ti may c lla ts r orre r uf nc noit a dn giv se ti e onrr sa a llavutc arg nemu t ,eulav eht ts r rre or uf n noitc snruter sem as ge rts ing dna eht us re p secor s ot tnirp aht t egassem .

oc sutats rorrE sutats oc ed gninaem

SECCAE S a ssecorp seod ton ah ve sseca pe noissimr ot p mrofre an A a aiv noitarepo aiv a A PI.

Dept.of CS&E,SJBIT egaP 21

INU X METSYS GNIMMARGORP SC01 26 REPE M a API w sa detrtoba eb ac esu eht nillac g rp o ssec t’seod vah e resurepus eht resurepus p gelivir e

NEONE T na dilavni elif eman w sa deificeps ot na A PI

BADF A ipA saw c della htiw a n dilavni elif rotpircsed

EI RTN a A PI e x noituce saw ba o detr eud ot a s ig lan etni rr oitpu n

.6 tsiL lla eht f eli ta t setubir gnola w hti rieht .sgninaem W hcih of th ese at etubirt s t’nac eb degnahc dna w ?yh tsiL eht sdna dedeen ot egnahc eht f ollo wi gn fi el .setubirtta )i f eli zis e; i )i esU r ;DI )iii saL t ac ssec dna m ido f noitaci it me; vi ) drah oc knil oc u .tn 50( ma )skr yaM( - D/60 ec- 80 ) :snA etubirttA eulav inaem ng F eli ty ep ty ep fo elif sseccA p noissimre eht elif a c ssec p e noissimr rof nwo er,g puor dna o t reh s nuoc knil draH knil nuoc t .on fo drah sknil fo a elif UID eht elif renwo u s re ID GID eht elif puorg ID F eli is ze eht elif is ze ni by et s L tsa ca c sse emit eht emit eht elif saw tsal ca c desse L tsa deifidom mit e eht emit eht elif saw tsal deifidom L tsa ahc nge emit eht emit eht elif ssecca ,noissimrep UID G, ID or drah knil nuoc t ahc tsal saw tsal ahc n eg d I on de rebmun eht sy mets edoni bmun re fo eht lif e F eli syst me Id eht elif sy mets di w h ere t eh elif si erots d ehT niwollof g setubirtta t’nac eb chang de sa ht ey ts ay cnu hang de rof eht e eritn efil fo eht elif F eli typ elif,e edoni mun b elif,re sy mets di jam, ro a dn ronim ecived rebmun . ta egnahc ot sdnammoC ot egnahc ta t etubir ra e

Dept.of CS&E,SJBIT egaP 31

INU X METSYS GNIMMARGORP SC01 26 etubirttA dnammoc F eli is ze ,iv ame c resU Id wohc n L tsa ca c sse & ifidom c noita emit ame,iv,hcuot c nuoc knil draH knil nuoc t nl .7 W tah si na ?edoni yhW era eht sedoni qinu ue ylno w nihti a f li e etsys m? oH w eod s SO m pa eht edoni ot ti s f aneli m ?e gnirB tuo the f ruo im tnatrop fid f secnere teb w ee n os ft dna drah il n sk . 70( m )skra yaM( - 80 / ceD - aM/90 y- 21 ) :snA I on de si na etubirtta fo ti,elif si na euqinu .on desu fer er na edoni bat le. nA itarepo ng sy mets may ah ve ca c sse ot pitlum le elif sy mets ta eno dnaemit na doni e rebmun si euqinu htiw ni a elif sy met no ly, a fi el edoni re droc si deifitnedi by a if el sy mets di dna na oni de n .rebmu

nA SO seod ton peek the n ema fo a elif ni s’ti i edon ,drocer bec esua eht nippam g fo elif seman ot edoni s.on si d eno aiv otcerid ry S.elif p lacifice ly a id r otce ry lif e sniaetnoc a tsil fo seman dna eht ir ser p evitce edoni srebmun f ro lla selif derots ni th ta otcerid ry f. or ex ,elpma fi a rid e otc ry f oo sniatnoc selif xy ,z .a o tu dna xyz hw,1nl_ e er xyz 1nl_ si a drah knil fo xyz. oT sseca a elif say xyz, eht rid e otc ry elif si craes h de htiw rehtie edoni .on or eH.eman elif eH.eman n ec ippam ng si enod .

knil draH knil tfos knil

rc ton seoD ton rc e eta a n we i n edo aerc te a n ew edoni mun ber

nu,seirotcerid knil t’naC knil nu,seirotcerid l sse enod by oor t naC knil eirotcerid s

t ssorca s elif knil t’naC knil elif s ssorca t he elif syst sme naC knil elif s ssorca eht elif sy mets s

In rc e esa eht h dra knil c o tnu fo eht deknil edoni t’seod ahc n eg ht e rah d il kn tnuoc of edoni deknil eht deknil edoni

Dept.of CS&E,SJBIT egaP 41

INU X METSYS GNIMMARGORP SC01 26 .8 tahW are id ff tnere rogetac i se of f eli epyt s va elbalia w hti ?XINU .nialpxE G evi emos co sdnamm ot erc a et hcae o f ht em. 01( m )skra ( yaM - D/01 ec- 11 ) :snA eR g lu ar F :eli sihT may eb rehtie et xt ro anib ry f eli dna may eb ex atuce b el dedivorp eht ex noituce ir g sth fo eht f eli era s te dna siht are nettirw by us ,re c na eb c detaer isu ng iv .rotide It si very elf x elbi ot rc e r,eta e etirw,da om, dify dna devomer by s cificep sy ets m .sdnammoc otceriD ry :elif It si kil e a elif redlof th ta atnoc i sn rehtona idulcni,selif ng ridbus e otc ry .selif It sah owt sdleif f emaneli dna edoni .rebmun A otcerid ry may be detaerc isu ng a dnammoc ridkm dnammoc a s namus/rsu/ ridkm namus/rsu/ eht otcerid ry elif si deredisnoc ot eb pme ty fi ti sniatnoc on rehto elif exc tpe ”.“ dnA ..“ ” selif . FI OF elif : It si a sp ice al epip ived ce lif e cihw h sedivorp a ropmet ary bu eff r of r owt or orp erom orp c sse ot etacinummoc by itirw ng tad a ot a dn idaer ng ad ta morf b fu .ref T he is ze fo eht fub f re etaicossa d htiw FIFO elif si if x de ot PI _E BUF. On ec the I CP begi sn th ne no ly omem ry lliw be acolla et d of r FIFO elif dna ti eb semoc phy lacis ly ex itsi gn . iruD ng I CP eht atad nettirw ot FI OF may ex deec eht PIP UB_E F neht w retir rp o ssec lliw eb dekcolb daer a litnu a daer er ekam a r ae d.It c na eb rc e deta isu ng ofif/ved/ ofifkm ofif/ved/ 5

C tcarah er ived ce :elif It erper s stne eht phy lacis ecived taht stimsnart ad ta ni a hc a car t re desab nam n re . Ex elpma enil ,retnirp elosnoc . For a rah d ksid seht e a er us de ot r wa da at refsnart b wte e ne orp c sse dna .ksid SO lliw lacitamotua ly ekovni pa rp tairpo e ived ce p ot noitcnuf revird noitcnuf ot p e ofr rm eht atad snart f .re

B kcol ived ce :elif It erper s stne a phy lacis d ecive taht stimsnart da at kcolb ta a E.emit x elpma polf py id sk .sevird

It c na eb rc e deta by Dept.of CS&E,SJBIT egaP 51

INU X METSYS GNIMMARGORP SC01 26 511 c 1kdc/ved/ donkm 1kdc/ved/ c 511 5 rof hc ara retc d e eciv lif e

ved kcolb rof 51 051 b 1kdb/ved/ donkm 1kdb/ved/ b 051 51 rof kcolb ved i ec lif e

dnoces argum tne ot eht c dnammo si ’c‘ rof ahc rac ret ecived elif dna ‘b’ of r kcolb cived e .elif rehtO ra g stnemu er p tneser rojam dna ronim n .rebmu A rojam bmun er si na edni x of eht rek n le lbat e taht sniatnoc eht serdda s fo d ive ce vird er uf n snoitc wonk n ot eht sy mets . enO ived ce revird nac es evr am ny ived c se dna ht ey r eriuqe ronim bmun er ot evres for ht e .secvied roniM rebmun i s dessap sa ra g tnemu ot ecived vird er nehw ti si c a dell

Dept.of CS&E,SJBIT egaP 61

XINU METSYS GNIMMARGORP SC01 26 TINU - 3 NU IX eliF A IP s

.1 tsiL na d alpxe in eht ssecca m edo f sgal na d ssecca m ido f rei f sgal . A osl e ialpx n oh w eht rep m noissi eulav iceps f dei ni an epo‘ n’ llac si m ido f dei yb sti illac ng ‘ ssecorp ‘ um ’ksa .eulav 40( m )skra ( yaM - yaM/80 - eD/90 c- aM/01 y- 21 ) :snA sseccA edom f gal esu ODR_O NLY snepo eht elif rof daer o y _O W OR NLY snepo eht elif rof etirw only DR_O WR snepo eht elif rof daer and etirw DNEPPA_O sdneppa atad ot eht dne of eht lif e TAERC_O aerc t se eht elif fi ti ’seod t e x tsi s XE_O CL desu w hti ht e AERC_O T no ly. sihT lf ag c sesua o nep ot f lia a elif deman eht fi eht deman elif a l aer dy ex stsi . CNURT_O fi eht lif e ex stsi ehtsdracsid elif tnetnoc na d tes the elif is ez ot z ore by set . ON_O NBL CO K seificeps taht any bus s tneuqe re da ro w etir on eht elif lbnon eb dluohs eb lbnon nikco g TTCON_O Y seificeps ton ot esu eht deman lanimret ived ce f eli sa eht nillac g rp o ssec noc t lor t e .lanimr

ehT ksamu noitcnuf kat es a wen ksamu eulav sa a n arg mu siht.tne wen ksamu elav lliw eb desU by eht c nilla g rp oce ss morf neht dna,no eht f noitcnu r snrute eht dlo u ksam eulav . F ro e x elpma eht iwollof ng tnemetats issa g sn eht c tnerru ksamu eulav ot ht e elbairav n eht stes dna ksam_dlo dna stes eht n ew ksamu eulav ot “ on e x etuce f or g ”puor dna “ n o etirw e x etuce srehto rof srehto ” S(ksamu=ksam_dlo t_edom S(ksamu=ksam_dlo _IX RG P|S_IW TO H S| _I OX T )H ;

Dept.of CS&E,SJBIT egaP 17

XINU METSYS GNIMMARGORP SC01 26 .2 E nialpx how f ltnc A PI si u des f ro f eli dna drocer .gnikcol 80( m )skra yaM( - 60 ) :snA alf_dmc tni ,csedf tni(ltncf tni tni(ltncf ,csedf tni alf_dmc g, )… ; ehT csedf ra g tnemu si a elif rotpircsed rof a elif to eb dessecorp ehT. mc d alf_ g arg tnemu o hcihw senifed hcihw o p noitare is ot eb p rofre m de . Cm _d f gal esu F ES_ TLK stes a elif .kcol oD ton b l kco fi siht t’nac us c deec i etaidemm ly F ES_ TLKW stes a elif kcol dna colb ks ht nillac g rp o ssec litnu eht kcol si deriuqca . F EG_ TLK seireuq sa ot hcihw p cor e ss dekcol a ps e deific r egi no fo a elif .

F ro eht elif ikcol ng 3 rd arg tnemu si na erdda ss fo a tcurts kcolf -ty ep d elbairav iht. s a seificeps a reg noi fo a elif ehw re eht kcol si ot eb ro,tesnu,tes deireuq .

{kcolf tcurtS {kcolf _l trohS _l typ ;e tahw*/ ol ck ot eb tes ro ot kcolnu f i el *\ / ;ecnehw_l trohS ;ecnehw_l / * a ref nere ce da d sser rof t he n xe t *dleif \ rf tesffo*/;trats_l t_ffO tesffo*/;trats_l rf on eht ecnehw_l er f ere nce sserdda *\ am woh*/;nel_l t_ffO woh*/;nel_l am ny by set ni eht col k de r egion*\ dip_l t_diP dip_l ; dip*/ fo a ssecorp hcihw sah l o dekc t eh elif *\ ;}

eulav epyt_l eulav esu F R_ DL KC stes a daer l o kc no a ps ce deifi r eg oi n F_ RW LCK stes a etirw kcol no a s ep deific r eg oi n F U_ NLCK skcolnu a deificeps region

ehT ecnehw_l trats_l, and nel_l enifed a reg noi fo elif ot eb .dekcolnu/dekcol L w_ h ne ce a senifed a ref ere n ec da dre ss ot hcihw trats_l by et o tesff eulav si da d de .

Dept.of CS&E,SJBIT egaP 18

XINU METSYS GNIMMARGORP SC01 26

_l w ecneh eulav esu RUC_KEES eht trats_l eulav si dedda ot eht tnerruc elif tniop re sserdda TES_KEES eht trats_l eulav si dedda ot eht by et z ore of eht if le NE_KEES D eht trats_l eulav si dedda ot eht dne is ze fo eht f li e fi nel_l si 0 eht, dekcol reg noi ex sdnet morf s’ti trats sserdda ot a sy mets i esopm timil no eht am x mumi is ze fo any f eli ihT. s snaem th ta sa eht elif is ze ni c aer ses eht col k osla e eht ot seilppa ot eht e x dednet elif r eg noi . kcolf tcurts A tcurts kcolf ty ep si ed f deni na d tes by a rp o ssec erofeb ti si dessap ot a fc ltn .llac

.3 tsiL eht st rutcur e desu ot yreuq eht f eli ta t setubir ni .xinU etirW a rgorp am in ++c ot tsil eht f ollo w ni g f eli setubirtta of a nevig raluger f eli dessap sa c omm dna enil tnemugra )i f eli epyt )ii drah knil oc u tn f)iii eli ezis )vi f eli an m .e 80( ma skr )

:snA yaM( - 60 )

{ tats tcurtS tats { st_veD ;ved_t I t_on oni_ts ; t_edoM ;edom_ts t_knilN kniln_ts ; t_diU diu_ts ; t_diG _ts g ;di t_veD ;vedr_ts _ffO t is_ts ze; t_emiT ;emita_ts t_emiT mitm_ts e; t_emiT ;emitc_ts ;}

Dept.of CS&E,SJBIT egaP 19

XINU METSYS GNIMMARGORP SC01 26 .maertsoih h.dtsinu rahc citatS rahc x lbt [10] wr”= x wr xrwx”; AM fednfi# AM J RO enifed# MIN B_RO I ST 8 AM enifed# AM J )ved(RO isnu(( gn ed)de v >> M B_RONI I ST ) enifed# MIN ved(RO ) ved( & MI RON _BITS)\

lpsid diov citatS diov lpsid ay_ t_elif y ep tni( )edom_ts { edom_ts(hctiwS & S _I )TMF { S esaC S _ FI DI :R uoc t << ’ nruter;’d ; S esaC S _ FI :RHC

lpsid diov citats diov lpsid ay_a ecc s tni(mrep_s )edom_ts { edoma rahC edoma [ 01 ]; F tni(ro (=j;0=i 1 9>i;)8<< ; >j,++i > 1= ) edomA [i] edom_ts(= & )j ? x bt l[i] : ‘ - ;‘ edoma<

Dept.of CS&E,SJBIT egaP 20

XINU METSYS GNIMMARGORP SC01 26

nol diov citatS diov nol g ahc(tsil_ r eman_htap* ) { vtats tats tcurtS tats vtats ; tcurtS g puor * p_rg ; ;p_wp* dwssap tcurtS dwssap ;p_wp* If an_htap(tatsl( m ,e &st )vta ) { “ dilavni”< n ma e ? p_wp - p> :eman_w ats t )diu_ts.v << g p_r ->g _r n ema ? g p_r ->g an_r m :e _ts.vtats gid) ’’<< ; If edom_ts.vtats(( & S _I )TMF == S _ FI C RH || ats( t edom_ts.v & S _ FI MT) == S _I BF LK) AM< )1 ol ng_ a++*(tsil rg )v ;

Dept.of CS&E,SJBIT egaP 21

XINU METSYS GNIMMARGORP SC01 26 ;0 nruteR ;0 }

.4 D ebircse eht nepo AP ,I elc a ylr sti ytotorp pe noitaralced itacidni ng sti epytotorp ,noitaralced eht eulav s eht ugra m stne ekat gnola w ti h rieht m .gninae G evi two secnatsni w neh nepo PA I nac f .lia tsiL lla eht ssecca idom f rei f sgal and nialpxe ieht r .sgninaem 60( m )skra eD( c- yaM/60 - 80 )

:snA

I tn epo n tsnoc( c h ra * ap t tni,eman_h ca c dom_sse e t_edom, ;)noissimrep

tap eht si eman_htaP si eht tap h n a em fo eht ti,elif nac be a b etulos ro evitaler an me.

sseccA edom f gal esu ODR_O NLY snepo eht elif rof daer o ln y _O W OR NLY snepo eht elif rof etirw only DR_O WR snepo eht elif rof daer and etirw DNEPPA_O sdneppa atad ot eht dne of eht lif e TAERC_O c aer t se eht elif fi ti ’seod t e x tsi s XE_O CL desu htiw eht TAERC_O no ly. sihT lf ag uac s se nepo ot liaf fi eht deman rla elif rla eady e x stsi . CNURT_O fi eht elif e x stsi ehtsdracsid elif tnetnoc dna s te eht elif is ze ot z ore by set . ON_O NBL CO K seificeps th ta any us sb e tneuq re da or tirw e no t eh lif e dluohs be nikcolbnon g TTCON_O Y seificeps ton ot esu eht deman lanimret ecived f eli sa eht nillac g rp o sec s lanimret lortnoc lanimret .

If eht n dema elif eod s t’ ex stsi dna eht TAERC_O lf ag si on t ficeps ied neht epo n lliw troba htiw a f erulia uter rn nehw.sutats htob TAERC_O & XE_O CL lf a sg ra e ps e eific d eht fi liaf lliw nepo eht nepo lliw liaf fi eht n dema elif e x .stsi

Dept.of CS&E,SJBIT egaP 22

XINU METSYS GNIMMARGORP SC01 26 .5 tsiL eht im tnatrop u ses of f tnc AP .I G evi sti epytotorp .noitpircsed etirW a ++c rgorp am ot kcehc w eh t reh eht esolc – on – cexe f gal si tes f ro a g nevi f .eli If ti is on t ,tes esu f tnc l ot tes siht f .gal slA o hs ow eht im noitatnemelp of pud s m orca gnisu this API. 60( m )skra yaM( - 80 )

:snA

desU ot euq ry ro tes ca c sse lortnoc alf gs and eht esolc no ex ce flag fo any lif e .rotpircsed desu to ssa ign elpitlum elif otpircsed r ot fer e er n ec ht e emas .elif desU in elif cer dna cer o dr ikcol ng.

I tn tni(niam ra g c,c h ra * a rgv ][ )

{

nepO= tni nepO=df (argv[1] ODR_O, NL )Y ;

If(f ,df(ltnc F_ TEG TF )D == 0 )

f(ltncf)dioV( d cse ,F ES_ TF )1,D ;

0 nruter 0 ;

}

itatnemelpmi 2puD itatnemelpmi no

2pud enifed# 2pud ( 1csedf ,fd )2 df(esolc 2 ltncf,) (fd ,cse F_ PUD FD, 2df )

rgorp a etirW.6 a rgorp am ot im lp e tnem sl –l c ommand 01( m )skra ( yaM - 01 )

:snA

.maertsoih

h.dtsinu

Dept.of CS&E,SJBIT egaP 23

XINU METSYS GNIMMARGORP SC01 26

rahc citatS rahc x lbt [10] wr”= x wr xrwx”; AM fednfi# AM J RO enifed# MIN B_RO I ST 8 AM enifed# AM J )ved(RO isnu(( gn ed)de v >> M B_RONI I ST ) enifed# MIN ved(RO ) ved( & MI RON _BI ST )\

lpsid diov citatS diov lpsid ay_ t_elif y ep tni( )edom_ts { edom_ts(hctiwS & S _I )TMF { S esaC S _ FI DI :R uoc t << ’ nruter;’d ; S esaC S _ FI :RHC

lpsid diov citats diov lpsid ay_a ecc s tni(mrep_s )edom_ts { edoma rahC edoma [ 01 ]; F tni(ro (=j;0=i 1 9>i;)8<< ; >j,++i > 1= ) edomA [i] edom_ts(= & )j ? x bt l[i] : ‘ - ;‘ edoma<

nol diov citatS diov nol g ahc(tsil_ r eman_htap* )

Dept.of CS&E,SJBIT egaP 24

XINU METSYS GNIMMARGORP SC01 26 { vtats tats tcurtS tats vtats ; tcurtS g puor * ;p_rg ;p_wp* dwssap tcurtS dwssap ;p_wp* If an_htap(tatsl( m ,e &st )vta ) { “ dilavni”< n ma e ? p_wp - :eman_wp> ats t )diu_ts.v << g p_r ->g _r n ema ? g p_r ->g an_r m :e _ts.vtats gid) ’’<< ; If edom_ts.vtats(( & S _I )TMF == S _ FI C RH || ats( t edom_ts.v & S _ FI MT) == S _I BF LK) AM< )1 ol ng_ a++*(tsil rg )v ; ;0 nruteR ;0 }

Dept.of CS&E,SJBIT egaP 25

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 TINU - 4 NU IX SECO S SE

.1 etirW na yrotanalpxe eton no norivne m tne v .selbaira oslA w etir a ++C/C rgorp am taht stuptuo t eh stnetnoc o f sti norivne m tne .tsil 60( skram )

:snA eD( c- 60 )

ehT tnemnorivne tsil si na ra ray of hc a tcar er ,sretniop htiw hcae p retnio niniatnoc g ht e sserdda fo a llun - nimret a det C nirts g. ehT serdda s fo eht rra ay fo sretniop is deniatnoc ni eht g labol v elbaira ivne r no :

ex nret rahc norivne** ; We' ll llac norivne eht en tnemnoriv retniop , eht array fo sretniop eht rivne o tnemn tsil , dna eht nirts gs ht ey tniop ot t eh tnemnorivne nirts gs. By ,noitnevnoc eht tnemnorivne tsisnoc s fo eman =v eula irts ngs, rgorp ++C/C rgorp am taht o u stupt eht stnetnoc o f sti tnemnorivne .tsil

.eupa" edulcni# .eupa" h" tni a tni(niam a rg ,c c h ra * ra g ][v ) { tni i; rahc rtp** ; ex nret rahc norivne** ;

rof rtp( = ;norivne tp* r =! ;0 +rtp +) */ dna lla e vn nirts gs * / %"(ftnirp s\n", tp* r ;)

ex )0(ti ; }

Dept.of CS&E,SJBIT

egaP 62 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 axe na htiW .2 htiW na axe m elp xe p nial eht esu o f jtes mp a dn jgnol mp fu snoitcn . 80( m skra ) :snA yaM( - 70 ) In ,C ew ac n't g oto a al b le taht 's ni rehtona uf n .noitc I tsn e ,da ew tsum esu eht pmjtes dna nol g pmj snoitcnuf ot mro siht t y ep o f arb n ihc ng. sA we' ll se ,e eseht wt o snoitcnuf are ildnah rof lufesu rof ildnah ng e rorr snoitidnoc taht rucco ni a d pee ly detsen uf n noitc c .lla

h.pmjtes< edulcni# h.pmjtes< > tni fub_pmj(pmjtes ;)vne

rid dellac fi 0 :snruteR 0 fi dellac rid e tc ly, non z ore fi r inrute ng f r mo a llac ot nol g pmj

diov nol g fub_pmj(pmj ,vne tni ;)lav

We llac mjtes p morf eht l noitaco taht ew tnaw ot r nrute ,ot cihw h ni siht e elpmax si in ht e niam .noitcnuf In siht ,esac pmjtes snruter 0 esuaceb ew dellac ti tcerid ly. In eht llac ot ,pmjtes eht ra g tnemu env si fo eht laiceps ty ep j .fub_pm sihT atad type si emos mrof of rra ay taht si bapac le fo nidloh g lla eht amrofni noit deriuqer ot erotser the sutats fo eht kcats ot ht e etats wh ne ew c lla nol g .pmj amroN ll y, ht e vne v baira le si a g labol v elbaira , w ecnis w e' ll deen ot er f re e ecn ti morf htona er tcnuf i .no

W neh ew retnuocne na rorre say, ni eht _dmc a ewnoitcnuf llac gnol pmj htiw wt o arg .stnemu ehT tsrif si eht emas vne taht ew desu ni a llac ot ,pmjtes dna t eh ,dnoces lav , si a non z ore lav ue taht b semoce ht e ruter n eulav morf .pmjtes ehT osaer n rof ht e oces dn arg tnemu si ot wolla su to evah om re naht no e nol g pmj rof ea hc .pmjtes roF ex ,elpma we dluoc nol g pmj morf dda_dmc htiw a lav fo 1 dna osla llac nol g pmj morf nekot_teg htiw a lav fo 2. In ht e niam uf n ,noitc eht r nrute lav ue rf mo pmjtes si rehtie 1 ro ,2 dna we ac n tset siht ,eulav fi ew ,tnaw dna enimreted tehw h re eht nol g pmj saw rf om dda_dmc ro g nekot_te .

Let's nruter ot ht e ex .elpma Ex elpma swohs htob eht niam dna dmc _ dda f .snoitcnu hT( e dna enil_od ,snoitcnuf owt rehto owt ,snoitcnuf enil_od dna g ,nekot_te ah ven t' ahc ng .de )

Dept.of CS&E,SJBIT

egaP 72 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 axE m elp o f tes jmp dna jgnol mp

.eupa" edulcni# .eupa" h" h.pmjtes< edulcni# h.pmjtes< > # enifed KOT _ DDA 5 reffubpmj fub_pmj reffubpmj ; tni )diov(niam { rahc enil [ AM XLINE]; fi effubpmj(pmjtes( r) =! 0 ) rre"(ftnirp o )"r ; elihw ( fg ,enil(ste M XA LI ,EN )nidts =! NULL) ;)enil(enil_od ex )0(ti ; } ... diov diov(dda_dmc ) { tni ;nekot nekot = g nekot_te ( ;) fi nekot( < )0 */ na e rorr sah o ucc r der * / nol g ffubpmj(pmj e ,r ;)1 */ tser fo orp c nisse g for siht dnammoc /* }

W neh niam is ex ,detuce ew llac ,pmjtes hcihw sdrocer vetahw er noitamrofni ti sdeen to ni eht lbairav e ffubpmj re dna r snrute .0 We eht n llac ,enil_od hcihw sllac ,dda_dmc dna emussa taht na e rorr of emos mrof si ceted t .de nol g pmj uac s se eht kcats to eb "un nuow d"

Dept.ofkcab ot CS&E,SJBITeht niam tcnuf i ,no niworht g wa ay eht kcats semarf rof dmc a_ dd dna od nil_ e

egaP 82 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 nillaC g nol g pmj c sesua t eh pmjtes ni niam ot ,nruter tub siht emit ti snruter htiw a ulav e ces eht( 1 fo 1 eht( ces o dn a rg emu nt rof nol g )pmj .

eht ebircseD .3 ebircseD eht XINU lenreK troppus f ro corp e .ss hS ow eht detaler atad .serutcurts 60( m skra ) yaM( - 21 ) :snA U in x ssecorp stsisnoc fo et xt es g ,tnem atad se kcats,tnemg seg atnem nu xi lenrek sah a ssecorp t elba aht t peek s t car k fo lla vitca e rp o sec s emos.se of eht p secor s se oleb ng ot ht e ht.lenrek ey a er c della sy mets eht.sessecorp jam o ir ty fo rp o essec s era sa s etaico w hti eht sresu ohw era eggol d hcae.ni tne ry ni eht ssecorp elbat sniatnoc retniop ot ht e et x kctas,atad,t seg tnem a dn eht u-area fo a rp o ec s eht.s u-ar ae si na ex snet i no fo a orp c se s elbat tne ry dna sniatnoc rehto orp c sse cificeps d at hcus,a sa F c,TD u tnerr root dna ikrow ng otcerid ry dna oni de srebmun dna tes fo sy mets i m desop ssecorp uoser r ec l i stim .

retfA a fo kr sy mets rof htob tnerap dna dlihc ssecorp muser ee ex noituce ta a nruter of krof uf n nehw.noitc a p ssecor si cr etae d by f kro ot noc t snia detacilpbud oc py fo et x kcats,atad,t seg stnem fo sti osla.tnerap ti h sa a FDT sniatnoc er f ere cn se ot eht emas denepo selif sa sti ap r eht.tne secorp s si issa gn de htiw eht setubirtta tihw ch era ni h etire d by sti ap r tne ro tes by ek r len ekil rUI :D eht su er di fo a u s re ohw c aer t de ap r tne rp o ssec . rGI :D eht g puor di fo a resu ohw c detaer ap r tne ssecorp . eUI :D s ema sa rUID ex tcep ehw n eht lif e taht w sa ex detuce ot rc e eta ht e ssecorp h sa ti s tes UID lf ag rut n de .no eGI :D emas sa rGID ex tcep nehw eht elif taht w sa ex detuce ot etaerc ht e ssecorp sah sti tes GID lf ag rut n de no . devaS _tes UID dna vaS ed _tes GI :D eseht a er ht e issa g den eUID dna Egid evitcepser ly orp eht fo eht orp c .sse PGI ,D SID uc, r tner rid e otc ry, toor otcerid ry s, i lang nildnah g is, gn la ecin,ksamu,ksam rtnoc,eulav nillo g t nimre a .l

Dept.of CS&E,SJBIT

egaP 92 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 ehT seutiburtta hctihw reffid are PI P,D PID ,pen nid g is gn murala,sla olc ck emit dna lif e .skcol

.4 B gnir tuo eht im op tr ecna of gnikcol f .seli tahW si eht ard w kcab of yrosivda kcol ? nialpxE ni irb ef. 50( m )skra eD( c- yaM/80 - )90

:snA

UNIX sy smets wolla um l elpit sessecorp ot r dae and etirw eht emas elif oc n tnerruc ly. sihT sedivorp a me sna of r da at irahs ng oma ng p ecor ss tub ti osla redner s fid f luci ty for any ssesorp ni ninimreted g nehw atad ni a elif nac eb neddirrevo by htona er sihT.ssecorp si laicepse ly tnatropmi rof noitacilppa ekil a atad esab .regamam oT emer dy siht ward kcab UNIX stroppus elif kcol ing.

F eli skcol ra e otadnam ry fi ht ey ra e fne orce by an SO ke lenr .If a m dna a ot ry ex evisulc kcol si tes on a elif on ssecorp nac esu eht etirw/ llac ot ssecca tad a no eht kcol de reg .noi If a nam d ota ry s derah lo kc si tes no a fi el on orp c sse c na esu the etirw llac to ca c sse atad no eht col ked r eg .noi

nA osivda ry kcol si ton rofne c de by a ke lenr at eht sy mets c lla evel l siht snaem eve n uoht gh a kcol r etirw/dae may eb s te no elifa ehto r ssecorp nac llits esu eht etirw/daer lac l eht ssecca ot ssecca eht eht.elif rp o erudec rof kcol i s

teS eht kcol fi tiaw,deliaf rof kcol tseuqer g ia en neht.d etirw/daer dna th ne aeler se eht .kcol

sA ea hc p secor s dluohs f wollo siht siht kcol si sa tub.ef ti ah s rd a cabw k is taht ot ollof w decorp eht decorp u er si tluciffid sa eht rp og smar era atbo i den morf fid f tnere uos rce .s

.5 In a ce niatr ti,noitacilppa si deriuqer ot ol ck eht dehctah noitrop of eht f eli as ohs nw ni f .)b(4.gi eb fo er gnikcol eht argorp m m tsu yreuq eht OS ot ees if os me rehto rp o ssec sah kcol ed eht f .eli If ,sey evig eht sliated of eht lo dekc noitrop dna ht e P DI of eht no.ssecorp ce eht kcol si atbo i den rep f ro m a w etir dna u kcoln eht f eli .

Dept.of CS&E,SJBIT

egaP 03 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 W etir a ++c rgorp am ot im lp e tnem siht pa p .noitacil A uss me s elbatiu kcol epyt . 60( m skra ) yaM( - 50 )

.6 tahW ra e eht id ff re e tn w sya ni hcihw a ssecorp nac et r ?etanim Wi ht a taen kcolb hcs em ,cita nialpxe how a ssecorp si dehcnual dna et rm setani elc a ylr nitacidni g ht e o elor o f C - putrats enituor dna eht tixe .sreldnah 50( m )skra (D ce - 60 /May- 80 )

:snA A C rp ogr ma rats ts ex noituce htiw a cnuf t noi dellac niam . hT e pr oto ty ep rof the si noitcnuf niam noitcnuf si

tni tni(niam ,cgra hc ar a* rgv ][ );

erehw ra gc si eht rebmun fo nammoc d- enil arg ,stnemu dna argv si na rra ay fo sretniop ot eht argum .stne W neh a C rp og ar m si ex etuce d by t eh ke lenr by no e fo ht e xe ce ,snoitcnuf a laiceps ts a tr - pu ituor ne si dellac be erof the niam noitcnuf si .dellac T eh ex lbatuce e margorp elif sp seifice ht is enituor sa eht itrats ng a sserdd rof the rp ogr ;ma siht si tes pu b y eht knil rotide nehw ti is dekovni by the C oc m .relip sihT trats -up tuor i en ekat s eulav s morf eht ke lenr eht oc m dnam - enil arg stnemu and eht tnemnorivne na d stes niht gs pu so niam eht taht eht niam noitcnuf si dellac .

eerhT snoitcnuf animret te a rp o marg lamron ly: _ xe ti dna _Ex ti , hcihw nruter ot eht rek n le etaidemmi ly, dna ex ti , hcihw smrofrep c niatre lc e puna issecorp ng dna ht en snruter ot eht lenrek .

erehT era ie g th ways rof a ssecorp ot t e etanimr . N lamro noitanimret rucco s ni evif w ays:

.1 nruteR morf iam n .2 nillaC g exit .3 nillaC g e_ x ti ro E_ x ti .4 nruteR fo eht tsal daerht morf sti trats enituor .5 nillaC g daerhtp _ex ti morf eht tsal aerht d

o noitanimret lamronbA noitanimret o c sruc ni eerht ways: Dept.of CS&E,SJBIT

egaP 13 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 .6 nillaC g troba .7 tpieceR fo a s ig lan .8 esnopseR fo eht tsal rht e da ot a ac n noitallec qer eu ts

A ssecorp nac er g retsi up ot 23 snoitcnuf taht ra e lacitamotua ly dellac by ex .ti esehT era c della ex ti sreldnah dna era reg tsi e der by c nilla g eht eta x ti .noitcnuf eW ssap ht e sserdda of a uf noitcn as eht argum tne ot eta x .ti nehW siht noitcnuf si c lla e ,d ti si ton dessap any ra g stnemu a dn si ton ex detcep ot nruter a .eulav The ex ti noitcnuf sllac eseht snoitcnuf ni er v re se edro r fo rieht reg tartsi i .no hcaE uf n noitc si lac l de sa am ny semit sa it aw s reg tsi e er d. ex ti tsrif sllac ht e ex ti sreldnah dna eht n sesolc ( aiv solcf e) smaerts nepo lla nepo smaerts .

rgaid taen a htiW .7 htiW a taen rgaid am, nialpxe eht m emo yr l a tuoy o f c rgorp am. nI w hcih stnemges tua eht era eht tua oma cit irav a selb dna d y an m aci yll c r detae ejbo c st era s erot d? 40( m skra ) yaM( - D/01 ec- 11 )

:snA C orp gr ma sah b ee n desopmoc fo eht ollof w ni g eip c :se

x eT xt es g ,tnem eht ma hc i en snoitcurtsni taht eht UPC ex .setuce lausU ly, eht et xt Dept.of es CS&E,SJBITg nem t si barahs le so taht no ly a is ng el oc py n sdee ot be ni em mory rof

egaP 23 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 tneuqerf ly ex detuce rp o ,smarg cus h sa et xt rotide s, eht C lipmoc e ,r eht shel ,sl dna os .no ,oslA eht text segm tne si netfo daer -o ln y, ot tneverp a rgorp am orf m nedicca t la ly idom fying sti .snoitcurtsni x I ilaitin z de atad seg nem t, lausu ly dellac pmis ly eht atad es g ,tnem oc n niniat g selbairav taht era sp ice f laci ly ilaitini z de ni eht .margorp F ro ex ,elpma eht C alced r noita tni am xco tnu = ;99 iraeppa ng edistuo any fu noitcn sesuac siht airav b el ot eb derots ni eht ilaitini zed s atad s eg tnem htiw sti ini t lai eulav . x laitininU iz de atad es gme ,tn netfo dellac eht " sb s" es g ,tnem n dema a retf an tneicna relbmessa po e rotar th ta doots rof " kcolb etrats d by sy ".lobm taD a ni siht es gm tne si ilaitini z de by eht ker len ot itemhtira c 0 or n llu sretniop feb o er ht e margorp e strats e x nituce g. T eh C d alce r noita nol g mus [ 0001 ]; iraeppa ng edistuo any noitcnuf c sesua iht s lbairav e ot eb ots er d ni eht ilaitininu z de atad es g em n .t x ,kcatS hw e er citamotua selbairav ra e derots , ola ng htiw noitamrofni aht t si evas d cae h emit a noitcnuf si c .della Ea hc emit a uf n noitc si dellac , eht sserdda fo hw ere ot nruter ot dna rec t nia noitamrofni tuoba eht ac l rel 's ,tnemnorivne cus h as emos fo eht ma enihc er g sretsi , ra e evas d no eht ts a .kc ehT wen ly dellac tcnuf i no neht ts eht no moor setacolla moor no eht ts a kc rof sti citamotua dna t aropme ry v selbaira . x ,paeH where dy ciman omem ry noitacolla usu ally ekat s alp c .e irotsiH c la ly, t eh b sah paeh sah b e ne acol t de eb t neew eht ilaitininu z de atad dna eht kcats .

Dept.of CS&E,SJBIT

egaP 33 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26

ehT omem ry l ay tuo fo a c rp og ar m

.9 tahW era setjmp dna l jgno mp f ?noitcnu pxE l nia w hti a argorp m ot t snar f re a lortnoc eht lortnoc a c ssor f snoitcnu su i gn eht m. 01( m )skra ( yaM - 21 )

:snA

In ,C ew ac n't g oto a al b le taht 's ni rehtona uf n .noitc I tsn e ,da ew tsum esu eht pmjtes dna nol g pmj snoitcnuf to perf mro siht t y ep o f arb n ihc ng. sA we' ll se ,e eseht wt o snoitcnuf are ildnah rof lufesu rof ildnah ng e rorr snoitidnoc taht rucco ni a peed ly detsen uf n noitc c .lla

h.pmjtes< edulcni# h.pmjtes< > tni fub_pmj(pmjtes ;)vne

rid dellac fi 0 :snruteR 0 fi dellac rid e tc ly, non z ore fi r inrute ng f r mo a llac ot nol g pmj

diov nol g fub_pmj(pmj ,vne tni ;)lav

We llac mjtes p morf eht l noitaco taht ew tnaw ot r nrute ,ot hcihw ni siht e elpmax si in ht e niam .noitcnuf In siht ,esac pmjtes snruter 0 esuaceb ew dellac ti tcerid ly. In eht llac ot ,pmjtes ht e ra g tnemu env si fo eht laiceps ty ep j .fub_pm sihT atad type si emos mrof of rra ay taht si bapac le fo nidloh g lla eht noitamrofni deriuqer ot erotser the sutats fo eht Dept.of CS&E,SJBIT

egaP 43 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 kcats ot ht e etats wh ne ew c lla nol g .pmj amroN ll y, ht e vne v baira le si a g labol v lbaira e, w ecnis w e' ll deen ot er f re e ecn ti morf htona er tcnuf i .no

W neh ew retnuocne na rorre say, ni eht _dmc a dd ewnoitcnuf llac pmjgnol htiw wt o arg .stnemu ehT tsrif si eht emas vne taht ew desu ni a llac ot ,pmjtes dna t eh ,dnoces lav , si a non z ore lav ue taht b semoce ht e ruter n eulav morf .pmjtes ehT osaer n rof ht e oces dn arg tnemu si ot wolla su to evah om re naht no e nol g pmj rof ea hc .pmjtes roF ex ,elpma we dluoc nol g pmj morf dda_dmc htiw a lav fo 1 dna osla llac nol g pmj morf nekot_teg htiw a lav fo 2. In ht e am ni uf n ,noitc eht r nrute lav ue rf mo pmjtes si rehtie 1 ro ,2 dna we ac n tset siht ,eulav fi ew ,tnaw dna enimreted tehw h re eht nol g pmj saw rf om dda_dmc ro g nekot_te .

Let's nruter ot ht e ex .elpma Ex elpma swohs htob eht niam dna dmc _ dda f .snoitcnu hT( e rehto owt ,snoitcnuf enil_od dna g ,nekot_te ah ven t' ahc ng .de )

axE m elp o f tes jmp dna jgnol mp

.eupa" edulcni# .eupa" h" h.pmjtes< edulcni# h.pmjtes< > KOT enifed# KOT _ DDA 5 reffubpmj fub_pmj reffubpmj ; tni )diov(niam { rahc enil [ AM XLINE]; fi effubpmj(pmjtes( r) != 0 ) ftnirp rre"( o )"r ; elihw ( fg ,enil(ste M XA LI ,EN )nidts =! NULL) ;)enil(enil_od ex )0(ti ; } Dept.of CS&E,SJBIT

egaP 53 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 ... diov diov(dda_dmc ) { tni ;nekot nekot = g nekot_te ( ;) fi nekot( < )0 */ na e rorr sah o ucc r der * / nol g ffubpmj(pmj e ,r ;)1 */ tser fo orp c nisse g for siht dnammoc /* }

W neh niam is ex ,detuce ew llac ,pmjtes hcihw sdrocer vetahw er noitamrofni ti sdeen to ni eht lbairav e ffubpmj re dna r snrute .0 We eht n llac ,enil_od hcihw sllac ,dda_dmc dna emussa taht na e rorr of emos mrof si ted ce t .de nol g pmj uac s se eht kcats to eb "un nuow d" kcab ot eht niam tcnuf i ,no niworht g wa ay eht kcats semarf rof dmc a_ dd dna nil_od e nillaC g nol g pmj c sesua t eh pmjtes ni niam ot ,nruter tub siht emit ti snruter htiw a ulav e ces eht( 1 fo 1 eht( ces o dn a rg emu nt rof nol gj )pm .

Dept.of CS&E,SJBIT

egaP 63 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 TINU - 5 RP O SSEC C NO ORT L

nialpxE .1 nialpxE t eh f llo owing tsys em sllac :

)i f kro v)ii f kro tixe)iii )vi w tia 01( ma )skr yaM( - 80 )

:snA

;)diov(krof t_dip ;)diov(krof

corp ,dlihc ni 0 :snruteR 0 ni ,dlihc corp e ss ID of dlihc ni ap r ,tne 1 no orre r

ehT wen rp o ssec cre eta d by fo kr si dellac eht dlihc ssecorp . sihT oitcnuf n si dellac cno e tub snruter .eciwt The o ln y fid f ere n ec ni eht r ute r sn si taht eht nruter ulav e ni eht dlihc is ,0 rehw e sa eht r nrute av l eu ni eht ap r tne si eht pr sseco ID of eht new ihc l .d ehT re nosa eht dlihc 's rp oc sse ID si denruter ot eht tnerap si taht a ssecorp nac ah ve erom naht eno ,dlihc dna ereht si on f noitcnu taht swolla a pr sseco ot niatbo eht orp c sse I sD fo sti .nerdlihc ehT nosaer of rk snruter 0 ot eht dlihc is taht a ssecorp nac evah no ly a nis gle rap ,tne dna eht dlihc can wla ays llac g dippte to niatbo eht ssecorp ID fo sti .tnerap ssecorP( ID 0 si r rese ved rof esu by the ke ,lenr so ti 's ton elbissop of r 0 ot eb eht rp o ssec ID fo a ).dlihc

B hto eht dlihc dna eht pa tner eunitnoc ex nituce g htiw eht rtsni noitcu taht f swollo eht llac ot krof . ehT dlihc si a oc py fo eht par .tne For ex ,elpma eht dlihc g te s a oc py of ht e nerap t's ad ta ps a ,ec h ae p, dna kcats . etoN taht ht is si a oc py rof ht e ;dlihc eht nerap t dna eht dlihc od ton erahs eseht snoitrop fo omem ry. ehT tnerap dna eht dlihc erahs eht et xt es g tnem

;)diov(krofv t_dip ;)diov(krofv

corp ,dlihc ni 0 :snruteR 0 ni ,dlihc corp e ss ID of dlihc ni ap r ,tne 1 no orre r

Dept.of CS&E,SJBIT

P ega 37 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 ehT krofv uf n noitc si dednetni ot rc e eta a n we ssecorp nehw the prup o es fo eht wen ssecorp si ot ex ce a wen orp gr ma pets( 2 ta eht dne fo eht suoiverp .)noitces ehT erab - senob llehs ni ht e rp og ar m morf Figure 7.1 si osla na ex elpma fo siht type of rp ogr .ma ehT krofv uf n noitc rc eat se eht wen rp o ,ssec tsuj ekil krof , tuohtiw oc pying eht serdda s ecaps of eht p tnera otni t eh ,dlihc sa ht e dlihc ow n't r fe e ner ce taht sserdda s ;ecap eht dlihc pmis ly sllac ex ce o( r ex ti ) rig th fa t re ht e krofv . ,daetsnI elihw the dlihc is gninnur na d rehtie sllac ti litnu ti sllac rehtie ex ce ro ex ti , eht dlihc snur ni t he sserdda s p eca of eht p a .tner

rehtonA effid r ne ce teb w nee eht owt snoitcnuf si taht krofv guar seetna ht at eht dlihc ur sn ,tsrif litnu eht dlihc llac s ex ce or ex ti . W neh eht dlihc sllac rehtie of eht se uf n ,snoitc ht e tnerap .semuser sihT( ac n dael ot d coldae k fi ht e dlihc ed p sdne no htruf er snoitca of ht e b tnerap b e erof nillac g rehtie fo eseht t wo snoitcnuf .)

eerhT snoitcnuf animret te a rp o marg lamron ly: _ xe ti dna _ Ex ,ti hcihw nruter ot eht rek n le etaidemmi ly, dna ex ,ti hcihw smrofrep c niatre lc e puna issecorp ng dna ht en snruter ot eht lenrek .

>h.bildts< edulcni# >h.bildts< e diov e x tni(ti s ;)sutat E_ diov E_ xi tni(t )sutats ; h.dtsinu< edulcni# h.dtsinu< > e_ diov e_ x tni(ti s ;)sutat

We' ll ssucsid eht tceffe fo eseht eerht uf n snoitc no rehto ,sessecorp cus h sa eht nerdlihc ap eht dna eht ap r tne fo eht et r nitanim g orp c .sse

r ehT r e nosa f or eht id f ef er tn daeh e sr si taht e x ti na d E_ x ti era eps eific d by ISO ,C ehw r sae e_ x ti si deificeps by SOP IX 1. .

lacirotsiH ly, eht ex ti noitcnuf sah wla ays frep o demr a naelc nwodtuhs fo t eh dradnats I/O arbil ry: eht esolcf uf n noitc si dellac rof lla nepo .smaerts sihT sesuac lla effub r de tuptuo Dept.ofatad ot eb CS&E,SJBIT ehsulf d ( ttirw en ot eht )elif .

P ega 38 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 llA eerht ex ti snoitcnuf ex tcep a is ng el tni e reg arg tnemu , hcihw ew llac eht ex ti .sutats tsoM UNIX Sy mets ehs l sl edivorp a way ot e ax enim eht ex ti sutats fo a .ssecorp If a( ) any fo eseht uf n snoitc si dellac tuohtiw na tixe s sutat , )b( niam seod a nruter tuohtiw a nruter ,eulav ro )c( eht m nia noitcnuf si ton alced r de ot nruter na tni ege ,r eht ex ti sutats of eht orp c sse si dnu e .denif vewoH e ,r fi ht e r nrute ty ep fo m nia si na tni e reg a dn niam sllaf" ne eht ffo eht ne d" ( na ticilpmi )nruter , eht e x ti sutats fo eht ssecorp si 0 .

ehT ex ti s sutat saw nu d denife fi eht dne fo eht niam noitcnuf saw caer h de tuohtiw an ex ticilp nruter tnemetats ro llac ot eht e x ti .noitcnuf

:tiaW

W neh a ssecorp ,setanimret rehtie lamron ly ro ab lamron ly, eht rek n le n to i seif eht nerap t by idnes ng eht SI CG H DL is g lan ot eht p a tner .

ot deen ew deen ot be a w era taht a ssecorp taht sllac tiaw ro diptiaw ac n

x B ,kcol fi lla fo sti rdlihc en era llits gninnur x nruteR etaidemmi ly wi ht eht noitanimret ats t su fo a ,dlihc fi a ch dli sah mret detani dna si itiaw ng rof sti noitanimret sutats ot eb ehctef d x nruteR etaidemmi ly tiw h na rre o ,r fi ti seod n't ah ve a ny dlihc orp c esse s

If eht rp o ssec si nillac g tiaw esuaceb ti deviecer eht SI CG HLD is gn ,la ew ex tcep tiaw to etaidemmi nruter etaidemmi ly. B tu if ew c lla ti ta a ny odnar m tniop ni ,emit ti nac .kcolb

;)coltats* tni(tiaw t_dip tni(tiaw ;)coltats*

B hto :nruter rp o ssec ID fi ,KO 0 s( ee etal r ,) ro 1 on orre r

ehT tiaw noitcnuf nac kcolb eht rellac litnu a dlihc ssecorp ,setanimret saerehw w diptia everp taht noitpo na sah na noitpo taht everp n st i t morf nikcolb g.

Dept.of CS&E,SJBIT

P ega 39 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 ehT arg tnemu coltats si a retniop ot na etni ge .r If siht ra g tnemu si ton a llun ,retniop ht e noitanimret sutats fo eht detanimret orp c sse si derots ni eht noitacol detniop ot by ht e arg .tnemu If ew od n't ac er tuoba eht te noitanimr ,sutats ew pmis ly ssap a llun retniop sa ra siht ra g tnemu .

.2 G gnivi eht epytotorp nialpxe d iff tnere tnairav o f cexe tsys em llac . 01( m skra )

:snA eD( c- yaM/50 - 90 )

esU fo eht krof uf n noitc si ot etaerc a wen p or c sse eht( )dlihc taht neht sesuac htona re margorp ot be ex etuce d by gnillac no e fo ht e e ex c .snoitcnuf W neh a rp co sse sllac one fo eht ex ce ,snoitcnuf taht p ssecor is etelpmoc ly per l eca d by ht e en w rp og ar ,m dna ht e en w margorp strats ex gnituce ta sti niam .noitcnuf The orp c sse ID seod ton ch egna a ssorc an ex ce , esuaceb a wen rp o ssec si ton ;detaerc erem ly lper a sec eht uc r tner tissecorp s et x ,t ,atad ,paeh dna ats ck es g htiwstnem a b dnar n we rp ogr ma morf ksid .

e tni e x tsnoc(lce rahc ap* t ,emanh tsnoc hc ar a* rg0, )* rahc( */ ... */ rahc( )* 0 /* ;) e tni e x tsnoc(vce rahc *p ,emanhta hc ar tsnoc* a rgv ][ ); e tni e x tsnoc(elce rahc * ap ,emanht tsnoc hc ar a* rg0, ... */ rahc( * ,0) hc ar tsnoc* pvne ][ /* ) ; e tni e x tsnoc(evce hc ar p* a ,emanht rahc * snoc t argv ][ , rahc tsnoc* pvne ][ ); e tni e x tsnoc(plce rahc if* l ,emane tsnoc ch ra *arg0, ... */ rahc( * )0 /* ;) e tni e x tsnoc(pvce rahc * ,emanelif c h ra tsnoc* argv ][ );

is llA is x :nruter 1 no ,rorre on nruter no us c sec s

ehT tsrif ereffid n ec ni eseht snoitcnuf si taht the tsrif ruof ekat a emanhtap arg ,tnemu rehw e sa eht tsal owt kat e a emanelif arg .tnemu W neh a anelif me arg mu e tn si eificeps d

Dept.of CS&E,SJBIT

P ega 40 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 x If emanelif sniatnoc a a ,hs ti si nekat sa a nhtap a .em x ,esiwrehtO eht ex batuce le elif si craes h de rof ni eht seirotcerid ps e deific by ht e HTAP tnemnorivne irav a .elb

ehT HTAP elbairav noc t snia a tsil of ,seirotcerid dellac htap iferp x ,se taht era apes r deta by snoloc .

ehT en xt ecnereffid oc n snrec eht issap ng fo eht ra gum tne tsil (l s sdnat rof tsil dna v sdnats rof otcev r .) ehT f snoitcnu ex lce , ex plce , dna ex elce eriuqer ea hc of eht dnammoc - enil arg stnemu ot eht new rp og mar ot eb sp fice i de sa pes a etar arg nemu t .s We kram eht dne fo the ra g stnemu wi ht a llun retniop . For the ehto r rht ee uf n snoitc (ex vce , ex pvce , dna ex vce e ,) we h eva to dliub na ra ray of tniop e sr ot eht arg ,stnemu na d eht da d sser of ht si rra ay si eht a rgum tne ot eseht eerht uf n .snoitc

T eh lanif dnammoc - nil e arg tnemu si dewollof by a llun .retniop If siht llun retniop is deificeps by eht tsnoc a tn 0, ew tsum ex ticilp ly c tsa ti ot a ;retniop if ew od n' ,t ti 's deterpretni sa na tni eger argu .tnem If eht is ze of an regetni si id f ef r tne from eht is ze fo a * rahc * , eht lautca ra g mu e stn ot eht ex ce noitcnuf lliw eb orw ng.

ehT lanif id f ef r cne e si eht issap ng fo the orivne n tnem tsil ot eht wen rp ogr .ma ehT t ow snoitcnuf sohw e seman dne ni an e (ex ce le na d ex evce ) wolla su ot p sa s a tniop er ot na rra ay of sretniop ot eht tnemnorivne nirts g .s T eh rehto ruof ,snoitcnuf ho ,revew use eht norivne elbairav ni eht nillac g orp c sse ot oc py eht ex si t ni g emnorivne nt rof eht en w margorp .

noitidnoc ecar si tahW .3 tahW si ecar noitidnoc ? etirW a rgorp am ni ++C/C ot etartsulli a r a ec .noitidnoc 60( m skra ) eD( c- 80 ) :snA For uo r sesoprup , a ar ce noitidnoc cco u sr w neh elpitlum orp c sesse a er trying to od nihtemos g htiw hs a er d atad na d eht if n la ctuo o em dneped s no eht o dr er ni cihw h eht sessecorp .nur The krof f noitcnu si a evil ly b deer ing g dnuor for ra ec dnoc i ,snoit fi any of eht ol gic a retf the fo kr rehtie ex ticilp ly or ticilpmi ly d sdnepe on htehw er eht p nera t or

Dept.ofdlihc CS&E,SJBITsnur tsrif retfa eht krof . In gen ,lare ew c nna ot tciderp hcihw corp sse snur .tsrif evE n

.tpeD fo SI E, TIBJS P ega 41 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 fi ew wenk hcihw ecorp ss dluow nur ,tsrif tahw h sneppa tfa er taht secorp s strats ninnur g eht no sdneped no eht sy mets daol dna eht k e enr l' s ehcs d nilu g a lg .mhtiro

P or gram w hti a ecar co oitidn n

.eupa" edulcni# .eupa" h" mitatarahc diov citats diov mitatarahc e(c rah )* ; tni )diov(niam { t_dip dip ; fi dip(( = f o ))(kr < )0 { _rre sys("fo kr e r or r"); } esle fi dip( == 0) { arahc t emita (" tuptuo morf lihc d\n"); } esle { arahc t emita (" tuptuo morf nerap t\n"); } ex )0(ti ; } iov citats iov d arahc t hc(emita ar rts* ) { rahc rtp* ; tni ;c ,tuodts(fubtes N ULL); */ tes effubnu r de /* rof rtp( = ;rts c( = tp* r )++ != ;0 ) ,c(ctup ;)tuodts } :tuptuO

Dept.of CS&E,SJBIT

P ega 42 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 / .$ / tuo.a tuptuoo morf dlihc tuptu morf nerap t / .$ / tuo.a tuptuoo morf dlihc tuptu morf nerap t / .$ / tuo.a tuptuo morf dlihc tuptuo morf nerap t

.4 oH w XINU gnitarepo tsys em speek orp c sse ?gnitnuocca 60( ma )skr eD( c- 70 ) :snA tsoM UNIX syst sme edivorp na noitpo ot do p ssecor ac nitnuoc g. W neh elbane ,d ht e lenrek setirw na uocca n nit g cer o dr ea hc emit a ssecorp .setanimret Th ese ac gnitnuoc sdrocer a er typi lac ly a llams tnuoma fo anib ry d ata htiw eht eman fo eht ,dnammoc ht e resu eht ,desu emit UPC fo tnuoma fo UPC emit ,desu eht resu ID dna g puor ID, eht itrats ng ,emit na d os no .

A noitcnuf ew evah n't de debircs (ac tc ) bane l se dna selbasid ssecorp occa u nitn g. ehT no ly esu fo siht noitcnuf si morf eht notcca )8( mmoc a dn hcihw( sneppah ot eb eno fo eht ef w seitiralimis noma g .)smroftalp A resurepus ex uce t se notcca htiw a nhtap a em arg tnemu to elbane a itnuocc ng. ehT itnuocca ng re sdroc a er nettirw ot eht eificeps d ,elif hcihw si lausu ly rav/ / /tnuocca a cc t

ehT utcurts re fo the a cc nitnuo g re sdroc si d nife ed ni eht aeh d re h.t dna skool nihtemos g kil e ty ep d fe trohs_u t_pmoc ; */ 3 - tib esab 8 e x ;tnenop 31 - tib noitcarf /* cca tcurts cca t { rahc a lf_c ag; */ lf ag ees( Figu er 62.8 ) * / rahc a ;tats_c */ ret m noitani sutats is( g lan & c ero lf ag no ly) * / Dept.of CS&E,SJBIT

P ega 43 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 */ siraloS( no ly) * / t_diu ;diu_ca */ aer l resu ID * / g t_di ca _g ;di */ r eal g puor ID */ t_ved t_ca ty; */ nillortnoc g lanimret * / t_emit ;emitb_ca */ s t nitra g nelac d ra emit /* t_pmoc ;emitu_ca */ resu UPC emit kcolc( cit k )s /* t_pmoc ;emits_ca */ s ys met UPC emit kcolc( t i )skc /* t_pmoc ;emite_ca */ e despal emit kcolc( )skcit /* t_pmoc ;mem_ca */ reva a eg omem ry su a eg */ t_pmoc ;oi_ca */ by set efsnart r ( der by re da a dn )etirw * / */ " kcolb s" no B DS syst sme /* t_pmoc ;wr_ca */ b l skco daer or nettirw * / */ ton( erp s tne no B DS sy )smets * / rahc a mmoc_c [8]; */ dnammoc :eman [8] rof ,siraloS /* */ [10] rof caM SO ,X [ 61 ] rof Fr ee B ,DS dna * / */ [17] rof L uni x /* ;}

ehT a lf_c ag m rebme er c sdro ce niatr ev stne rud ing the ex noituce of eht .ssecorp Th se e a stneve a re sed c debir ni Figure.

_ca f al g noitpircseD

AF RO K ssecorp si eht r tluse fo f o ,kr tub reven dellac e xec

USA ssecorp desu us p resure p elivir ges

TAPMOCA ssecorp desu tilibitapmoc y dom e

EROCA ssecorp depmud roc e

XA SIG ssecorp w sa dellik by a is g an l

Dept.of CS&E,SJBIT

P ega 44 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 _ca f al g noitpircseD

NPXEA D ex dednap itnuocca ng ne rt y

ehT ad ta r eriuqe d of r ht e ac gnitnuoc re droc , hcus sa UPC semit na d bmun er of hc a car t re s efsnart r ,der is tpek by t eh rek n le ni ht e orp c se s elbat na d ilaitini z de evenehw r a en w ecorp ss si c aer t ,de sa ni t eh dlihc fa t re a .krof Each itnuocca ng r roce d si w nettir nehw ht e ssecorp .setanimret sihT snaem taht eht redro fo eht sdrocer ni eht nitnuocca g lif e dnopserroc s ot eht t noitanimre edro r fo the rp co ,sesse ton ht e dro er ni w hcih ht ey w re e etrats d

o mrofrep oT mrofrep o ur ,tset ew do eht niwollof g:

.1 B oce me resurepus dna e elban itnuocca ng, htiw eht notcca .dnammoc No et aht t nehw siht dnammoc ,setanimret nitnuocca g hs o dlu eb ;no ,erofereht eht tsrif eht ni drocer ni eht ac nitnuoc g elif dluohs eb morf siht c .dnammo .2 Ex ti eht resurepus llehs dna nur eht rp og mar to .tset sihT dluohs pa p dne xis sdrocer ot eht itnuocca ng :elif eno rof eht repus u res ,llehs eno rof eht tset ,tnerap dna eno rof ea hc fo eht ruof tset .nerdlihc A new ssecorp si ton etaerc d by eht ex lce ni eht dnoces lihc d. erehT si no ly a nis g el a nitnuocc g r droce for eht noces d .dlihc .3 B oce me pus e resur dna t nru ac gnitnuoc ffo . ecniS a itnuocc ng si off wh ne siht notcca dnammoc t nimre a ,set ti dluohs ton raeppa ni eht itnuocca ng elif . .4 nuR rehtona rp ogr ma ot tnirp eht detceles f i sdle f r mo eht itnuocca ng elif .

.5 tahW si boj noc t ?lor muS m ira ze ht e boj noc t lor f serutae w hti eht eh lp of a f erugi . 80( m skra )

:snA J bo lortnoc si a ef a erut hcihw swolla su ot trats elpitlum sboj (g uor ps fo orp c sesse ) morf a is ng el te lanimr a dn ot lortnoc hcihw boj s nac ca c sse eht te lanimr dna hcihw boj s

Dept.ofera ot nur CS&E,SJBIT ni eht b ca kgro .dnu J bo lortnoc seriuqer eerht smrof o f :troppus

P ega 45 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 .1 A llehs taht stroppus boj lortnoc .2 ehT lanimret vird er ni eht lenrek tsum troppus oj b lortnoc .3 ehT rek n le tsum troppus niatrec boj - lortnoc is gn sla

A boj si pmis ly a celloc t noi fo ,sessecorp netfo a enilepip fo .sessecorp ehT noitcaretni htiw eht animret l evird r sesira b uace se a ps e laic t lanimre ch ra a etc r af tcef s eht of er g dnuor :boj eht dnepsus key (ty lacip ly ortnoC l- .)Z tnE e nir g siht char etca r uac es s eht animret l revird ot s dne ht e SI TG S PT is g lan to lla rp o ssec es ni eht foreg nuor d rp co sse g .puor The sboj ni any backg dnuor p ssecor spuorg aren't a ff ce .det ehT te lanimr vird er l skoo rof ht r ee hc laiceps hc ara ,sretc cihw h gen are te is gn sla ot eht f ro eg dnuor rp o ssec g puor .

x ehT tpurretni c h ra a retc ( typic la ly D EL ETE ro C o lortn - )C eneg r seta SIGIN .T x ehT tiuq ahc r retca (typ ci la ly lortnoC -ba )hsalskc areneg t se SI QG UI .T x ehT dnepsus c h ra a retc ( typic la ly lortnoC -Z) neg e setar SI .PTSTG

nA rehto boj lortnoc noitidnoc nac esira taht tsum eb deldnah b y eht imret n la .revird ecniS ew c na vah e a rof e uorg nd boj dna eno or erom b ca kg dnuor ,sboj hw i hc of eseht rec sevie eht ahc r sretca taht we e retn ta eht lanimret ? Only eht of er g dnuor boj re seviec et animr l .tupni It si ton na rre or rof a backg dnuor boj ot try ot re da morf eht t re ,lanim tub ht e lanimret revird stceted siht dna sdnes a laiceps sig lan ot eht cab kg dnuor :boj SIG TT IN. sihT is g lan lamron ly ts o sp eht cab kg nuor d ;boj by isu ng eht sh ,lle ew are deifiton fo siht dna nac irb ng eht boj i otn eht dnuorgerof os taht ti nac daer morf eht .lanimret ehT niwollof g artsnomed t se siht :

$ tac > oof.pmet & trats ni cab kg ,dnuor b ut ti ' ll daer f mor dradnats i tupn [1] 861 1 $ ew p sser RUTER N [1] + S deppot ( SI TG T )NI tac > oof.pmet & $ f g 1% b r ni g boj rebmun 1 otni ht e rof eg nuor d tac > oof.pmet eht llehs sllet su hcihw boj si won ni eht rof eg uor nd ,olleh dlrow retne eno nil e Dept.of CS&E,SJBIT

P ega 46 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 D^ ty ep eht dne -of- elif ahc r ca ter $ tac oof.pmet kcehc taht eht o ne enil w sa tup otni eht elif ,olleh dlrow

ehT llehs strats eht tac ssecorp ni eht cab kg nuor d, tub nehw tac seirt ot r dae sti radnats d tupni eht( nillortnoc g ,)lanimret eht lanimret ird v ,re niwonk g taht ti si a b ca kg dnuor boj , sdnes eht SI TG sign la ot eht cab kg dnuor oj b. ehT llehs stceted siht c egnah ni sutats fo sti dlihc dna sllet us t tah eht boj sah neeb ots p .dep We neht evom eht s deppot boj ni ot eht rof eg uor nd htiw eht llehs 's fg .dnammoc oD ing siht uac s se eht llehs ot ecalp eht oj b rof eht otni eht rof eg dnuor p cor e ss g puor tesct( pr ) dna dnes eht eunitnoc s ig lan S( I NOCG T) t o eht ssecorp g .puor ecniS ti si won ni eht rof eg or u dn ssecorp g ,puor eht oj b nac re da morf nillortnoc eht nillortnoc g t e .lanimr

W tah sneppah fi a cab k dnuorg boj stuptuo ot eht nillortnoc g lanimret ? hT is si na itpo no taht ew nac wolla ro .wollasid lamroN ly, ew u es eht ts ty )1( nammoc d ot nahc ge iht s llof ehT .noitpo ehT llof niwo g s h swo woh siht :skrow

$ tac oof.pmet & e x etuce ni cab kg nuor d [1] 171 9 $ ,olleh dlrow eht tuptuo morf eht cab kg dnuor boj eppa a sr tfa er eht tpmorp ew p sser RUTER N [1] + enoD tac oof.pmet & $ ts ty potsot elbasid iliba ty fo b ca kg or u dn sboj ot tuptuo t o nillortnoc g animret l $ tac oof.pmet & t ry ti ag nia ni eht b ca k dnuorg [1] 271 1

Dept.of CS&E,SJBIT

P ega 47 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62

$ ew sserp NRUTER na d dnif eht boj si eppots d [1] + S (deppot SI TG OT )U tac oof.pmet & $ f g 1% r e emus deppots boj ni eht rof eg nuor d tac oof.pmet eht llehs sllet su hcihw boj si won ni eht rof eg uor nd ,olleh dlrow dna ereh si sti tuptuo

W neh ew wollasid cab kg dnuor sboj morf w nitir g ot eht nillortnoc g ter ,lanim tac liw l kcolb nehw ti seirt ot wr eti ot sti dradnats ,tuptuo esuaceb the lanimret dr revi seifitnedi Dept.of CS&E,SJBIT

P ega 48 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 eht etirw sa imoc ng from a cab kg dnuor p ssecor dna sdnes eht boj eht S UOTTGI sig .lan sA htiw eht suoiverp exa ,elpm nehw ew esu eht llehs 's fg dnammoc ot nirb g eht boj tni o rof eht rof eg uor n ,d eht boj c .setelpmo

ehT Figure irammus z se emos fo eht f serutae of boj lortnoc taht we' ev b nee ed s nibirc g. ehT dilos senil uorht gh eht imret lan revird b xo naem taht eht imret n la I O/ dna eht lanimret -g ne e detar signa sl era la ways nnoc e etc d morf eht of er g dnuor pr sseco g puor to eht lautca .lanimret hT e dehsad enil roc r nidnopse g ot eht SI UOTTG si lang snaem taht rehtehw the tuptuo from a rp o ssec ni the b ca kg nuor d orp c sse g uor p raeppa s no eht .noitpo na si lanimret si na .noitpo

.7 htiW a epytotorp noitpircsed of f ,kro pxe l nia eht laiceps f serutae of siht API. etirW a rgorp am ot c er eta a dlihc ssecorp dna tnirp eht PP DI dna PID ni eht lihc d .ssecorp ehT tnerap corp sse m tsu erusne taht eht dlihc seod ton emoceb a Zom ib e .ssecorp ehT tnerap pr sseco m tsu w tia f ro eht dlihc a dn tnirp tixe sutats of eht ihc dl a gnisu a p etairporp macr .so 60( m )skra eD( c- 90 )

:snA nA e x nitsi g secorp s nac c r etae a wen o ne by nillac g eht f kro uf n .noitc

;)diov(krof t_dip ;)diov(krof

corp ,dlihc ni 0 :snruteR 0 ni ,dlihc corp e ss ID of dlihc ni ap r ,tne 1 no orre r

ehT wen rp o ssec cre eta d by fo kr si dellac eht dlihc .ssecorp sihT oitcnuf n si dellac cno e tub snruter .eciwt The o ln y fid f ere n ec ni eht r ute r sn si taht eht ter nru ulav e ni eht dlihc is ,0 rehw e sa eht r nrute av l eu ni eht ap r tne si eht pr sseco ID of eht new ihc l .d ehT re nosa eht dlihc 's orp c sse ID si denruter ot eht tnerap si taht a ssecorp nac ah ve erom naht eno ,dlihc dna ereht si on f noitcnu taht swolla a pr eco ss ot niatbo eht orp c sse I sD fo sti .nerdlihc ehT nosaer of rk snruter 0 ot eht dlihc is taht a ssecorp nac evah no ly a nis gle ,tnerap dna eht dlihc can wla ays llac g dippte to niatbo eht ssecorp ID fo sti .tnerap ssecorP( ID 0 si r rese ved rof esu by the ker ,len so ti 's ton elbissop of r 0 ot eb eht rp o ssec

IDept.ofD fo a CS&E,SJBIT).dlihc

P ega 49 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 diov e_rp x tni(ti sutats ) { fi ( W FI EXIT tats(DE u )s ) (ftnirp "no lamr mret i ,noitan e x ti sutats = d% \n", WEXI ATST T ;))sutats(SU esle fi ( W FI SIGNALE )sutats(D ) lamronba"(ftnirp et r ,noitanim is g lan rebmun = %d% s\n", W SMRET IG(s ,)sutat fedfi# W PMUDEROC W )sutats(PMUDEROC ? " oc( re elif ge etaren d)" : ""); esle# ""); fidne# esle fi ( W FI EPPOTS D )sutats( ) tnirp dlihc"(f ,deppots is g lan rebmun = % d\n", W SPOTS I s(G t ;))suta } tni )diov(niam { t_dip dip ; tni sutats ; fi dip(( = f o ))(kr < )0 { _rre sys("fo kr e r or r"); } esle fi dip( == 0) { */ tsrif dlihc /* fi dip(( = fo ))(kr < 0) _rre sys("fo kr e rror"); esle fi dip( > 0 ) ex ;)0(ti */ tnerap morf dnoces f o kr == if r ts dlihc * / Dept.of CS&E,SJBIT

P ega 50 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 */ * We're eht dnoces ;dlihc ruo tnerap b e moc es tini sa noos * sa ruo r e la ap r tne llac s e x )(ti ni eht tnemetats evoba . * reH e's w here w e d' eunitnoc e x nituce g, k n niwo g taht w hen * w e' er od n ,e tini lliw paer ruo sutats . /* )2(peels ; (ftnirp "s dnoce lihc d dip = ,d% ap r tne dip = %d\n", ,dip g (dippte ) ;) ex )0(ti ; } fi ,dip(diptiaw( & tsts u ,s )0 =! )dip */ tiaw f or f tsri dlihc /* _rre sys("w diptia re r ro "); */ * We're eht ap r tne t( he iro gin la orp c ;)sse ew c eunitno e x nituce g, * niwonk g taht ew ' er ton eht tnerap fo eht s ce o dn .dlihc /* e_rp x )sutats(ti ; ex )0(ti ; }

.8 nialpxE in eirb f, wh ta sneppah nehw cexe is dellac ni a dlihc .ssecorp tsiL eht 6 fid f tnere f ro ms of xe ce AP .sI irW te a orp gram taht cexe s a rgorp am ohce lla ot yalpsid lla eht comma dn enil dna emnorivne tn selbairav w neh siht rgorp am si cxe e de ni eht dlihc orp c sse ecaps . 60( m )skra yaM( - D/90 ec- 01 )

:snA

eno esu fo eht krof noitcnuf si to etaerc a wen rp o ssec eht( )dlihc taht neht sesuac ehtona r margorp ot be ex etuce d by gnillac no e fo ht e e ex c snoitcnuf . W neh a rp co sse sllac one fo eht ex ce ,snoitcnuf taht p ssecor is etelpmoc ly per l eca d by ht e en w rp og ar ,m dna ht e en w margorp strats ex gnituce ta sti niam .noitcnuf The orp c sse ID seod ton ch egna a ssorc an Dept.of CS&E,SJBIT

P ega 51 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 ex ce , eb c esua a en w rp o ssec si ton c aer t ;de exec m ere ly r alpe c se eht ruc r tne orp c sse sti et x ,t ,atad ,paeh dna ats ck es g stnem htiw a b dnar wen rp ogr ma morf ksid .

e tni e x tsnoc(lce rahc ap* t ,emanh tsnoc hc ar a* rg0, )* rahc( */ ... */ rahc( )* 0 /* ;)

e tni e x tsnoc(vce rahc * p ,emanhta hc ar tsnoc* a rgv ][ ); e tni e x noc(elce ts rahc * ap ,emanht tsnoc hc ar a* rg0, ... */ rahc( * ,0) hc ar tsnoc* pvne ][ /* ) ; e tni e x tsnoc(evce hc ar p* a ,emanht rahc * snoc t argv ][ , rahc tsnoc* pvne ][ ); e tni e x tsnoc(plce rahc if* l ,emane tsnoc c h ra *arg0, ... */ rahc( * )0 /* ;) e tni e x (pvce tsnoc rahc * ,emanelif c h ra tsnoc* argv ][ );

is llA is x :nruter 1 no ,rorre on nruter no us c sec s

tini_vne* rahc tini_vne* ][ = { "U nwonknu=RES ", " TAP H pmt/= ", N ULL } ; tni )diov(niam { t_dip dip ; fi dip(( = f o ))(kr < )0 { _rre sys("fo kr e r or r"); } esle fi dip( == 0) { /* iceps fy anhtap m ,e eps cify vne i tnemnor /* fi e( x elce (" s/emoh/ a llaohce/nib/r ", "e laohc l", "myarg1", " YM GRA 2", ( rahc ,0)* )tini_vne < 0 ) _rre sys("ex elce er )"ror ; } fi ,dip(diptiaw( N ULL, )0 < 0 ) Dept.of _rre CS&E,SJBITsys("w tia orre r ;)"

P ega 52 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 fi dip(( = f o ))(kr < )0 { _rre sys("fo kr e r or r"); } esle fi dip( == 0) { /* iceps fy anelif m ,e rehni it tnemnorivne /* fi e( x hce"(plce o lla ", "e llaohc ", " no ly 1 ra g", ( rahc )* 0) < 0 ) e _rr sys("ex plce e orr r"); } ex )0(ti ; } margorp lla ohce ehT ohce lla margorp : tni a tni(niam a rg ,c c h ra * ra g ][v ) { tni i ; rahc rtp** ; ex nret rahc norivne** ; rof i( = ;0 i < ra g ;c i ++ ) */ ohce lla nammoc d- enil a rgs * / "(ftnirp argv[ d% ]: % s\n", ,i a rgv[i] ;) rof rtp( = ;norivne tp* r =! ;0 +rtp +) */ dna lla e vn nirts gs * / %"(ftnirp s\n", tp* r ;) ex )0(ti ; }

.9 htiW a taen kcolb hcs em ,cita nialpxe eht et rm lani nigol ssecorp ni DSB xinU . tahW si a ?noisses nialpxE how od uoy etaerc a s noisse gnisu pa p etairpor llehs comm .sdna 40( m )skra yaM( - D/80 ec- 90 )

:snA

W neh eht sy mets si oob t ,depparts eht lenrek rc eat se ssecorp ID ,1 eht ini t ,ssecorp dna ti si tini taht irb ngs ht e s yst me pu .resuitlum The ni it secorp s re sda the lif e /e t/ct tys dna , of r eve ry lanimret ived ce taht swolla a ol g ,ni seod a krof dewollof by na ex ce fo eht orp gr ma Dept.of CS&E,SJBIT

P ega 53 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62 g te ty. It si g te ty taht c slla nepo rof eht t lanimre d e .eciv ehT t e lanimr si po e den rof r idae ng dna nitirw g. If eht ived ce si a ,medom eht o nep may led ay edisni eht ed v eci revird litnu eht medom si delaid dna eht llac si .derewsna nO ce eht ecived si ,nepo elif srotpircsed 0, ,1 dna 2 ra e tes ot eht ed .eciv ehT n g te ty stuptuo nihtemos g ekil log :ni na d stiaw of r su ot su ruo retne ruo su er .eman

W neh ew ne t re uo r su er ,eman teg ty's boj si c ,etelpmo dna ti eht n sekovni eht login margorp ehT ol g ni rp o marg seod am ny iht ng .s ecniS ti sah ruo resu ,eman ti nac llac g wpte n ma ot f hcte uo r drowssap lif e tne ry. hT en ol g ni sllac g ssapte (3) ot lpsid ay ht e tpmorp :drowssaP dna r dae ruo sap s drow tiw( h iohce ng ,delbasid fo c .)esruo It c slla cry tp )3( ot cne ry tp eht pa drowss taht ew deretne a dn serapmoc eht ne cry detp tluser ot eht dwssap_wp dleif morf o ru wodahs p drowssa elif tne ry. If the log ni metta pt sliaf eb c esua of na dilavni drowssap retfa( a few ,)seirt ol g ni sllac exit htiw na ra g tnemu fo .1 ihT s noitanimret lliw eb on t deci by eht ap r tne ( tini ,) dna ti iw ll od rehtona krof dewollof by na ex ce fo teg ty, s t nitra g t eh udecorp re revo a g nia f ro siht .lanimret

tA siht iop n ,t ruo ol g ni s lleh si ninnur g. I st erap nt ssecorp ID si eht iro gin la tini ssecorp ssecorp( ID ,)1 os nehw ruo ol g ni llehs ,setanimret ini t si no deifit ti( si se tn a SI CG HLD is g ,)lan dna ti nac ts a tr eht elohw orp c erude over niaga rof siht .lanimret Fi el rotpircsed s ,0 ,1 na d 2 rof our log ni sh lle are es t ot the animret l ived c .e Figu er wohs s siht arra n tnemeg .

Dept.of CS&E,SJBIT

P ega 54 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 62

noitcelloc a si noisses A noisses si a noitcelloc fo eno ro om re orp c sse .spuorg

F ro e x ,elpma eht noisses dluoc evah b e ne gen tare ed by llehs sdnammoc fo t eh rof m

orp 1c | 2corp & 3corp | 4corp | p cor 5

.01 tahW si boj noc t or l? tahW ra e eht rht ee forms of troppus f mor the SO deriuqer f ro boj ?lortnoc ( 40 skraM ) eD( c- 11 )

:snA

J bo lortnoc si a rutaef e dedda ot B DS nuora d .0891 sihT erutaef swolla su ot trats pitlum el boj s (g spuor fo essecorp s) morf a nis g el lanimret dna ot lortnoc hcihw sboj nac ca c sse eht lanimret dna hcihw sboj era ot nur in eht cab kg .dnuor J bo lortnoc eriuqer s o smrof eerht smrof o f :troppus

.1 A llehs taht stroppus boj lortnoc .2 ehT lanimret vird er ni eht ek lenr tsum troppus oj b lortnoc .3 ehT rek n le tsum troppus niatrec boj - lortnoc is gn la

Dept.of CS&E,SJBIT

P ega 55 GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 TINU - 6 LANGIS S A ND OMEAD N P COR SESSE

.1 W tah si a langis ? D ssucsi na y evif P XISO ed f eni d ngis a .sl Ex ialp n woh tes pu h langis h a .reldn 01( m )skra yaM( - D/70 ec- 90 ) :snA iS g slan are rt iggr de by e stnev dna a er etsop d no a orp c sse ot iton fy ti aht t ihtemos ng h sa deneppah dna r seriuqe s emo nA.noitca tneve can eb gen are t de morf a rp o ,ssec a resu ro lenrek eht lenrek . langiS an me esu eroc f eli reneg a det ta ed f lua t SIGALRM mrala remit emit ac.stuo n eb eneg r deta by a l (mra )API. oN SIGABRT troba orp c sse e x ce noitu c na eb gen detare by troba )( A PI. eY s SIGF EP elli g la itamehtam c la epo r .noita eY s SIGH PU nillortnoc g lanimret ah n .pug oN SIG LI L ex noituce fo na lagelli enihcem noitcurtsni . eY s is ehT is gn la A PI nac be u s de ot enifed eht p re s ignal nildnah g dohtem . is*( dioV is*( g lan ( tni is g an l ,mun_ diov *( ()reldnah i )tni()))tn ; ehT rof m la argum tne of na API is is gn mun_la dna si is gn la ifitnedi er l eki SIGINT ro SI .MRETG ehT eldnah r ra g tnemu si nouitcnuf retniop fo a resu nifed e is g lan eldnah r .noitcnuf sihT nuf noitc dluohs ekat na regetni lamrof arg tnemu dna d seo ton ruter n any iht ng. ehT ex elpma sehctac S MRETGI is g slan dna ign sero SIGI TN sig slan na d tpecca d luafe t noitca of SI EGESG sig ht.lan e uap se API sdneosus eht illac ng rp co sse litnu ti si detpurretni by a s ig lan a nd eht roc r nidnopse g s ign la reldnah seod nruter . maertsoi. is is */ is g lan ldnah er itcnuf o /*n

Dept.of CS&E,SJBIT egaP 56

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 s_hctac dioV s_hctac ig( tni is g_n mu ) { iS g s(lan ig ,mun_ hctac _ is g ) ac”<

.2 tahW si a ead m ?no iD s ssuc eht cisab gnidoc r u .sel 01( m )skra ( yaM - ceD/60 - 80 )

:snA snomeaD are orp c sesse taht evil rof a nol g .emit hT ey era netfo st detra nehw ht e sy mets si deppartstoob dna etanimret no ly wh ne eht sy mets si tuhs nwod . B uace se ht ey nod 't ah ve a illortnoc ng t ,lanimre ew s ay t h ta ht ey nur ni eht cab kg dnuor .

doc ot selur cisab emoS cisab selur ot doc ing a d nomea p r tneve u n detnaw retni a snoitc orf m ineppah ng.

.1 ehT tsrif niht g ot od si ac ll ksamu ot tes eht elif edom cr noitae ksam ot .0 ehT elif edom noitaerc ksam aht t's detirehni dluoc eb es t ot ed ny ce niatr .snoissimrep If eht nomead orp c sse si g io ng ot cr etae selif , ti may tnaw ot tes ificeps c .snoissimrep F ro ex ,elpma fi ti eps lacific ly rc e seta selif htiw g puor - er da dna g uor p- etirw ,delbane a elif edom cr noitae am sk taht snrut ffo rehtie fo eseht stroffe sti odnu dluow snoissimrep dluow odnu sti stroffe . .2 llaC krof dna h eva ht e p tnera ex ti . sihT seod es v lare iht ng .s F ,tsri if eht nomead saw detrats sa a elpmis llehs ,dnammoc nivah g eht tnerap etanimret ma sek eht

Dept.of CS&E,SJBIT egaP 57

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 llehs kniht taht eht dnammoc si enod . ,dnoceS the dlihc hni e stir eht rp oce ss uorg p ID fo eht par tne tub steg a wen p or c sse I ,D os w er'e gu nara t dee taht eht dlihc is ton a ssecorp puorg ael d .re T sih si a rp e etisiuqer rof eht c lla ot distes taht si enod en xt. .3 llaC distes ot etaerc a new .noisses ehT eerht ets ps detsil ni noitceS 5.9 .rucco ehT ssecorp (a) semoceb a noisses redael fo a new ,noisses )b( semoceb eht secorp s g puor l e da er fo a n we p r sseco g ,puor dna )c( h sa on nillortnoc g nimret la . .4 nahC ge eht cu tnerr row k ni g rid e otc ry ot eht toor otcerid ry. The cu tnerr w gnikro otcerid ry detirehni orf m eht tnerap dluoc eb no a detnuom elif sy mets . ecniS snomead lamron ly ex si t litnu eht sy mets si er b ,detoo fi ht e da nome ts ays on a detnuom elif sy ts ,me ht at elif sy mets c tonna be .detnuomnu evitanretlA ly, mos e snomead im g th ahc nge eht uc r tner ikrow ng id er otc ry to emos ps e cific l ,noitaco rehw e ht ey lliw od lla rieht krow . For ex ,elpma enil retnirp iloops ng ad snome ahc netfo ahc n eg ot rieht ps o lo otcerid ry. .5 edeennU d elif ed s tpirc o sr dluohs eb .desolc T sih stneverp eht d mea on morf nidloh g nepo any ed s rc i srotp taht ti may h eva i detirehn morf sti nerap t hcihw( dluoc eb a llehs ro emos rehto orp c .)sse W e c na u es ruo _nepo max noitcnuf ro ht e g timilrte mnoitcnuf to enimreted eht ih gh tse rotpircsed dna esolc lla ed s srotpirc .eulav taht ot pu ot taht .eulav .6 emoS snomead epo n lif e rotpircsed s ,0 ,1 dna 2 ot llun/ved/ os taht any arbil ry senituor taht try ot r ae d morf dradnats tupni ro etirw ot dradnats tuptuo or dradnats er ror lliw vah e on .tceffe ecniS eht da nome si ton detaicossa htiw a t ,ecived lanimret ,ecived t h ere si erehwon rof tuptuo ot eb lpsid ay ;de on r si ereht any hw re e ot er c evie tupni morf na evitcaretni us .re Ev ne fi eht nomead w sa rats t de f mor an evitcaretni ,noisses eht nomead snur ni eht ,dnuorgkcab dna eht ol g ni noisses ac n etanimret tuohtiw af tcef ing ht e .nomead If hto er u sres log ni no eht s ema t lanimre ,ecived ew dluow n't wa tn tuptuo morf ht e da nome gniwohs pu on eht et ,lanimr dluow sresu eht dna eht sresu dluow n't e x tcep rieht tupni ot eb r ae d by eht d nomea .

Dept.of CS&E,SJBIT egaP 58

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 .3 tahW era ?slangis eM n noit eht diff tnere ruos c se of is g .slan W tah era eht eerht itisopsid o sn eht secorp s sah w neh slangis ?rucco tsiL yna f ruo slangis gnola wi ht eno ro two enil .noitanalpxe eitrW a pr rgo am t o putes sreldnah f ro IS G TNI na d IS G ACA RM .slangis 80( m )skra yaM( - D/01 ec- 11 )

:snA

iS g slan are rt igg der by e stnev dna are detsop no a orp c sse ot iton fy ti aht t nihtemos g sah eppah n de dna iuqer r se emos a nA.noitc neve t nac be g ne e detar morf a ,ssecorp a k eht ro resu ro eht k e lenr . giS lan an me esu eroc f eli reneg a det ta d fe lua t SIGALRM mrala remit emit ac.stuo n eb eneg r deta by a l (mra )API. oN SIGABRT troba orp c sse e x noituce c na eb gen detare by troba )( A PI. eY s SIGF EP elli g la itamehtam c la epo r .noita eY s SIGH PU nillortnoc g mret lani ah n .pug oN SIG LI L ex noituce fo na lagelli enihcem noitcurtsni . eY s

.4 W tah era ead m no ?sessecorp tsilnE ht rie carahc t .scitsire Al os w etir a rgorp am ot snart form a on rm la resu orp c se s otni a ad em no ecorp s .s alpxE ni s yreve s t pe ni eht rgorp am. 60( m )skra yaM( - 80 )

:snA snomeaD are orp c sesse taht evil rof a nol g .emit hT ey era netfo st detra nehw ht e sy mets si deppartstoob dna etanimret no ly wh ne eht sy mets si tuhs nwod . B uace se ht ey nod 't ah ve a illortnoc ng t ,lanimre ew s ay th ta ht ey nur ni eht cab kg dnuor .

PPID PID PGID SID YTT PT GID UID DNAMMOC

0 1 0 0 ? -1 0 tini

1 2 1 1 ? -1 0 [ dtnevek ]

1 3 1 1 ? -1 0 [ dmpak ]

Dept.of CS&E,SJBIT egaP 59

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 0 5 1 1 ? -1 0 [ dpawsk ]

0 6 1 1 ? -1 0 [ hsulfdb ]

0 7 1 1 ? -1 0 [ detadpuk ]

1 9001 9001 9001 ? -1 23 pamtrop

1 8401 8401 8401 ? -1 0 sy ls ogd -m 0

1 5331 5331 5331 ? -1 0 x dteni - elifdip x/nur/rav/ i dip.dten

1 3041 1 1 ? -1 0 [ dsfn ]

1 5041 1 1 ? -1 0 [ dkcol ]

5041 6041 1 1 ? -1 0 [ doicpr ]

1 3581 3581 3581 ? -1 0 dnorc

1 2812 2812 2812 ? -1 0 su/ dspuc/nibs/r

.eupa" edulcni# .eupa" h" < edulcni# < sy ols g. >h h.ltncf< edulcni# h.ltncf< > < edulcni# < sy uoser/s r .ec h> diov inomead z tsnoc(e hc ar * c )dm { tni ,i ,0df ,1df ;2df t_dip dip ; tcurts timilr lr ; tcurts is ga noitc s ;a */ * raelC elif c noitaer .ksam /*

Dept.of CS&E,SJBIT egaP 60

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 )0(ksamu ; */ * teG am x mumi un m reb fo elif d srotpircse . /* fi (timilrteg( R IL MI _T IFON LE, )lr& < 0 ) tiuq_rre (" :s% can't g te elif timil ", ;)dmc */ * Bec emo a noisses l e da re ot esol illortnoc ng T .YT /* fi dip(( = f o ))(kr < 0 ) tiuq_rre (" :s% can't f kro ", ;)dmc esle fi dip( =! 0) */ ap r tne /* ex )0(ti ; ;)(distes */ * erusnE utuf re nepo s now 't olla c eta illortnoc ng sYTT . /* as.as ldnah_ er = SIG_ ;NGI is g pme ty tes (& _as.as m ;)ksa lf_as.as ags = 0 ; fi is( ga (noitc SI PUHG , & ,as UN LL) < )0 tiuq_rre (" :s% can't i g on re SI UHG P"); fi dip(( = f o ))(kr < 0 ) tiuq_rre (" :s% can't f kro ", ;)dmc esle fi dip( =! 0) */ ap r tne /* ex )0(ti ; */ * egnahC eht uc r tner nikrow g id r otce ry ot eht toor os * ew ow n't erp v tne elif sy smets f mor ieb ng u n .detnuom

Dept.of CS&E,SJBIT egaP 61

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 /* fi ridhc( ("/") < )0 tiuq_rre (" :s% can't c egnah rid e otc ry ot / "); */ * esolC la l nepo elif srotpircsed . /* fi am_milr.lr( x == RL MI _INFINIT )Y am_milr.lr x = 4201 ; rof i( = ;0 i < milr.lr _ am x; )++i )i(esolc ; */ * hcattA elif ed s srotpirc ,0 ,1 dna 2 ot .llun/ved/ /* 0df = nepo (" lun/ved/ l ," O DR_ W )R ; 1df = )0(pud ; 2df = )0(pud ; */ * I ilaitin ze eht ol g lif e. /* ,dmc(golnepo L _GO C ,SNO LO MEAD_G O )N ; fi 0df( =! 0 || 1df =! 1 || 2df =! )2 { sy ls og(L GO _ ,RRE " enux detcep elif d pircse t sro d% d% % d", ,0df df ,1 )2df ; ex )1(ti ; } .eupa" edulcni# .eupa" h" < edulcni# < sy ols g. >h h.ltncf< edulcni# h.ltncf< > < edulcni# < sy uoser/s r .ec h>

Dept.of CS&E,SJBIT egaP 62

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 diov inomead z tsnoc(e hc ar * c )dm { tni ,i ,0df ,1df ;2df t_dip dip ; tcurts timilr lr ; tcurts is ga noitc ;as */ * raelC elif c noitaer .ksam /* )0(ksamu ; */ * teG am x mumi un m reb fo elif d srotpircse . /* fi (timilrteg( R IL MI _T IFON LE, )lr& < 0 ) tiuq_rre (" :s% can't g te elif timil ", ;)dmc */ * Bec emo a noisses l e reda ot esol illortnoc ng T .YT /* fi dip(( = f o ))(kr < 0 ) tiuq_rre (" :s% can't f kro ", ;)dmc esle fi dip( =! 0) */ ap r tne /* ex )0(ti ; ;)(distes */ * erusnE utuf re nepo s now 't olla c eta illortnoc ng sYTT . /* ldnah_as.as er = SIG_ ;NGI is g pme ty tes (& _as.as m ;)ksa

Dept.of CS&E,SJBIT egaP 63

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 lf_as.as ags = 0 ; fi is( ga (noitc SI PUHG , & ,as UN LL) < )0 tiuq_rre (" :s% can't i g on re SI UHG P"); fi dip(( = f o ))(kr < 0 ) tiuq_rre (" :s% can't f kro ", ;)dmc esle fi p( di =! 0) */ ap r tne /* ex )0(ti ; */ * egnahC eht uc r tner nikrow g id r otce ry ot eht toor os * ew ow n't erp v tne elif sy smets f mor ieb ng u n .detnuom /* fi ridhc( ("/") < )0 tiuq_rre (" :s% can't c egnah rid e otc ry ot / "); */ * esolC lla nepo elif srotpircsed . /* fi am_milr.lr( x == RL MI _INFINIT )Y am_milr.lr x = 4201 ; rof i( = ;0 i < milr.lr _ am x; )++i )i(esolc ; */ * hcattA elif ed s srotpirc ,0 ,1 dna 2 ot .llun/ved/ /* 0df = nepo (" lun/ved/ l ," DR_O W )R ; 1df = )0(pud ; 2df = )0(pud ; */ * I ilaitin ze eht ol g lif e. /*

Dept.of CS&E,SJBIT egaP 64

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 ,dmc(golnepo L _GO C ,SNO LO MEAD_G O )N ; fi 0df( =! 0 || 1df =! 1 || 2df =! )2 { sy ls og(L GO _ ,RRE " enu x detcep elif d pircse t sro d% d% % d", ,0df ,1df )2df ; ex )1(ti ; } }

Dept.of CS&E,SJBIT egaP 65

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 TINU - 7

PRETNI R ECO SS C INUMMO CA OIT N

.1 W tah era ?sepip W tah era rieht l im ti a ?snoit W etir a c orp gram taht sdnes olleh“ w ”dlro m egasse to eht dlihc ssecorp hguorht eht .epip T eh dlihc no er c gnivie siht m egasse s dluoh sid p yal ti no eht s dradnat tuptuo . 60( m ra sk ) eD( c- 80/50 )

:snA

mrof tsedlo eht era sepiP era eht tsedlo mrof fo U NIX Sy mets I CP a nd era ivorp d de by lla U NIX syst .sme oitatimil owt evah sepiP evah owt oitatimil n .s

.1 lacirotsiH ly, ht ey h eva b nee flah elpud x ,.e.i( ad at swolf ni no ly eno id r tce i .)no emoS sy smets won vorp i ed lluf - elpud x ,sepip tub rof am x mumi ilibatrop ty, ew aht emussa reven dluohs reven emussa aht t siht si eht .esac .2 sepiP nac eb desu no ly b neewte rp o sessec t h ta h a ev a nommoc a n .rotsec lamroN ly, a epip si c r ae t de by a orp c ,sse taht orp c sse sllac krof , dna eht epip si t neewteb desu neewteb t he ap r tne dna eht dlihc .

.eupa" edulcni# .eupa" h" tni )diov(niam { tni n ; tni df [ ]2 ; t_dip dip ; rahc enil [ AM XLIN ]E ; fi )df(epip( < 0 ) _rre sys(" epip orre r ;)" Dept.of fi dip(( CS&E,SJBIT = f o ))(kr < )0 {

egaP 66

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 _rre sys("fo kr e r or r"); } esle fi dip( > )0 { */ tnerap /* df(esolc [0] ;) df(etirw [1], " olleh lrow d\n", )21 ; } esle { c */ h dli * / df(esolc [1] ;) n = r e df(da [0], ,enil AM XLI )EN ; TUODTS(etirw _ IF LEN ,O ,enil )n ; } ex (ti )0 ; }

.2 W hti a taen kcolb ehcs ma ,cit nialpxe oh w F OFI nac eb desu ot i m lp e tnem tneilc - res v re c o noitacinumm m .ledo 40( m )skra ( yaM - 70 )

:snA tneilC - revreS noitacinummoC nisU g a FIFO

If ew h eva a s vre er taht si detcatnoc by mun e suor ,stneilc hcae tneilc ac n w etir sti tseuqer llew a ot a llew - nwonk FI OF taht eht vres er c r .setae "w lle - nwonk " m snae taht t he emanhtap fo F eht F I OF si nwonk ot lla eht stneilc taht deen ot c o tcatn eht res v .re ehT Fi erug swohs siht arra n .tnemeg ecniS eht re era elpitlum sretirw f or t eh F IF ,O eht stseuqer es nt by eht revres eht ot stneilc ot eht revres n dee ot eb ssel naht PI EP _BUF byt se ni is z .e sihT stneverp a ny ivaelretni ng fo eht tneilc .setirw

nisu ni melborp ehT melborp ni nisu g IF F sO rof siht ty ep fo eilc nt- revres noitacinummoc si woh ot dnes kcab seilper kcab morf eht s re rev ot e a hc .tneilc A is n elg F I OF can't eb ,desu sa eht stneilc wonk reven dluow reven wonk nehw ot daer rieht r esnopse v re sus sesnopser rof hto er c l .stnei enO neilc hcae rof si noitulos si rof hcae neilc t ot dnes sti ssecorp ID w i ht eht .tseuqer ehT s vre re neht rc e seta euqinu a euqinu F FI O rof e hca c ,tneil nisu g a anhtap me b desa no eht neilc t's rp oce ss I .D F ro ex ,elpma eht revres nac c etaer a F FI O htiw eht n a em ,XXXXX.1vres/pmt/ erehw si XXXXX si r decalpe htiw eht tneilc 's p ssecor ID. Dept.of CS&E,SJBIT

egaP 67

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 arra sihT arra n tnemeg ,skrow uohtla gh ti si elbissopmi rof t eh res v re ot llet ehw t reh a tneilc sihT .sehsarc sihT sesuac eht tneilc - cificeps FI sOF ot eb tfel ni eht elif sy .mets ehT vres er osla hctac tsum hctac SIGPI ,EP is n ec ti 's elbissop f or a eilc nt ot dnes a tseuqer dna ter etanim ofeb re idaer ng eht r ,esnopse l ae niv g eht c tneil -sp cifice FI OF htiw eno retirw t( he evres r) dna on daer e .r

W hti eht arra ng tneme s h nwo ni if gur ,e fi eht s erv re snepo sti llew - nwonk FI OF r e da - no ly no ti ecnis( ti no ly r sdae f mor )ti hcae emit eht rebmun fo stneilc go se morf 1 ot ,0 eht revres na daer lliw daer na dne of elif on eht F I .OF oT p r tneve t eh vres er morf h a niv g ot eldnah siht a ,esac a nommoc kcirt si tsuj ot evah eht vres er po en sti llew - nwonk F I f OF or aer d .etirw

stneilC gnidnes stseuqer ot a vres er gnisu a FIFO

vrestneilC er c omm inu c noita gnisu FIF sO

Dept.of CS&E,SJBIT

egaP 68

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 .3 tahW era eht ht r ee d fi f tnere w sya ni w hcih t eh tneilc dna revres rp o sessec a re ca teg nac teg ca c sse ot s a em IPC s utcurt r ?se tsiL eht AP sI w hti rieht gra ume tn sliated t tah era desu ot c aer t ,e lortnoc , dnes dna iecer ve m segasse from a sem s ega .eueuq 70( m ra sk ) eD( c- 80 )

:snA

erehT era v suoira w ays f ro a tneilc dna a res v re t o edner z suov ta eht emas CPI .erutcurts

.1 ehT vres er c na c r etae a n we I CP erutcurts by ps ce ifying a key fo I P_CP RI ETAV eht erots dna erots eht r denrute di e reifitn ehwemos re hcus( sa a )elif rof eht tneilc ot .niatbo k ehT k ey I P_CP RIV ETA gua tnar e se taht eht res ver aerc t se a n ew I CP rts u .erutc tnavdasid ehT tnavdasid a eg ot siht euqinhcet si taht elif sy mets snoitarepo a re r riuqe ed rof ot revres eht revres ot etirw eht ni t rege ifitnedi er ot a ,elif a dn neht rof eht ilc stne ot eveirter retal reifitnedi siht reifitnedi retal .

ehT I P_CP RI ETAV key si osla desu ni a nerap tch dli .pihsnoitaler ehT rap e tn aerc t se a n ew I CP rts u erutc iceps fying I P_CP RIV ETA , dna eht r nitluse g i d reifitne c eht ot elbaliava neht si neht elbaliava ot eht c h dli retfa eht fo kr . ehT hc i dl nac ssap eht ifitnedi er ot a rp wen rp ogr ma sa na argu tnem ot eno fo eht ex ce f .snoitcnu

.2 ehT tneilc dna eht s vre er nac agr ee no a k ey by d fe nini g eht k ey ni a nommoc ,redaeh rof e x .elpma hT e revres neht cr setae a en w I CP utcurts re ceps ifying siht key. T he elborp m htiw t h si hcaorppa si taht ti 's p o elbiss rof eht k ey ot la re da y eb na htiw detaicossa htiw na I CP ,erutcurts ni hcihw esac t he teg noitcnuf ( msgg te , s tegme , ro mhs get) snruter na e rr .ro ehT res v re tsum nah d el siht ,rorre ed l nite g eht ex nitsi g I CP ,erutcurts and try ot c aer te ti ag nia . .3 ehT tneilc dna eht s vre er nac agr ee no a emanhtap dna tcejorp ID eht( orp ej tc ID c a si a ahc r retca v eula teb w nee 0 dna 52 5) dna c lla eht noitcnuf kotf ot vnoc e tr eseht k a otni seulav owt seulav otni a k ey. T h si k ey si neht desu ni ets p .2 ehT no ly se ecivr p or v dedi by kotf si a way fo eneg r nita g a key morf a nhtap a em dna tcejorp ID.

Dept.of CS&E,SJBIT

egaP 69

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 ot teggsm noitcnuf ehT noitcnuf teggsm ot e rehti nepo na e x nitsi g q u eue ro cre eta a n we euq u .e

sm tni sm g k(teg ey t_ k ey, ni t )galf ;

eueuq egassem :snruteR egassem eueuq ID fi ,KO 1 no e orr r

W reveneh na I CP s tcurt u er si ieb ng c r detae (by c a nill g gsm g te , s tegme , ro mhs g te ,) a k ey ehT .deificeps eb tsum eb .deificeps ehT d ata type fo siht k ey si ht e evitimirp syst me atad ty ep key t_ , denifed netfo si hcihw si netfo denifed as a nol g tni e reg ni eht h ae red h.sep . sihT ek y si a otni detrevnoc otni a n fitnedi i re by eht k e lenr .

lf ehT lf ag ra g tnemu na ni t rege f al g. ehT snoitpo of r alf g nac I P_CP RI TAV E ,I ,TAERC_CP I XE_CP CL, I ON_CP AW IT

ehT ltcgsm noitcnuf rep f smro suoirav epo r snoita no a eueuq .

sm tni sm g tni(ltc ,diqsm tni ,dmc tcurts sd_diqsm fub* ;)

nruteR :s 0 fi ,KO 1 no e r or r

a dmc ehT dmc a rgum tne iceps f sei eht dnammoc ot eb p e demrofr no eht q u eue ps e deific by .diqsm

I ATS_CP T F hcte eht sd_diqsm urts c erut rof siht ,eueuq irots ng ti ni eht ot detniop erutcurts detniop ot by b .fu

I TES_CP

I R_CP MID evomeR eht ssem age q eu ue morf eht sy mets dna na y ad ta llits no omer sihT .eueuq eht .eueuq sihT omer v la si etaidemmi

sm tni sm g tni(dns ,diqsm tsnoc diov ,rtp* is z t_e nby ,set tni lf ag);

Dept.of CS&E,SJBIT

egaP 70

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 I ATS_CP T F hcte eht sd_diqsm urts c erut rof siht ,eueuq irots ng ti ni eht ot detniop erutcurts detniop ot by b .fu

e no 1 ,KO fi 0 :snruteR 0 fi ,KO 1 no e r or r

ssem hcaE ssem a eg si desopmoc fo a evitisop ol ng tni eger type ,dleif a non -ne evitag el ng ht (nby et s ,) dna ht e lautca d ata byt se c( o idnopserr ng ot eht nel g .)ht M sse ag se era la ways eht ta decalp ta eht dne fo eht q eueu .

ehT rtp arg tnemu stniop to a nol g tni e reg taht noc t snia eht evitisop etni ger egassem ty ,ep etaidemmi si ti dna ti si etaidemmi ly dewollof by eht ssem a eg ad t .a ehT( re si on ssem age d ata fi nbyt se ).0 si ).0 If eht al r tseg ssem age ew dnes si 215 by ,set ew nac d enife eht niwollof g tcurts u er :

tcurts my em sg { nol g m typ ;e */ evitisop egassem type * / rahc etm xt[ 15 2]; */ egassem ,atad of el ng ht bn y set */ ;}

ss iz t_e sm g tni(vcr ,diqsm diov ,rtp* is z t_e n by et s nol , nol g ty ,ep tni lf ag);

is :snruteR is ze fo atad noitrop fo ssem age fi ,KO 1 no orre r

sm htiw sA htiw sm g ,dns eht rtp arg tnemu stniop ot a ol ng etni ger dewollof by a ad ta ffub er rof ssem lautca eht lautca ssem a eg .atad nby set s pe seific eht is ze fo eht atad ub f .ref T he ty ep a rg tnemu iceps su stel su iceps fy hcihw em s egas ew tnaw .

type == 0 ehT tsrif ssem age no t eh eueuq si ruter n de .

ty ep > 0 ehT tsrif ssem age no t he eueuq esohw m sse age ty ep slauqe ty ep si ter u enr d.

ty ep < 0 ehT tsrif sem sage no t he eueuq esohw m sse age ty ep si eht tsewol eulav el ss

Dept.of CS&E,SJBIT

egaP 71

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 type == 0 ehT tsrif ssem age no t eh eueuq si ruter n de .

osba eht ot lauqe ro naht ro lauqe ot eht osba l etu eulav fo ty ep si r ute r .den

.4 W tah era s em ?serohpa tahW si rieht ?esoprup tsiL dna alpxe in eht sIPA aerc ot desu ot aerc te dna lortnoc eht s em .serohpa ( 30 ma )skr aM( y- )01/70

:snA A erohpames si a c retnuo desu ot edivorp ca ssec ot a ahs r de atad bo ej tc rof elpitlum sessecorp .

llac ot noitcnuf tsrif ehT tsrif noitcnuf ot llac si mes g te ot niatbo a es m erohpa I .D

< edulcni# < sy h.mes/s > mes tni mes g (te key t_ k ey, tni ,smesn tni alf g);

rohpames :snruteR rohpames e ID i f ,KO 1 no rre ro

ctac eht si noitcnuf ltcmes ehT ltcmes noitcnuf si eht ctac h lla rof v a suoir s e erohpam po e .snoitar

< edulcni# < sy h.mes/s > tni ,dimes tni(ltcmes tni tni(ltcmes ,dimes tni s ,munme tni ,dmc ... */ noinu numes a rg )/* ;

iwollof ees( :snruteR ees( iwollof ng)

id eht era tahW .5 tahW era eht id ff tnere tsys em sllac elbaliava ot c r ae te dna m alupina et sem ?serohpa nialpxE . 01( m )skra (D ce -0 yaM/8 - /01 eD c- 11 )

:snA

c ot noitcnuf ehT noitcnuf ot c r etae si mes g ,te ot niatbo a s me a erohp ID.

Dept.of CS&E,SJBIT

egaP 72

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 < edulcni# < sy h.mes/s > mes tni mes g (te key t_ k ey, tni ,smesn tni alf g);

ohpames :snruteR ohpames er ID i f ,KO 1 no rre ro

W reveneh na I CP curts t eru si ieb ng c r detae (by c nilla g teggsm , es mg te , o r mhs g te ,) a key tsum eb s p .deifice T eh atad ty ep fo siht k ey i s eht evitimirp sy mets ad ta type key t_ ., k sihT k ey si noc v detre ni to na reifitnedi by eht ker len .

W neh a wen tes si c r tae e ,d eht niwollof g bmem re s fo eht sd_dimes erutcurts a re laitini iz .de

x ehT mrep_cpi rts u erutc is laitini iz de ehT edom rebmem fo siht utcurts re si tes ot roc eht roc r nidnopse g p noissimre stib fo alf g. x emito_mes si tes ot 0 . x emitc_mes si tes ot eht tnerruc emit . x smesn_mes si tes ot .smesn

fo rebmun ehT rebmun fo s ohpame r se ni eht tes si .smesn If a wen tes si ieb ng c r detae (ty ip c la ly ni evres eht evres r ,) ew tsum ps ce ify .smesn If ew era er fer icne ng na e x nitsi g tes a( ,)tneilc ew c na iceps fy smesn sa 0 .

T eh ltcmes noitcnuf si eht ctac h lla rof v a suoir s e erohpam po e .snoitar

< edulcni# < sy h.mes/s > tni ,dimes tni(ltcmes tni tni(ltcmes ,dimes tni s ,munme tni ,dmc ... */ noinu numes a rg )/* ;

htruof ehT htruof ra g tnemu si ,lanoitpo nidneped g no t eh dnammoc seuqer t ,de na d fi eserp ,tn si fo ty ep s ,nume a noinu o f suoirav dnammoc - ps e ic f ci a rg stnemu :

Dept.of CS&E,SJBIT

egaP 73

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 noinu numes { tni ;lav */ rof VTES AL /* tcurts sd_dimes ;fub* */ rof I TATS_CP dna TES_CPI * / isnu g den trohs * ra ray; */ rof TEG ALL dna S ETA LL * / };

a lanoitpo eht taht etoN taht eht lanoitpo a r tnemug si eht lautca ,noinu ton a retniop ot eht .noinu

a dmc ehT dmc a rgum tne iceps f sei eno fo eht iwollof ng t ne sdnammoc ot eb p e fr o demr no eht deificeps tes deificeps by .dimes T eh evif sdnammoc taht er ref ot eno p ralucitra s me a erohp eulav su e munmes ot iceps fy o en rebmem fo t he .tes T he eulav fo s munme si neewteb 0 dna smesn - ,1 .evisulcni

I ATS_CP T F hcte eht s sd_dime erutcurts rof siht ,tes irots ng ti ni eht erutcurts detniop to by ra g fub. .

I TES_CP teS eht ,diu.mrep_mes s e .mrep_m g ,di dna s _me pe edom.mr sdleif morf eht ot detniop erutcurts detniop ot by a rg fub. ni eht s sd_dime erutcurts cossa i deta htiw siht nac dnammoc sihT .tes sihT dnammoc nac be e x detuce no ly by a rp o ssec esohw fe f evitce su re ID slauqe _mes p uc.mre id ro diu.mrep_mes ro by a ssecorp htiw resurepus elivirp g se .

I R_CP MID evomeR eht ohpames re s te morf eht sy .mets sihT lavomer si .etaidemmi Any hto er orp c sse llits nisu g eht hpames o er lliw teg na e r ror fo EI MRD no en sti en xt detpmetta noitarepo no eht .erohpames hT is dnammoc nac eb ex detuce no ly by a orp ec ss sohw e fe f evitce su er DI slauqe p_mes e diuc.mr ro diu.mrep_mes ro diu.mrep_mes ro by a ssecorp htiw urepus s re p r elivi g se .

VTEG AL nruteR eht eulav fo s lavme rof eht bmem er nmes u .m

VTES AL teS eht eulav fo lavmes f ro eht rebmem .munmes ehT eulav si ceps i deif by arg lav. .

TEG PID nruteR eht eulav fo s dipme rof eht rebmem s .munme Dept.of CS&E,SJBIT

egaP 74

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 I ATS_CP T F hcte eht s sd_dime erutcurts rof siht ,tes irots ng ti ni eht erutcurts detniop to by ra g fub. .

NCNTEG T nruteR eht eulav fo s tncnme rof eht bmem er mes n .mu

TEG ZC TN nruteR eht eulav fo s me z tnc rof eht bmem er mes n .mu

TEG A LL F hcte lla eht ohpames re seulav ni eht .tes esehT v seula a re derots ni eht rra ay detniop ot by arg. ra ray.

TES ALL teS lla eht erohpames v seula ni eht tes ot eht ulav es detniop ot by a rg. ra ray.

F ro lla eht TEG ammoc n sd rehto naht TEG ALL, t eh noitcnuf snruter t he c o idnopserr ng .eulav For eht er m ninia g ,sdnammoc eht nruter v eula si .0

ta pomes noitcnuf ehT noitcnuf pomes ta o lacim ly p e smrofr na ra ar y fo o p snoitare no a s erohpame tes .

< edulcni# < sy h.mes/s > rts ,dimes tni(pomes tni tni(pomes ,dimes rts u tc fubmes apomes rray ,][ is z t_e )spon ;

e no 1 ,KO fi 0 :snruteR 0 fi ,KO 1 no e r or r

apomes ehT apomes rray ra g emu nt si a retniop ot na ra ray fo ames erohp epo r ,snoita erper s detne by fubmes rts u serutc :

tcurts fubmes { isnu g den trohs n_mes u ;m */ rebmem # ni tes ,0( ,1 ,... smesn - )1 /* trohs ;po_mes */ noitarepo n( e ,evitag ,0 ro )evitisop /* trohs lf_mes g; /* I ON_CP AW I ,T MES _ ODNU * / ;}

Dept.of CS&E,SJBIT

egaP 75

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 a spon ehT spon a rg tnemu ps eci seif eht rebmun fo o p are t snoi )stnemele( ni eht a arr y.

epo ehT epo r noita no hcae m rebme fo eht s te si iceps f dei by eht roc r nidnopse g po_mes .eulav nac eulav sihT eulav nac be n eg ita v ,e ,0 ro .evitisop (In eht f niwollo g noissucsid , ew r refe ot eht " dnu o" lf ag f or a es m pa h .ero sihT lf ag c o nopserr ds ot eht ODNU_MES tib ni eht idnopserroc ng mes _ lf g m .rebme )

.1 ehT tseisae c esa si nehw po_mes si .evitisop sihT esac c o sdnopserr ot eht inruter ng fo r ruose c se by eht .ssecorp T he eulav of mes po_ si dedda ot eht rohpames e's v .eula If eht odnu galf si ,deificeps s e po_m si osla detcartbus f mor rohpames eht rohpames e's tnemtsujda eulav rof siht orp c .sse .2 If po_mes si n eg ,evita we tnaw ot niatbo uoser rces taht eht erohpames .slortnoc

If eht hpames ore's eulav is gr retae t h na ro qe u la ot eht etulosba eulav fo s po_me uoser eht( uoser r sec a er aliava b ,)el eht etulosba lav ue fo po_mes si detcartbus rf om eht rohpames e's v .eula sihT gua tnar e se taht eht luser t ni g eulav rof eht es m pa h ero si gr tae er naht ro qe u la ot .0 If eht odnu lf ag si ps e ,deific eht etulosba lav ue of ohpames eht ot dedda osla si po_mes si osla dedda ot eht ohpames er 's mtsujda e tn eulav rof siht orp c .sse

If eht hpames ore's eulav is ssel naht eht etulosba v eula fo po_mes eht( ser o secru a ton era ton a v ,)elbalia eht niwollof g snoitidnoc ppa ly.

.a If I ON_CP AW IT si eps c ,deifi pomes snruter tiw h na rre or fo E AGAIN. .b If I ON_CP AW IT si ton ,deificeps eht s tncnme av l eu rof siht ohpames re si detnemercni ecnis( eht ca rell si tuoba ot go ot els e ,)p dna eht c nilla g tnu dednepsus si ssecorp si dednepsus tnu il eno fo eht iwollof ng o c sruc . .i ehT ohpames er 's eulav b semoce gr retae t h na ro e lauq ot eht o_mes fo eulav etulosba eulav fo o_mes p ,.e.i( emos rehto rp o ssec sah ler e desa ruoser emos ruoser c .)se T he av l eu fo tncnmes f or siht erohpames si erced m detne nis( ce eht c nilla g orp c sse si enod w a niti g ,) dna t eh o_mes fo eulav etulosba eulav fo o_mes p si detcartbus morf eht es rohpam e's .eulav

Dept.of CS&E,SJBIT

egaP 76

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 If eht odnu lf ag si ps e fic i ,de eht etulosba eulav of po_mes si osla hpames eht ot dedda ot eht hpames ore's tnemtsujda eulav rof iht s ssecorp . .ii ehT ohpames re si omer v de morf eht sy .mets In t h si ,esac ht e na snruter noitcnuf snruter na rre or fo EI MRD . iii . A is g lan si caug th by t he ,ssecorp dna t he is gn la reldnah r .snrute In eulav eht ,esac siht ,esac eht eulav of s e tncnm rof siht rohpames e si nemerced t de eht ecnis( eht c nilla g rp o sec s si on nol g re w nitia g ,) and eht noitcnuf na snruter na e orr r of EINT .R .3 If po_mes si ,0 siht snaem taht eht nillac g p ssecor stnaw ot tiaw litnu eht rohpames e's v eula oceb m se .0

If eht hpames ore's eulav is tnerruc ly ,0 eht uf n noitc snruter etaidemmi ly.

If eht hpames ore's eulav is non z ,ore eht niwollof g snoitidnoc pa ply.

.a If I ON_CP AW IT si eps c ,deifi nruter si edam htiw na rre or fo E AGAIN. .b If I ON_CP AW IT si ton ,deificeps eht s me z tnc eulav rof siht ohpames re si detnemercni ecnis( eht ca rell si tuoba ot go ot els e ,)p dna eht c nilla g tnu dednepsus si ssecorp si dednepsus tnu il eno fo eht f iwollo ng o c sruc . .i ehT ohpames er 's eulav b semoce .0 ehT v eula fo s me z tnc rof siht d si erohpames si d e erc m tne ed ecnis( eht c nilla g rp oce ss si enod nitiaw g). .ii ehT ohpames re si omer v de morf eht sy .mets In t h si ,esac eht na snruter noitcnuf snruter na rre or fo EI MRD . iii . A is g lan i s caug th by t he ,ssecorp dna t he is gn la reldnah r .snrute In eulav eht ,esac siht ,esac eht eulav of s emz tnc rof siht rohpames e si nemerced t de eht ecnis( eht c nilla g rp o sec s si on nol g re w nitia g ,) and eht noitcnuf na snruter na e rorr of EINT .R

po noitcnuf pomes ehT pomes noitcnuf po re seta lacimota ly; ti seod rehtie lla eht epo r snoita ni eht ra ray ro meht fo enon fo meht . Dept.of CS&E,SJBIT

egaP 77

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 TINU - 8

WTEN ORK PI :C S O TEKC S

.1 tahW si a ?tekcos ssucsiD oh w ti aerc te dna yortsed a ?tekcos yaM( -1 )0

:snA

tsba na si tekcos A tekcos si na tsba r itca on fo a noitacinummoc e n .tniopd Ju ts sa ht ey uow ld esu elif a ot srotpircsed ot a c ssec a ,elif snoitacilppa esu cos k te otpircsed sr ot a c ssec os c .stek tekcoS a srotpircsed a re emelpmi n det sa elif sed c srotpir ni eht U NIX Sy .mets Ind ee d, am ny o f eht htiw laed taht snoitcnuf taht laed htiw f eli ,srotpircsed hcus sa re da dna etirw , lliw krow htiw a tekcos rotpircsed .

rc oT rc e eta a cos k ,te ew ca ll eht kcos te noitcnuf .

< edulcni# < sy h.tekcos/s > tni(tekcos tni tni(tekcos niamod , ni t ty ep , tni locotorp );

)tekcos( elif :snruteR elif )tekcos( des rotpirc fi ,KO 1 no orre r

ehT niamod arg tnemu ed senimret eht erutan of ht e ,noitacinummoc nidulcni g eht sserdda snoc ehT tamrof ehT snoc t stna trats tiw h AF_ f( or dda r sse imaf ly) bec esua e hca d o niam sah sti rof tamrof nwo tamrof rof per r nese t ni g na sserdda .

Dom nia noitpircseD

AF_IN TE I 4vP I tn e tenr iamod n

AF_INET6 I 6vP I tn e tenr iamod n

AF U_ NIX UNIX iamod n

AF CEPSNU_ eificepsnu d

Dept.of CS&E,SJBIT

egaP 78

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 ehT type a rgum tne eted r senim eht ty ep of eht os c ,tek hcihw htruf er ted e senimr eht ahc noitacinummoc ahc r etca r .scitsi

epyT noitpircseD

MARGD_KCOS if x de - nel g ,ht noc n ,sselnoitce elbailernu ssem a eg s

WAR_KCOS tad ag mar etni r af ce ot IP ( lanoitpo ni SOP I 1.X )

TEKCAPQES_KCOS if x de - nel g ,ht euqes n ,dec ,elbailer noc n noitce - iro e detn ssem ages

AERTS_KCOS M ,decneuqes ,elbailer idib r ,lanoitce nnoc e noitc - iro e detn by et smaerts

ehT locotorp argum tne si lausu ly z ,ore ot les e tc eht tluafed torp o loc rof eht g nevi niamod tekcos dna tekcos ty .ep W neh m elpitlu slocotorp a er pus p detro rof eht s ema amod in dna tekcos ty ,ep we c na esu eht orp t loco arg tnemu ot les e tc a ralucitrap torp o .loc ehT tluafed a rof locotorp rof a S_KCOS T MAER tekcos ni eht AF_IN TE noitacinummoc d o niam si PCT ed ehT .)locotorP lortnoC noissimsnarT( lortnoC .)locotorP ehT ed f tlua orp t co lo rof a RGD_KCOS AM tekcos ni eht AF_IN TE inummoc c noita niamod si PDU resU( taD a marg )locotorP .

We nac elbasid I O/ no a tekcos htiw eht nwodtuhs .noitcnuf

< edulcni# < sy h.tekcos/s > ;)woh tni ,dfkcos tni( nwodtuhs tni nwodtuhs tni( ,dfkcos tni ;)woh

e no 1 ,KO fi 0 :snruteR 0 fi ,KO 1 no e r or r

If woh si ,DR_TUHS ht en idaer ng morf eht s o ekc t si .delbasid If woh si _TUHS W ,R neht ac ew ac n't u se eht tekcos f or nittimsnart g .atad We c na esu DR_TUHS WR ot elbasid htob r dna noissimsnart atad noissimsnart dna r ce .noitpe

Dept.of CS&E,SJBIT

egaP 79

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 .2 ssucsiD eht fid f tnere fu snoitcn elbaliava f ro snart m gnitti dna niviecer g atad .tekcos a revo a .tekcos 01( m skra ) yaM( - D/01 ec- 11 )

:snA

t rof noitcnuf ehT noitcnuf rof t r nittimsna g a er

iss z t_e tni(dnes ,dfkcos tsnoc diov ,fub* is z _e t nby ,set tni lf ag )s ;

fo rebmun :snruteR rebmun fo tnes fi ,KO 1 no e r or r

sed tekcos eht si dfkcoS si eht tekcos sed c ,rotpir ub f si a g ne e cir p o retni er f sere ot eht ol c noita morf ehw re eb ot dah atad dah ot eb r dae ot t ar ,refsn n by set acidni t se eht eht rebmun fo byt se ot eb efnrt r de .

F al g noitpircseD

TUORTNOD_GSM E noD 't uor te cap k te edistuo fo lacol wten o kr .

TNOD_GSM AW IT elbanE ikcolbnon ng epo r noita tnelaviuqe( ot gnisu ON_O NBL )KCO .

ROE_GSM sihT si eht dne fo cer o dr fi detroppus by locotorp .

BOO_GSM dneS tuo - fo - dnab d ata fi detroppus by p locotor .

ffid ehT .dnes ot ralimis si noitcnuf otdnes ehT otdnes noitcnuf si ralimis ot .dnes ehT ffid ere ecn si taht otdnes iceps ot su swolla su ot iceps fy a ed s noitanit sserdda ot eb su ed htiw stekcos sselnoitcennoc stekcos . iss z t_e tni(otdnes ,dfkcos tsnoc diov ,fub* is z _e t nby ,set tni lf ags, tsnoc tcurts os c rddak datsed* dr, t_nelkcos )neltsed ;

fo rebmun :snruteR rebmun fo bytes tnes fi ,KO 1 no e r or r Dept.of CS&E,SJBIT

.tpeD fo SI E, TIBJS egaP 80

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 Wi ht a noitcennoc - neiro t de ,tekcos eht oitanitsed n sserdda si i gno ,der sa eht noitanitsed si deilpmi by eht noc n .noitce W hti a sselnoitcennoc ,tekcos ew can't esu dnes sselnu eht rif si sserdda noitanitsed sserdda si rif st tes by c nilla g noc n ,tce so otdnes g sevi su na etla r etan w ay ot ssem a dnes a ssem a eg .

We nac llac mdnes sg iw th a sm g rdh rts u erutc ot s icep fy elpitlum ffub e sr f r mo hcihw ot atad timsnart atad

iss z t_e smdnes g tni( ,dfkcos tsnoc tcurts sm gh rd sm* g, tni lf ag )s ;

fo rebmun :snruteR rebmun fo bytes tnes fi ,KO 1 no e r or r

OP SI 1.X d e senif eht m s rdhg erutcurts ot ah ve ta l e tsa eht niwollof g mem eb :sr

tcurts sm g rdh { diov sm* g an_ m ;e */ lanoitpo erdda ss /* t_nelkcos sm g n_ a ;nelem */ sserdda is ze ni by set * / tcurts cevoi sm* g i_ o ;v */ a rr ay fo I/O b sreffu * / tni sm g ;nelvoi_ */ rebmun fo mele e stn ni rra ay * / diov sm* g noc_ t ;lor */ allicna ry atad */ t_nelkcos sm g oc_ n ;nellort */ rebmun fo a n allic ry byt se /* tni sm g lf_ ag ;s */ alf gs rof r deviece egassem * / . . . ;}

r ehT r e vc noitcnuf si ralimis ot ,daer tub swolla su ot iceps fy emos snoitpo ot lortnoc woh r ew r e eviec eht d ata .

Dept.of CS&E,SJBIT

egaP 81

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 iss z t_e tni(vcer ,dfkcos v dio ,fub* is z t_e n byt ,se tni alf g )s ;

nel :snruteR nel g ht fo sem as ge ni by ,set 0 fi on m sse ag se era elbaliava dna ep er sah enod na redro ly ,nwodtuhs ro 1 on orre r

F al g noitpircseD

BOO_GSM eveirteR tuo - fo -b dna ad ta fi detroppus by cotorp ol

KEEP_GSM nruteR tekcap stnetnoc w tuohti nimusnoc g tekcap .

URT_GSM CN tseuqeR taht eht laer el n htg fo eht tekcap be ruter n ,de neve fi ti saw detacnurt .

_GSM AW ITA LL W tia litnu lla atad si elbaliava MAERTS_KCOS( no ly).

If ew era tni e detser ni ht e itnedi ty fo eht nes d ,re we nac esu re morfvc ot bo t nia eht ecruos sserdda f or m hcihw eht d ata saw tnes .

iss z t_e tni(morfvcer cos k ,df diov tcirtser* fub , is z t_e ,nel tni alf g ,s tcurts dakcos dr tcirtser* da dr, t_nelkcos er* s tcirt )nelrdda ;

nel :snruteR nel g ht fo sem as ge ni by ,set 0 fi on m sse ag se era elbaliava dna ep er sah enod na redro ly ,nwodtuhs ro 1 on orre r

If rdda si non - ,llun ti lliw niatnoc eht dda r sse fo t he tekcos tniopdne morf w hcih eht atad .tnes saw .tnes W neh illac ng r ,morfvce we n e de ot tes eht nelrdda p ara m rete ot p tnio ot na etni ger niatnoc ing eht is ze ni by set of eht tekcos b reffu ot cihw h rdda niop t .s nO ,nruter a eht ot tes si regetni eht regetni si tes ot eht a c laut is ze fo eht sserdda i n by set .

Dept.of CS&E,SJBIT

egaP 82

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 Bec esua ti swolla su ot r e eveirt eht da d sser fo eht s ,redne r vce f mor si llausu y desu htiw .stekcos sselnoitcennoc .stekcos htO ,esiwre r vce f mor eb h seva lacitnedi ly ot r e vc .

er oT er c evie atad otni elpitlum sreffub we c na esu r smvce g.

iss z t_e smvcer g tni( kcos f ,d tcurts sm g rdh m* sg, tni alf g )s ;

nel :snruteR nel g ht fo sem as ge ni by ,set 0 fi on m sse ag se era elbaliava dna ep er sah enod na redro ly ,nwodtuhs ro 1 on orre r

sm ehT sm ghdr erutcurts (w hcih ew was u s de htiw s e smdn g) si desu by r vce msg ot ceps ify u eb ot sreffub tupni eht tupni sreffub ot eb u s de ot er c evie eht ad t .a We nac tes eht lf ags ra g tnemu ot ahc nge eb tluafed eht tluafed eb h roiva fo er smvc g. nO ,nruter eht m sg lf_ ags dleif fo eht m sgh rd erutcurts si c suoirav etacidni ot tes ot etacidni suoirav c h cara t scitsire fo eht ad ta r .deviece ehT( m sg lf_ ags dleif si i g deron tne no tne ry ot mvcer sg .)

F al g noitpircseD

NURTC_GSM C lortnoC atad saw nurt c .deta

TNOD_GSM AW IT mvcer sg saw dellac ni n o bn nikcol g edom .

ROE_GSM dnE fo cer o dr saw er c ie v .de

BOO_GSM tuO - fo - dnab d ata w sa r ce devie .

CNURT_GSM lamroN atad w sa acnurt t .de

.3 tahW si tuo -of- ab nd d a ?at etartsullI w hti ,elpmaxe oh w wo dlu uoy ps ecify tuo -of- dnab .atad 30( m skra ) eD( c- 70 )

:snA

Dept.of CS&E,SJBIT

egaP 83

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 tuO - fo - dnab d ata si na o p lanoit erutaef ppus o detr b y emos noitacinummoc ,slocotorp niwolla g h ig eh r- iroirp ty eviled ry fo ad ta naht on r .lam tuO - fo - dnab d ata si tnes daeha of any d ata taht si la r ae dy q deueu rof t r .noissimsna PCT srefer ot tuo - fo -b dna atad sa "ur neg t" d .ata PCT stroppus no ly a is ng el by et of tnegru ,atad tub swolla u rg tne d ata ot eb fo tuo dereviled tuo fo b dna rf om eht lamron atad viled re y m e .smsinahc oT gener eta u rg tne ps ew ,atad ew ps e ic fy eht MS OO_G B lf ag ot a ny fo t he eerht s dne .snoitcnuf If ew dnes erom t nah eno htiw eht M OO_GS B lf ag, t he tsal byte lliw eb t r detae sa eht tnegru - atad by et .

no seton trohs etirW.4 trohs seton no :

ecar )i ecar oitidnoc n

gniggol rorre )ii rorre gniggol f ytilica ni DSB xinU . 90( m skra ) yaM( - 01/80 )

:snA

F ro ruo p u ,sesopr a race noitidnoc srucco nehw m pitlu el sessecorp a re t rying ot od nihtemos g htiw derahs d ata dna eht if n la moctuo e sdneped no eht ro d re ni hcihw eht sessecorp .nur ehT fo kr f noitcnu si a evil ly b r dee ing g dnuor rof r eca ,snoitidnoc fi a ny of ol eht ol g ci retfa eht krof rehtie e x ticilp ly or ilpmi ltic y ed p sdne no tehw h re ht e tnerap ro t retfa tsrif snur dlihc snur tsrif retfa t he f kro . In g ne e ,lar we nnac ot tciderp hcihw rp o ssec r snu .tsrif nevE wenk ew fi ew wenk hcihw orp cess dluow nur ,tsrif tahw h a snepp retfa t h ta orp c sse strats ninnur g eht no sdneped no eht sy mets daol dna eht ke enr l' s ehcs d nilu g a lg .mhtiro

mitatarahc diov citats diov mitatarahc e(c rah )* ;

tni )diov(niam { t_dip dip ;

Dept.of fi dip(( CS&E,SJBIT = f o ))(kr < )0 {

egaP 84

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 _rre sys("fo kr e r or r"); } esle fi dip( == 0) { arahc t emita (" tuptuo morf lihc d\n"); } esle { hc ara t emita (" tuptuo morf nerap t\n"); } ex )0(ti ; }

diov citats diov arahc t hc(emita ar rts* ) { rahc rtp* ; tni ;c

,tuodts(fubtes N ULL); */ tes effubnu r de /* rof rtp( = ;rts c( = tp* r )++ != ;0 ) ,c(ctup ;)tuodts }

uO :tupt $ tuo.a/. tuptuoo morf dlihc tuptu morf nerap t $ tuo.a/. tuptuoo morf dlihc tuptu morf nerap t $ tuo.a/. tuptuo morf dlihc tuptuo morf nerap t Dept.of CS&E,SJBIT

egaP 85

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 )iii

a melborp enO melborp a d nomea h sa si woh ot eldnah e r ror .segassem It can't pmis ly etirw ot ts dradna e r ,ror nis ce ti ndluohs 't evah a illortnoc ng .lanimret We nod 't tnaw lla eht nitirw snomead nitirw g ot eht c elosno ,ecived nis ce no am ny w o ,snoitatskr eht c elosno ecived iwodniw a snur a iwodniw ng sy .mets We osla nod 't tnaw e ca h nomead nitirw g sti nwo rorre segassem otni a pes a etar .elif It dluow eb a h dae ca eh rof a nyone etsinimda r ni g eht sy mets d hcihw htiw pu peek ot peek pu htiw hcihw d a nome setirw ot hcihw l og elif dna ot hc e kc eseht f i sel no a reg ralu b .sisa A tnec r la nomead e r ror -logging f aci il ty si r deriuqe .

erehT era ht r ee ways t o areneg te ol g m sse ag se :

.1 lenreK senituor nac c lla eht ol g fu .noitcn esehT m sse ag se c na eb r dae by na y su er taht ssecorp taht nepo s dna re da s eht olk/ved/ g d .ecive W e now 't ed s ebirc siht f u noitcn any ,rehtruf is n ec ew ' er n to detseretni ni nitirw g k lenre senituor . .2 tsoM resu secorp s se d( ea )snom llac eht sy ls og(3) f noitcnu ot gen etare l og .segassem We sed c ebir sti nillac g qes u ne ce .retal sihT sesuac eht ssem a eg ot eb U eht ot tnes ot eht U NIX iamod n tad ag mar cos k te ol/ved/ g. .3 A resu rp o ssec no siht ,tsoh ro no emos rehto tsoh taht si detcennoc ot siht tsoh by PCT a PCT /IP ,krowten nac s e dn ol g ssem a seg ot PDU trop .415 etoN taht eht sy ols g reven noitcnuf reven eneg r seta eseht PDU tad agr :sma ht ey iuqer re e x ticilp krowten nimmargorp g by t he orp c sse eneg r nita g eht l og m e egass .

.5 etirW a p rgor am ot im lp e tnem nepop dna p esolc tsys em .sllac 01( m skra )

:snA eD( c- 01 )

.eupa" edulcni# .eupa" h" e< edulcni# e< r h.onr > h.ltncf< edulcni# h.ltncf< > Dept.of CS&E,SJBITedulcni# < sy h.tiaw/s >

egaP 86

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 */ * retnioP ot rra ay olla cat de ta nur - emit . /* N = dipdlihc* t_dip citats t_dip dipdlihc* = N ULL; */ * F mor ruo _nepo max ,)( Figu er 61.2 . /* tni citats tni am x df ; IF LE * c tsnoc(nepop c h ra sdmc* t nir g, tsnoc rahc * typ )e { tni i ; tni dfp [ ]2 ; t_dip dip ; IF LE pf* ; */ no ly wolla "r" ro "w" * / fi (( type[0] =! ' r' & & type[0] =! 'w') || type[1] != )0 { onrre = E I VN AL; */ deriuqer by OP SIX * / (nruter UN LL); } fi dipdlihc( == N ULL) { */ tsrif emit uorht gh /* */ etacolla z deore o tu rra ay f or dlihc sdip /* am x df = am_nepo x ;)( fi dipdlihc(( = c am(colla x ,df is z )))t_dip(foe == N ULL) (nruter UN LL); } fi fp(epip( d) < 0 ) (nruter UN LL ;) */ e onrr tes by epip () /* fi dip(( = f o ))(kr < )0 { (nruter UN LL ;) */ e onrr tes by rof k )( * / Dept.of CS&E,SJBIT } esle fi dip( == 0) { */ dlihc /*

egaP 87

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 fi *( type == 'r') { dfp(esolc [0] ;) fi dfp( [1] =! IF_TUODTS LE )ON { dfp(2pud [1], S _TUODT FIL NE O ;) dfp(esolc [1] ;) } } esle { dfp(esolc [1] ;) fi dfp( [0] =! DTS IN IF_ LE )ON { dfp(2pud [0], STDI _N FIL NE O ;) dfp(esolc [0] ;) } } */ esolc lla pircsed t sro ni [dipdlihc ] * / rof i( = ;0 i < am xfd; ++i ) fi dipdlihc( [i] > 0) )i(esolc ; ex (lce " hs/nib/ ", "sh ," "-c", nirtsdmc g, hc( ar * ) ;)0 e_ x )721(ti ; } */ tnerap ...seunitnoc */ fi *( type == 'r') { dfp(esolc [1] ;) fi pf(( = (nepodf p df [0], type )) == N ULL) (nruter UN LL); } esle { dfp(esolc [0] ;) fi pf(( = (nepodf p df [1], type )) == N ULL) (nruter UN LL); } Dept.of CS&E,SJBIT

egaP 88

GNIMMARGORP METSYS XINU METSYS GNIMMARGORP SC01 26 dipdlihc [ )pf(onelif ] = ;dip */ rebmemer dlihc dip rof siht df /* f(nruter p ;) } I tn olcp se( IF LE f* )p { tni ,df ;tats t_dip dip ; fi dipdlihc( == N ULL) { onrre = E I VN AL; (nruter -1 ;) */ )(nepop sah n reve b nee llac ed /* } df = onelif ( )pf ; fi dip(( = dipdlihc [ df ]) == )0 { onrre = E I VN AL; (nruter -1 ;) */ pf saw n't denepo by op p ne () /* } dipdlihc [ df ] = 0 ; fi esolcf( ( )pf == E OF) (nruter -1); elihw ,dip(diptiaw( &s ,tat )0 < 0 ) fi onrre( =! EI RTN ) (nruter -1 ;) */ rre or rehto naht EIN RT orf m )(diptiaw /* ;)tats(nruter */ r nrute dlihc 's noitanimret sutats /* }

Dept.of CS&E,SJBIT

egaP 89