0% found this document useful (0 votes)
9 views

OS Unit 2 Part 1

Operating System Notes Unit 2 AKTU

Uploaded by

Shishir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
9 views

OS Unit 2 Part 1

Operating System Notes Unit 2 AKTU

Uploaded by

Shishir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 15
UNIT- IT CONCURRENT | PROCESSES SS PROCESS CONCEPT ¢ (bala Wr priatious site’) A process ts an eartuting pro including eunent voluLs of tht 4g. 00 ; Argistew variables, pAoters can be dusoulbed as : To bound process > spends move time in doing Jo then on. CPU bound process > spends time vr comput odion. Process : $ en Co- ppercdive prouss. PALES ade > cont aject by othr process Santp. shoving “> dotun't shore data, ‘emern-, > comput ou” sperdup . variobl, code ote. > modularity | 2 oO {ser work, oh. many Oaks Ob tht Tie time) PROCESS SYNCHRONIZATION: PpRocess oe % contwisunt arts tb o shosud data roy auutt Sn poga Scone’ * enanroining dato: condibtency Regu, “mechanum Yo endure eal exoeubion eb eoppeiating pooetes, Example: int shaud= 5 5 Pa ' 0 mt w= vee ode ye shad; = 5 ett; é | yon Alup (1) 5 sleep (1)5 ahora ef) saa 45 4. Bern processed ars eneuttd parol Rut shy yer erwikon, is UnIpRowson. 3, auquanen Of extention 4 the phous wy be he R2HPR “ prowases aw exeerted se bapa ae co- open ~ tive proses but = Yo known ab "hoe condition | dhis type ri eek PRINCIPLE | OF CONCURRENCY Concur MIVLY > interteowt 4 processes in time to gine the appienand a el LLORUSLONL PSSULbs yy shanin global ALSOUNLES + opemaL cation, a ALSOUELS ¥ tocating prognarnncing eons % also inthoduts th watt nok tf paoensses mary: gun ok defh Sperds. RaLe . epndittion > oceuns usher mulhipls proeetes, ov Usreads Read ov “pailt data items 0 thot “ginal DAU depends on thy ort Of eRCeUaEN of instrut: 8) fn thy pouliple Processes, theupore, OS conwurs fell. things : 4. 05 must bt Oble to keep track of Vorrinud proteases, 2. 0 Must aloe % challorate various ALSOUELA fOr each aetive paoresd 3. 0S must pAoteet th data & Pp ico RSOUNLL Of cath prouss agdunst unintenaud © inieyouncr by mh. processes . 4. The gunctioning a process % the of Up produces must be naupandled ah Spee at whith HS purution is cassied out wative to She spied othe eoneumsent processes. ' PRODUCER CONSUMER, PROBLEM et Have one J OMe wndumer beth ars coming at au ome time % ay OME -ALLOWILLS > CO-OPEIOEV CONSUMER COdE : void consumer (void) i wt Stems 5 exeuiion tn PU: whi (true) ‘ stO0 WN ; i naa 4. Load Rey ™ Ctount] [est Teount = = 03] Up, 2. OECR_ Re emt = Quit Loud], 3, &tove mftoun], Q, out = (out +1) mod n + { ‘ ’ : wound = wound 15] Prowus-Hem (Here) 4 Both prose anu, sharcg fy © Buse (Memory) @® count (voledte) PRODUCER, CODE 7 UE fount = 0 | void produc, (void) 4nd temp 5 : obi (true) exeustion fn CPUS produet, Aters (Herp) ; 4, Load Rp, rofvourd ) [while Count ==n); | exes” pos 2. NER, RPS ‘uo Lin) - : Herp 5 3. stove mount], Rp 5 ‘n= Cin +4) mod ny [tout = unk +15 5 th (0-0 ‘la consume OF ' by ays [oil sf el oie ‘ ene ita daub 5 is 220 (0) 7 % Fells the add. ad [i of ae eng 9 bayer". cose D ; Let Hemp =o igo in ine Co+t) mod 6 = [4] now, count. tes no, 6} tems present Xn wa Hy 0 Wetigg Spout ott ' / Now, cheeks How consume works ? Hew, — Sterne = Buyerfo] = x 5 put= out ¢4 Mod) @ | = o+4 med Oo: [A count = 41-1 = [&] we Hem om buyer | —Kke case @; nee i see ms a out 1 [oat : 4 5 count 6 + : (Pye K prowess phaduts 3 “ems (Xj, 2,0) q steve em bupor, New, HS Auady 1 produce 4% Storm, (74) put Lin] = Temp = %. 5% place at place 3 in = DH Mod N= St! med @ = (| count = Bt! =], Now, consid ; two Snapuctions 7 wad Re , mCvount] O Ca) Hutu auterssfally, 2° TNOR Rp © fe then, pAouss preempt bey 3B. Store mCeount] Rp ® A LONOUPLA —PADUAS , 2 wounk not Updated, Now, tonsUmey tode works Stemce = Suppor out] = ®[o] = % wt = ot! mod 8 = 4 2. yOdenglrs Re oem 5 B-1- 2 (Same, before ereutin sieve mLsount], Re prowsd preamps agai by Prluus, at Producey side, SF wesuines. Finally Ta exteuted & venus oh count why Se (E) 5 toerinated | Now, eongumer exetuced Sie Ts Fnebutton, “Hou, [Re=Q now, load mount), Re 2, feount=2] now town ‘s updated | ecnsumey Alay {taminatrd _ count = 9 s0ys, 1 have “tase ems to aye Bat, m acmal , VWs . Three. Kis probum is coud Roce Condition {wwe cout arhieye — proelss synchowinatton hike Hie of this, sequence, o_esustion | Pim en, Pi C ta. CRITICAL EN consid o a 1D) of nn ctr aan | ent af cool. He caltica) Seuton i wshich the Prous ay. be vere cornmnon | vanlobles , _ upaaniog Q file wohen one paotus ts exeusting 4m tag eatHtal Avction, No oth, procs ” % to be allowed 4d exteutt th Ys cadtcol section. muinal excwsive- No, wo pooesses ory exteusitg %n chur escitical Bein at thy same me ,o = do { ENTRY SECTION. cated! seetione EXIT SECTION Remoinc secifon 5 whur ( Taue)s “Example : process. Py Process 2 te include 44 include 454dlo.h> main () main () Non. criHeal section « ENTRY SECTION Non-cattical section ENTRY SECTION caiticed, Section eatticol Section EXIT SECTION EXIT SECTION SOLUTIONS, OF CRITICAL SECTION (PROBLEM| 4. Mutual Exclusion * only one, process aie time Bs avowed into Us eattical Settion. Requiements, for Mutual exclusion : 7 4 0 Prous that hots Sn US non odHeal do $0 without wreqerdng with Oth, processes. y aL roust not be possible for a preess vrequiss fo 0 Ulta) stttion to be delayed’ Toaufinitely No. deadlok er staswaton, | x when no proces 1 tn @ obtical seuticn , joes that sada pe O45! emttical » Section must be pesmi- udithout del ye No assumfstions ay made About ~eatve proses « pete ee Peeasor A prouss —“VerHaANS eee Ys esttea) sect. for a * gintte time ma : Auton. must iy access, a ie a > calHcol suction Us , none af the p, A process & bauer the, Now, Py wants +o entey In Hs eribeal section Shack) om the othur hand, fis not Sntertsted otal | fo twtencting His enbHea) Seubton bu secthn J Ts staying to sep FL fos execu his chiical section No pee by omy pros. & Bounded wait > A bound must exist on thy oo, of Bmes that othur Presse vu atlowed to enter aped} eattical section aftr a prowss has made a 74- fo entor HS ehiical - Settion & befose thas SUQULSE ws aqvanted. : > amume that each prncess exteues ot pon x60 specd. 3 No _assuroption tonexntng welative Sperd sf, the N phocesses, 4 cond’ need: to held to have good aoj” * @ No two presser m be sirputtonenudls enter. snajle, their -eMticol “Section. © No assumption may be made about Apud "proce 8 : ® wo pws aunoing outers Hs. cS, may block. } othe — pspesath | @ No proetss should hove 4o wort , pred fo erden S45 enmticad section, . DEKKER'S — SOLUTION blag [To]; = true, while blag Cry = pave Ai bw # 0 Hag Loy i= pose while twn #0 7 F pag Lo] y= tue ¥9 Yo tical section. funn 7 - a blag Col: = false I semaindir section Y whi (TRUE); he tor two processes based setely on gio, ech gnese procses loop 0 , repens entesding mis C3. PH process = and A wish +o exttute HS CS fost orders thy igloo earnings thy blackboard. The. po- ews number & writtey on plackbeand , thar Process roves th igloo Q protuds to ¢5, othewue, thar wow wood fos “ds wh, SF repeats this enesde allowed +o enter Ws ¢6, Tis prouduse ts Algo. go" a one prous elle, other u PETERSON'S , SOLUTION do stag Ci) = TRUE } | twuy= $5 while ( plaglid- RHO = =F) 5 eaitical section. : . [pegct] = FALSE 5 pemorney section, J while (TRUE) TEST and SET operation . As) Sperial Mie instAuction used to avoid mutual exclusion, 4 can be dupened as follows boolean testset Cint 1) f i Liss 0) i isl; Awuy TRUE 5 dae L xeon FALSE 5 Fy above yunerion is caried out autor net ay. tS) 9 ov a simple & cay +o vest a applicable +o any "0, iene + wed to purport Multiple enitical eetions. ssp! vy" as 7 wali osstble. y stewwation” ts abto possible. w tho Noy be a dtadLoek, Lock yoriable ! (oldest Method) @x" t ee Wok 4. whut {lok == 4) ony cattical Suction. 2, wks, cod’, nulrase, Lock. 3, cAuiCOl SHON M [ bok=0 5) ot code “> exteutt In user mode \ => No quanantt oh mutual vtlusion cae) (ek Cee ae | Note :4 Loek= 0 means CS fe empty =1 " a Py exeeuted. te Rete Tr (woke =41) 2 (o== t) @F wow, 9 sts volt of botke 4 usty eben In CS. In tty meanwhile, oP wants to enter 5} can} beoz. Lok= 4 pow. _ apts the comption ay | PL. usw end tude. vice versa | case® % excoutid, Tr (0== 1) @ Fae Belpre eneeuting Tp Pt peeempts, and fo, comes, pp chek Ty (o==4) @ False thn enteutts Ip Ar au. tok= 4 ond ents In CS, Now, P, come ‘ g eceuted I, & stk Locke 1 (oveumte Lock vole ) wow, P, also enters {n cS, Both Prowsses au in C8 now. ve, there fe No quosouss Of Mutual excurson tH tis (ue | Tet _and set, instruction 7 pyar while (testand. set er) ie eatital settion Louk = = pose | ‘ oe ri oe beclean test_and. seb ( boolean » tenga) > T boolean ov = Hagel 5 3 4 she (touk= = 1) | Here, T, ord Ty combines 4 work = 15 cect ene instucbian Yn ery cede “5, er seaien Ne ee ne te one Li ake Oj Jest ase BQ then aut thy value fn one stu. 60, tha, premption wut not toke place \ by cuyauute, otk = ieee Lo kK te: rhe Le) Fi) while [ test_anol Set Ha yerwins False means co ompry sR wid eter Be 6S : AR, wu pot rote FA enden 9n cs und) PU tomplutet Ton Props | . 1000 “. Aciwed Mutual “Oe Town Vosiable (siete auiennation metros) —— ohm > two paoeus sol” 5 un UseH Mode. _ Prous fo rout Pr jest while (tas | = 0) | hiv (twa | = 4) cs cs oy Toe 1 ‘ tus = 0, { snitiolly , gun tan be 0 OL, o qusuy= 0 then % n pe, wsill enero f, pu enter OUT fev fuun= 4, all tw twn-o , fo ws eeecrst x: his ews o) @& False g wh enter Tn cs Now, > alto wants +o enfen An C5, x1 wh (two |= 4) (o = 4) @ Te eo ceee tee loop, nk alowed to ent OP inp ena apis thi wmpltion of fe Mucdeal welusion dw, TH_ cue se ee empty cs i any P wonts ie, ue bak, wt xuppose €S bs empty ke tw.= 0 Now 1p, wants -fo orden bub at cont, why? use “hw = 4) (0}- © T pee @ cant enter 8n CS ountl Be get post. baz. ey fr ental S46 ext} caddy wll VERSE fons 4 get exited {x vie versa, oe udu Meant poe sn bees fe ty to wop Ph to ent tn CS, +6 pee teneept »

You might also like