OS decode TE IT

You might also like

Download as pdf
Download as pdf
You are on page 1of 81
VL. SYSTEMS SOFTWARE AND ITS IMPORTANCE. vaca ore ne incor FE aero anamiy ngae Poem se Ase eats fee SEESEAE SER ne mame of omen ete oti Cee tats Gu! Ln Se Sate Lag, nnn at nti em 0 TABLE OF CONTENTS ‘Ghapter-3__ Concurrency Control @- to @- 4) 3: Process / Thread Synchronization and Mitual Exlsion, 3.2 Mutual Exclusion: 5 3.3, Mutual Belusion: W/W Appr on 34 Semaphore 3.5: Monitor. ao = 3.6 Cassia Synclonitation Problems. 17 ‘Inter Process Communication (Pipes, Shared Memory) 38 Deadlock en 39. Deadlock Prevention 3.10 Deadlock Avoidance 3.11 Deadlock Detection and RECOVEEY cme 3:12 Example Dining Philosophers Problem, 3-1 aa 3-6 a8 3-2 3-16 an ee areca Chapter-4 Memory Management (>I) to 733) 44. Memory Management Concept and Requirements 44.2. Memory Partitioning: Fixed Partitioning and Dynamie Partitioning. 4a ™ @ — 43. Buddy System 44 Pasig. 45. Segmentation. 46 Viral Memory 423 447, demand Paging 425 48, Page Replacement. ao 449. Allocation of Frames, Trashing. 4-3 rd File Management Chapter Tapat/ Output ne an 5.1 VO Deviees, Organization ofthe /0 Function. Set 52 yo Buterng.. nn “3 53 Dis scheduling mie -8 54 Overview of File Management. 5-15 55 Fle Organization and cess 5-13 5.5 File Directories. $B 57. Sharing soon S24 58 Record Blocking. : 5-8 5.9. Secondary Storage Management, v8 -28 cia Chapter-6 Systems Software and its Importance (6-1) to (6-24) 6: Study of Various Components of Sytem SoftWareswnnen8°2 —S—aeeeov—=—— 52 Assemblers 6-2 63 Simple Assembly Scheme. - 6-4 6.4 Pass Structure of Assembler con 65 65 Design of Two Pass Assembler 6-7 65 Introduetion to Macro Proceso 6-1 67 Maéro Expansion... pen“ {68 Introduction to Compilers. nM 69 Phases of Compile. ew 620 Loaders 6-20 6:1 General Loader Scheme 6-2 16.12. Subroutine Linkages : penn -2 6.13 Linkers ea 6-2 6.16 Relocation and Unking 6-23 ‘Solved Model Question Papers O- Dems) om 3 Concurrency Control ‘34: Process / Thread Synchronization ‘and Mutual Exclusion (Qt Esplain the principle of concurrency. ‘Aus: + Concurent. access to shued data my result in dat inconsistency. Maintaining data consistency requires mechanisms to ensze the orderly execition of cooperating proceses. + Concurency arses in the sme way at diffrent levels of execution sweat, Following are the example of concurency in different types of aperaing syste 1° Coscurrerreney in multiprogramming smultiple processes runing on one CPU. 2 Concucy in multithreading: An interacion between. multiple threads runing in oe process 3. Concurrency ia multiprocessors: An intercton between mle (CPUs runing muliple processes of treads, 4. Concurrency ia multncomputers: An interaction between ‘mukiple computers running detibted processes or tzeads. Joa isa concuret programming language ‘Process synchronization is requed in uni-processor system, ruliprocessor system and network If more than one tend exists ia fystem atthe same time, then the treads are ‘sid to be concent Synstronization problems ean occur whenever two or more eonciet cess use any shared resource, "+ Cooperating proces share the lgialeddess space + An intereton between Operating Systems 2 2 Concarensy Control .2 Explain the following terms 1) Critea section i) Race conltion (SPU: D-H, Sam, Mr 5) Ans) Crieal seetion A steal section isa block of code that only one process at tne can excite; 80, when one process i in ie crit section, no other process ‘may be in its eal section. The exe section problem is to ensure that only one process at a tine is allowed to be operating in is ral seton, Fig, Q24 Criteal secon ‘Critical secon meas, process may change tome common variable, ‘writing files, updating memory locaton, updating a process tbe et When process is accessing shred mouiable dat, it ssid to bein & ttl seeton, ‘Bich proces thes pemission fiom operating system fo enter into the teal sttion. Stetire of process sas flows 1. Enwy section 2, Remainder section 3, Exit section ‘+ Entry seston: It Block of code executed in preparation for entering tcl section ‘+ Balt section: The code executed upon leaving thecal section * Remainder seston: Rest of the code is remainder section. ‘Bach process cycles through reminder, ent, citcl, exit setions ia this ode. “Ge fr ExcengSn Bn ConcrencyContret perting yen 1) Race condition: = vas conden ec when 0 oF mare operations eT in an aetoed mame, When to of more POSeses ae reading OF writing aancrrrad du and the fal teu depends on who runs precisely when ae called ace conn. There is a “ace contin” ifthe eutcome depends on the order of the ecnion ‘The outcome depends on the CPU scheduling or "inericaving” of the threats lon shoud be avoided because they can cause fine errs in + Race co ‘plications and ae dificult to debug. “tn banking system balance isa shared variable. After depositing the mount, it vpdte ty bank enployee balance = balance + amount. At the same time, some ammount is wansfer then it becomes balance = lance amount, These two tasks are in a race 10 write variable ‘lace, In this the process that updates lst determines the final vale balance, +The concurent execution of two processes is not guaranteed to be determinate, since diferent executions ofthe same program on the same dua may nt produce the same result 1 ection. 1. At anytime, only one process i allowed to ene in is er 2, Solution i plemented purely in software on «machine 3. A proces remains inside its cri section fr a bounded time only. 4 Xo assumption can be made about relative speeds of asynchronous concurrent posses 5. A paces camt prevent ay oer process fr eting into cies! A proses must no be indeinily postponed fom entering it xa = “A lle for Erie Send Operating Systems at Conary Conta (4 Explain the following terms + 1) Mutual exclusion 1) Synchronization i) Race condi USP: Oe, um, Maks 6 ‘Ans. £1) Mutual exclusion : “+ Mutual exclusion methods are ued inconcutet programming 1 avd the simultaneous wie ofa common resource, such asa global variable, by plese of computer code called ciel setons ° + Requiement of mural excision i tha, when process PI is ecesing & shared resource RI then on oer proces should be able to access resource Rl unl process Pl has fished its operation with resource RI + Examples of ssh resources include files, VO devices such as printers and shared dats stratus. 1) Synchronization : Synchronization means sharing system resources ‘by processes in such way tha, concureat acces to shared dat is handled. thereby minimising the chance of inconsistent data, Maintaining. daa consistency demands mechanisms to ensure synchronized execution of caopesting processes, Process synchronization was introduced to handle problems that arote while multiple proces execatons. Ii) Race condition : Refer Q2. 3.2 : Mutual Exclusion : 5/W 5 How lvtock situation is avaoided by uting Dekker’ solution ? ‘Ans: £ » Dekkers solution avoids a livelock sation. + Dekker algoritim was the fist comet solution tothe real section ‘problem fortwo processestireds, It uses an amay of Boolean values and an integer variable, ‘Dekkers algorithm is purely software solution with no speci purpose rdware instruction, I ses flag to indicate a process desie to enter its cried section A aie Eien Se Operating Sess 35 Concureney Controt Operating Systems SSE processes ter their critical sections at the same time, +f 0 ty 10 en enable nam indicates which of the processes should be allowed to it allows wo thresds to share 2 single-use resource witbout conflict, ‘using only shared memory for communication. Processes are loops indefinitely, repeating entering and re-entering its critical section. Here flag and turn are the two global variables + Vaible flag indicates the postion of the process with respect to ‘murual exclusion, The tum variable is used for resolving the confit + Algorithm is 25 follows : 4 Here, if Pl finds ©2 = 0, it defers 10 P2 only if tum = 2; otherwise, it simply waits fr €2 to become 1 before entering its eitical section + Process F2, which is also trying to enter its erical setion at the same time, is freed to defer to PL only if tum I. © Delser’ algorithm is corect and it satisfies mutual exclusion and itis fee from deadlock and starvation © Limitation of Dekker's Algorithm : 1. Dekkers algritim does not provide strict alteration 2 Dekker’ algorithm will not work with many modem CPUs. => “A Gale for Enginering Sudens Operating Systeme 36 Concereney Control 3. This algorithm won't work on Symmetric Mult-Processor (SMP) CPU. 4. Additionally, Dekkers algoritim can fil regardless of platform due 10 many optimising compilers. Compiler may remove writes to flag since never accessed in loop. Creating infinite loop. QS Write short note on : Peterson's solute ‘Ans. + + Peterson's solution is software based solution for critical section ‘problem, This algorithm will not work correctly on the modem computer architecture. It is simpler algritim for two process mutual exclusion with busy waiting. ‘+ This algorithm is less complicated than Dekker’ algorithm, + Peterson's algorithm solves critical section problem of two processes ‘only. It does not requie any special hardware. Two processes alternates execution between their ercal section and remainder sections. ‘Dealock and indefinite postponement are impossible in Peterson's algorithm as long as no process or tread terminates unexpectedly + For indefinite postponement to occur, one process would have 10 be able to contimally complete and reenter its eritcal section while the other process busy waited, 3.3 : Mutual Exclusion : H/W Approach| Q7 Explain interrupt disabling concept of mutual exclusion, Ans. : + On uniprocessor system, parallel execution of process is not possible. But they can only be inteleaved. To guarantee mutal exclusion, it is sufficient to prevent a process from being interrupted A process can prevent the operating. system ffom executing by not issuing. any supervisor call instructions and by lsabling inerups, ‘Access to ritial section can be controlled by calling those primitives, “A Gee for Engineering Studer, An ConcueneyControk Ente on aaa + Use interop 2) Implement preemptive CPU scheduling 1b) Irma eveats to relingush she CPU Extra events to zschedule the CPU + Disable interop 2) node uinerptble code tepons 1b) Think sequently mos f the time «) Dely handling of exeral events “+ Mutual excuvion is gunranted because the etc section cannot be imemoped Disadvantages 1. Tewors nly in a single processor environment 2. eure canbe lst if nt served promptly. 3. A proces wing to enter ite crite! section could sufer from ia What are the advantages and distdvantages of Test and Set 1 Simple inpement 2 vrs well or small umter of processes | 3. Thean be used osepport mug sections, “Gtr Engeing Sue Operating Systeme at Disadvantagos : 1. euler fom starvation, 2. There is possibility of buy waiting 3, There may be deadlock. conceny Contra 3.4 : Semaphore 2.9 Explain with definition, the concept of general and binary semaphore. LSU: Hay, One, nd Sem, Ms 8) ‘Ans. + Concept of general semaphore «+ Semaphore i described by Dijkstra. Semaphore is « nonnegative integer variable that is used as a fag. Semaphore is an operating system ssract dat type It tes ony ieteger value Is used to solve eral Seaton problem. + Dijkstra otoduced two operations (P and V) to operate on semaphore to solve process synchronization problem. A. process calls the P operation when i wants to enter ite erical section and calls V ‘operation when want to ext ite criti section. The P operation is called a wait operation and V operation i eae as signal operation, + A wit operation on a semaphore decease its vale By oe. ooops: 4 signal operation increment its value signa: Sa 8+ ‘A proper semaphore implementation requies tat P and V be indvisble operations. A semaphore operation is atomic. This may be posible by taking hardware suppor. The operation P and V are executed by, the operating system in response to ells issued by anyone process naming 1 semaphore as parameter, ‘+ There is no gunante that no two processes can execute wait and signal operations on the same semaphore at the same time. “ier Emerg Ses an re non matt ks 1d th te 2c emanate paces, Bay semaphore vai oly vee dT TT sempre val rested and 2 ced ely when he semaphore vale 5 dos at change te senapoe Yale wen ti + nay seeps ue ete fo inplenet hn gee semaphores nsec hry semepore: (hyn omenbore ata} Procedin Wa esis vette ener 160 then gn sansa vwacays “ sigalintes “A Gl Engierng Sens Operating Systene a0 Concarney Control 2.10 List the propertis of semaphore Ans: Popartos of semaphore 1, Semaphore we mace independent 2. Senaphores we singe to ple. 3 Coneetes i ay o determin. 4 Semaphore aque many resources simlineousy. 5. Can have many dierent ei sections wih feet semaphore {4 Explain the following functions (along with parameters pated) ‘ith reference te semaphore programing in 'C. 2 sept) semi) ESP Oe tn Se, Mas 5) ‘Ans: sem post () Syme Ainctude sats poston em The tem pou) fiction unlocks the specie semaphore by performing semaphore lock operation on tht semaphore. When tis ‘peraon resus na posvesenapore aie, ao reads were blocked wing forthe semaphore to be unlocked: the semaphore value is Sil incremented ‘When this operon ret in a semaphore valve of see, one of the dhnads vag forthe senapbor is allowed to eum sucessfully Som its invocation of the sma) fenstion. The sem_post ) interes reenrant wih respect 10 signals and. may be invoked fom siomlcathingfinctin ‘Semwalt () Syaur fot vaiteom,t 3) ( walt nti value of semaphore ¢ i rester than 0 ‘decrement the value of semaphore # by 1 y “Gif Engng Se co Concmeney Contra Opeting Sytem a peti Stns an oncareny Cont «e The sem_walt{ ) funtion Jocks the semaphore referenced by sem by 3.5 : Monitor pertoring x semaphore ck persion co moar in bi rite semapioe vale seen 20, thn he alin head wil nt pr pe epee enum ffm the eal to sem_srait{) wil iter locks the semaphore or the eal is iteroptd bya signal Z tz Explain busy wating with appropriate example. PU: hog ne, Hats 6} (OR What Is busy walting with respect to process synchronization ? Explain how semaphore solves problem of synchrontzati SE [SPPU: O03, tn Sem, Mats 6) ‘Ante: + Busy wating is situation in which a process is blocked on @ resource but des not yield the processor. A busy wait keeps the CPU by in executing 2 process even as the process does nothing + Bry waiting aso called as spin wating. “By wang waste CPU cycles that some ther proess might be able 10 se productively To avo busy wating, process wating for crcl section, Uy put ino the blocked sae, When process allowed entering ito cial seston then process i kept in redy site To overcome the need for bust wating tn wait ) operation: | When proces reads semaphore value and iti nt postive value then proces Blocked itself fr some time '. Semaphore keeps al blocked process ithe waiting queue so process fs hep in is quae CPU schedule selects another proces for exection. In sigma () operation 4 The wakup ( ) operation is used for restating the blocked processes. ‘When any otier process excetes signal ( ) operation then blocked rocess sate changed fom Blocked set redy state 1, Tis proces is kept inte ready queue = = “A Gd for Engerng Suen ‘Ans. + Monitor is an object that contin both dita and procedures needed to perform allocation of a shared rewource. It is a programming Tanguage consist tat svppor both data access synchronization and «onto sypchroization. + Fig. Q.13.1 shows structure of moniter. sero aoaae ooo Bae 72 OO Ey mae Sehymomet Fig. 19:1 Monitor svucture + Monitors implemented in programming languages lke Pascal, java end Cot Java makes extensive we of monitors to implement muna exclusion. « Monitor is an abstract datatype for which only one process may be rceting a procedure at aay given time. Monior is a collestion of —_— as “Gif Engneng Sus ncuron Operating Systems fe {Concureney Control inside the monitor may be ocedure, variables and data stature, Dats Tine global to all routines within the monitor or loal (0 2 specific Monitor data accesible only within the monitor, A shared data faructre can be protected by placing it in a monitor. Ifthe dat in @ Tmonitor represents some resource, then the monitor provides @ mutual txcusion fly for accessing the fesource. A procedure defined within monitor can acess only those variable declared locally within the ‘monitor ad ts formal parameters “When a proces calls monitor procedure, the first few instruction of| the procedure will check to see if any other process is curently active within the monitor, If process is acive then calling process will be pended unl the other process has eft the moniter. If no other proces busing the monitor, he ealling process may enter. + Monitor suppers synchronization by the use of conton variables thst are conned within the monitor and accessible only within the monitor. very coadona variable has an associated queue, Coniton variables operates on to futons ‘wal(condtion variate) signal (condton variable) ‘eval: I suspend execution ofthe calling proces on condition. ‘+ esignal + Resume exceuton of some process blocked afr ewait on the same contin, 1+ The cvalt must come before the csgnl 2.14 List the drawback of monitor 1. Major weslness of monitors is the absence of soncumency if a renior empath reo, sce only one pce tn sve within a monitor at atime " o = 2, Tht the pasty of dence ia the ese of nested monitors a “A Gite for Ergin Sede Operating Systems a Concuneey Conta 13. Monitor conept is its ack of implementation most commonly used Programming languages, 4. Monitors cannot easly be added if they are not natively supported by the language 3.6 : Classical Synchronlzation Problems 46 Explain reader writer problem. ‘Ans. + When two pes of processes need to access a shared resouce such a6 file of database, They called these processes reader and writes. + Malliple readers can concurenty read from the data base, But when updating the database, there en only be one write (Le, ao other ‘writers and no readers ether) More than one reader may ead shared data (p0 writes). When a wter ses shared dat all other writers and readers must be excluded 1 ig. Q1S.1 shows renderer problem, ‘Stared wie oat Z waar Fig, 018.1 Readerriter problem ‘For example in railway reservation system, readers are those who want train schedle information, They are called reader because readers do not change the content of the database. Many readers may acess the Aabase at one. There is n0 need to enforce mutual exclusion among readers. The writers at those who making reservations on a particular train Writer can modify the database, so it must have exclusive access co “ier Engrg Sens Operating Sestens a5 onnrencyControt i axive, no other readers of writers may be active, eee mural exchson if there are groups of ‘Therefore, it must afore reader and awit, Reader writer problem is similar to one which @ Beis 0 be sbared atoong auc of processes. Ifa process wantonly f read the file, then i may share the Ble with any oer proces that also wants to read the Sie We apply nes for acess order 1. Ifa writer i waiting for readers to be finished, €o not allow iy snore readers 2 Mra reader i wating fora wer to Binish, give reader pity. + Uf the vote wants to append the fil, then no other process should have acces tothe ile when the writer hat access to ‘AF reader having higher priority than the writer, then there will be startin with writers For writer having higher prorgy than reader then starvton with reader. 246 Write seaphore tion for dlaing Philosophers problem. (SPU + Dees, 39 fae Sm, Maks 8) ‘Aus. + Thee is one semaphore foreach chopstick. In adion, a local two-phase prorization scheme is use, under which philosophers defer to their aighbore who have declared themssives “hungry.” All ritmeic is rodule 5 system DINING PHILOSOPHERS Operating Sytem a6 Conary Convo! “ while TRUE do « tke chops EATING: rop, chopsticks; ) » 1 Tua ahe_shopeticks procedure involves checking the status of neighboring phiaeophere and then declaring one's ov intention to fat, This i a topes protocol feet dectaring the status HUNGRY, ‘then going on to EAT. procedure take. chopsticks) 4 DOWNime): _/* extleal section lit = HUNGRY; testi P(e): (7 ond etica section DOWN) /* at enabled */ ? oid tae) ‘ “f(plaghl == HUNGRY 1 Lat pl oa, waiting se mnt van cepa ve 24 fe eaten tele 8 ann - snout 0 enn 7 ‘ HUNGRY PAD naly Te sag = Ba 7 pri tag ort (1 As before, each philosopher is an endless cycle of thinking and + , te oss str) =F Tannen | a pean 7 Concurrency Controt Operating Systems a8 Concurrency Control “Once a philosopher finishes eatin, all that remains isto relinquish te ‘he rooouen aor chopsticks and thereby eloas waling tate sicher. sie ) oid dop_chopecatit " ‘ sea) ‘Downimal "ext eacion*/ tenth /* Let lon at ot poe / fase testi+1}; _—_/* Lat phil on rght oat if possible */ pees Urine, wpeafie atten */ ae , coneumedats 47 Wirte 2 pseudo code for produercensumer problem sing H(p==0) seraphre [PPh nse, saat deay Solution to prodeser conser problem ty wing binry , ‘semaphore > void man () {48 Wie a semaphore slo for readers- writer's problem. Hi Sati psn beth td am, Ho 5) Dinaryeeméphore sor producer () ‘ ne eve) semSignalbdelay: comSigns(e; : ) d ‘ee consumes () 9 “A Oe for Erie Ske ‘Ans. + When two types of proceses ned to access a shared resource ‘such a le or dutsbase, They called these proceses reader and writes The writers are tote"who making reservations on 2 pantcula tin Weiter can modify the ambas, soit mst have exclusive acess, When writer i active, no ober readers or writers may be active. Therefore, it ‘ust enfree mutual exsuson if there are groupe of reader: and 8 “+ Reader writer problem is smilie 19 ope which a file is 10 be shared among a set of processes, Ifa process wantonly to read the ile, then it say share the le with any other process that also wants to read the file, 1 the writer wants to append the ile, then no eter process shou Inve acess t the fle when the writer has access t it Sa eater Ene ts io Concarency Contra fee 249 What is eral section ? Give semaphore solution for producer + consumer probes. PUPP: May, Se, Hak 5) ‘Ams: + A cial sein i block of code that ooly oe process at & tine ces ext; 0, when on proces sin its eral ection, no ether roess may be i fs ctl secon. The ercl section problem is 10 aT “A Glo Enecng Sader Operating Systems a0 conceney Conta censure tht ony one process at a tne is allowed to be operating in its cried section. ‘Producer ~ consumer problem is example classic problems of synchronization. Producer process produce dat item tht consamer process eonsumes Inter + Butler is wed bemeen producer and consumer. Buller size may be fixed or variable, The producer ponon ofthe aplication generates dita tnd sore itn a butler andthe consumer reads daa from the bur. ‘In ord to synchronize these processes, bth procedure and consumer ‘xe Blocked on some condition. The producer is blocked when the ‘buffer full andthe consumer is blocked when the bute is pty. 1. Cote for prodocer + 2 Code for earamer proces [producer trots) ‘ ‘ soem soem: ‘white (TRUE) | we raz) | produc tom (2 tem); seep eater tom (tem ‘counter = counter + 1; (comer = = 1) ‘razoup (consumer) aS “A lef Erie Sens ee a Concreney Contra Operating Systems aa Concern Conte “37 Inter-Process Communication (Pipes, Shared Memory) it 8 pn deret IPC mechs. 3 ES[SPPU : May-28, Dec-18, End Sem, Marks 5] ox iepoces Communion vides 4 mechanism 10 exinge i dinero css mail process, whch might be on Sle cer compas sone ya ewok 1 eps ef eros commsicon a ws 1 Shed mene permie pce commnit by singly edie fet venga peel mem ieon 2. Mapped memory i snr shared meno, Aer hat 3 Sond wits ene fe en 3. Pps perm equal oman Som one poss fad ro || 4 For ae sii 10 pies, estat ered proces on Commu ten pie gen ane nef rm, 4. Sets mpg snmniatoa been tried proce Sen comps 4. shared Mor = A ion of meen ht ise by coopeing pene i ‘ahi Pacemer an te ecg iron by dng so |||, sig to sae gin | Shared memory allows maximum speed and convenience of, ommnicaton, as it can be done at memery speeds when within a computer. Shared memory is faster than message pasing, 2s rmesiage-pasing systems are jypiily implemented sing system calls ‘nd ths equi the more ime- Available (Request is not granted) New available = Available 53,2) ©) For P, process Need = (1, 0, 0,2) Available = (1, 5,3,2) Need < Available (Request is granted) [New available = Allocation + Available = 3,5, +4 5,3.2) = 2886) 4 For process Py ‘Need of Py = (0, 0,2, 0) eos “A Gul for Enpinecrng Stade operating Sytem sot Conerency Coto ‘Available = @, 8 8,6) Teed < Availabe New avaible = @, 14, 11,8) Process Py Need of Py = (0,6 4,2) Available = @, 14, 1, 8) ‘Need < Available 214,11, 0,014) = 214,121) 1 Again for P, process ‘Need of P, = (0,7 5, 0, Available = 2 14,12, 12) Need < Avalable {New available = (1,0, 0, 0)+ @, 14, 12, 12), = 6,14, 12,12) So the ste sequence is Py Pay Pas Pos Pa 31 Consider flowing New availble | Rw ett sas [ mB 2pefe afaia T CE Oe I TE ES feat ma |e)? beads Real Answer the following questions using bankers algorithm, 1) What i the content of matrix ned ? 1 Is he system in sae state? What i safe sequence ? "(SPU ot, tn Sem, Marks 5; Ap, In Sem, Hark 6 Answer the following questions wsing Banker's aio 4) What are the values of Need Matrix ? 1) Ie the eprom inthe safe mode 7 If yes, what isthe sae sequence ? Ifa request from process PL arrives for (1 0,2), eam the ‘aquest be granted immediately ? [S97 Ed Sem, Mars 20) ‘Ans. Safe sequence : Safe sequence is clelate as follows 1) Need of each process is compared with avallble. If reed, < avallable, then the resources ae allocated 1 that process and process wil release the resource 2) If need is greater than avalable, next process need Is taken for comparison, 3) In the above example, need of process Py is (7, 4, 3) and available is B32), reed > available > False So éytem will move for next process 4) Need for process Py is (1,2, 2) and avallable 3, 3,2), so eed < available (work) (1.2.2) § G,3,2)= Troe ‘hen ish [i] = Tre Request of P, is grated and proceses Py is release the resource 10 the system, ae “nie fr Egeing Saez _ : Coney Conn pennies BS ‘Woik = Work + Aston Work := , 3.2) + @, 0,0) * 63D a is poet scone fer al oes. Se et 00) enna wih Do a 632 ‘eel > Avaable = Fale > 632) 6) rr 1) 8 soph vile, 3,22 Ned < Avaible (1) <639=Te vale = avalible + Alloeaton = 639701 43) ew sve 1) Then process Ps ned (43 1) compared wih vale 743) © ‘Need < Avalibe (43 < 043) Te ‘Avalibe = Available + Allein = 743) +(002) =(745) (New avaable) 1) One eye is completed. Again ten takes ll emsining proces Sequence. 8 pts Py ned (743) i compared with new ava 45, Need < Avalible 49 < 045) ‘Avalible = Ava + Alben = (145)+(010)= (75 5) Qlew avalahle) 9) Process edi (600) is compared with new avalible (755) Neal < Ava = Tre 600< 055) Tre ‘Avalible » Avalale + Alcaton = 055)+G02 “A Ge for Experi Se Operating Sten 30 ConcaeneyControt = (1057) = (New available) Safe sequence is 132 What is banker's algorithm? Explain banker's algorithm. ‘Ans. : + Bankers algorithm is the deadlock avoidance lgrthm. Banker's is named because the algoritim ie modeled afer a banker who rakes loads fom a poo! of capital and receives payments that are returned t that pol + Algortim is check to see if graming the request leads to an unsafe sate, I it does, the request ie denied If granting the request leads to 2 tafe stat it seared ox. + The Dijkstra proposed an algorithm to regulate resource allocation to void deadlocks. The bankers algorithm is the best known of the svoidance method “By using avoidance method, the system is always kept in safe state tie easy tovcheck if a deadlock is created by graming a request, ? 1 Once n philosopher finishes eating, all that remains sto relinquish he resources, te two chopsticks and thereby release wating alghors void drop chopeticktin ‘ DOWN}; J eel section */ SS A hide for ngnceing Se Operating Systems « ancy testa); 1 Lat pon tt on posse */ test(i+1); _/* Let phil on gt eat if possibie*/ Pte); 7 wp cited secon */ ) .37 Explain dining philosopbers problem. ‘Ans. + Dining ptilosophers problem is one of classical proces synchronization problem. Here five philosophers are sexed sound @ cirular table, They spend ther lives in thinking and eating. Five plates with ve forks are ket on the cular table ‘Wile philosophers think, they ignore the eating and do not require fork. Whea 2 plosopher decides oat, then bese must obtain 2 two fork, one om left side feck and. another from right side fork Philosophers can pick up only a single fork atone tne. After consuming a fod, the philosophers replace the fork and resumes thinking. A. piloopbers to the lef or right of » dinning piloopher cannot eat while he dinning plospbers i eating, since Forks are 2 shared resource, 1 Fg. Q37.1 shows seating smangement of Sve piloopbers. + Consider the following cade oid laning_Patoopter () ‘ wt (se) thinking sextag , Fig, 37.4 Bini , "Spnophers wid ening () telefon ( sal ( eatood daly) —_—— Ss “oso Egarig Satn sere se Concurrency Cott pring Sytems ptsghtfon( pti ( } and concuretly, it i Here philosophers operates asynchronously ponible foreach pilosopers to enter ito eating mode. The procedure fake () waits until the specified fork is avilable and then seizes it This isnot posible because of the following reasons. ‘+ Bach philosopher will hold exstly one fork, and no forks will remain svilabe onthe le. The philosophers wil all deadlock. ‘To solve this problem, write some exta code in takerightork ( ) ‘procedure, User ean specify the philotophers to put down the left fork 1 that pilosopherscanot obtain the right ork Problem analysis : «Shared resource : Here each fork is shared by to philosophers so we called i isa shared resource. + Race condiion : we do not want a piloropher to pick up # fork that ‘bas already been picked up by hit neighbor. This i a zce condiion + Solution + we consider each fork as x shared item and protected by 2 rule lok. Before eting, etch philosopher ft lok lef fork and then Fight fork If philosopher acquires both locks suceesfl, then philosophers have two lacks (evo fork) so he can eat a food. After fishes easing this plospber releases both fork, and thinks END. “A Gd for Eglening Sul Unit tv 4 Memory Management jemory it Concept and Requirements 241 Explain primary memory requirement, Also lst fonctions of memory managemest. ‘Ans. : Pmary memory requirements 1 Access time : It should be as small as posible, This need influences ‘both softare and harware design. 2 Size : Size must be as lage at potsible. It can accomodste many roprams into memory. 13. Cost: Cost ofthe memory sles thn the ttl ost of the compute. Memory Management Function 1. Allocate primary memory space to processes, 2, Minimize access tne, 3, Determining allocation pliy fr memory. 4. Daallocation technique and poly. 22 Define the following = Compile time, loadtime, execution time. ‘Ans. + Compile te : Source progam is translated at compile time to ‘produce relocatable object module. At compile tine, the transistor ‘enerates code to allocate storage forthe varinbl, Tie storage adress is ‘wed for code reference. Tage adress i¢ unknown at compile tne, it ‘cannot be bound at compile tine. Example of compile time binding is MS DOS.com programs. ‘Load time + Compiler genentes relocatable code if compile time binding isnot performed. The loader modifies the addreses inthe load 0) a Memory Manageeny | Operating Stems Srerting Store 3 Memory Management ae a nd tine wo ode te exe mabe OEY FA mg | aoe i program lon time. nization Main memory is organized as a lineat or ‘Remory, Final binding i eayed il rogram ‘one-dimensional adress space that comiss of sequence of bytes or fam is changed ‘eExecutlon time + Memory address of the poets Bed a aa en, ten execution Ge hinding i wed: Binding is detayeg fram. Normally all operating sem tse, for execution time So te fine of ie F ran ume dig Spec fdas wed vag aaa Wet re eure for emery mange 7 : [EB (SPP : May-t6, End Sem, Marks 8) [Ans + Memory shanagement requirements are Relocation, Protection ‘Sharing, Logica organization and Physical organization. ‘Relocation + Programmer does not know where the progam will be placed in memory when itis exceed, While the program is executing, it may be swapped to disk and retured to main memory at different location (relocated). Memory references must be tasiied inthe ode to atl physial memory addres 1+ The operating sytem need to know the locaton of 1. Proeess contol information 2. Execution stack 5 Enuy point ro begin the execution of «program, ‘Processor’ must eal with memory references within the program. «+ Protectlon : Memory protection i used to avoid interference between ogams existing in main memory. The memory protection hardware Compares every memory addres used by the program with the conten of two registers (base and limit to ensure that it ies with the allocate! memory area, Multiple hardware memories are used to provide a larg adavess space. ‘The simplest method of memory protection Is adding two register the CPU, This warks good for all memory is allocated contguow. [Non-cotguous memory is harder to protec. ‘Sharing + Allow several processes to access the same postion memory. Beer to allow each process access to the same copy of tt ropram rather than have their ovm seperate copy. ———— ae “A Guide for Enginering Swe words. Setondary memory at is physical level is similarly organized. is physical y Most of the programs are organized into modules 8 Computer memery is organized into to 28) Main memory : Main memory isa volatile wemory and it provides fast acess at elavely high cost. 1b) Secondary memory : Secondary mettory is non-volatile memory and itis slower and cheaper than main memory ‘In a fxed size patoning ofthe msin memory all paitions are of the same size. The operating sytem divides main memory into a number of| {xed size arition. Pach patton holds single program. 4 Flaed sized pattions are relatively simple to implement. Degree of rmultprogrmming depends onthe number of panitions ‘+ Normally main memory is divided into two partons 1 For resident program 2. For user processes, ‘Batch operating system uses the fixed size pation scheme. The operating system keeps the record. of memory location and ‘ealocaton in the form of table, Intly all the memory is availble for ser processes ‘When the proces aves in the system and needs memory, operating system search for large hole for this proces. Hole is one large block of fee svalable memory. If any fee hole is found, process is allocated to the fice hole of memory as is needed + After allocating number of holes for the processes, a set of various size holes is seatered throughout memory at any given time, When 2 tailor Emig Ser —_ perting Supe “ Meer tpg ve mec en) of EB ey . to accomodate the process. alee. Any Ost Whos a an be ne io sy oes rt be lage en008h «Fixed sized partitions are simple is tess than or equal to the pari salable pation may Fig. QA shows a expe of fied partoning of FT a memory, Korea! | Thee ate two eliculies withthe use of equal size >= Sed partons 1A program may be to big (fit into pariion sem 2. Memory sition is extremely ineffcen. aa «i ficult is solved by using oveays, Ovelays involves moving data and progam sepments in and Fig. 04.4 Fixed out of memory Advantages and disadvantages of fixed partton size 1) Advantages 1, Simple to implement, 2, Does not require experize lo understand and use sucha system 3. Less oven, 2) Disadvantages, 1. Memory isnot ily uilized, 2. Poor wilization of processors. 5. Users proces being lnited tothe size of available main memory. 4 Reguies contiguous lading of entre program, {5 Explain dynamle patton of memory. ‘Ans. : Contiguens Memory Allocation with Variable Partitions The use of unequal size pains provides a degree of flexibly’ ‘iced pattoneg. Indymac pariioning, the patitons are of variate length and mumer ‘In noncosiguows memory allocation, a program is divided into blosts ‘that she system may plein nonadjacent slots in main memory. ‘This allocaion method donot suffer from intemal fagmentatios Decause a process pain is exc -roces partion is exaty the size of the process, = A Ge for Engncring ae | Operating Systems 5 Memory Management ig. Q51 shove somonips mney ain mt. Opening sysen mana he wie wich oun enemy wes eee yroess and fe menoy. Manory magenta this information for allocating processes. Sanne man) [fasaw seen Soren Prien regent | | Fora: | | Pagans wong! || Taney! | | is reopen | | Pegg (teas | | Peta) mae Papen freemice | |i Frese Fig. Q5. (a) Variable size partition Opt ‘paaina open ‘tem Progen: | | Progam: ons) ona) Fes paca Freepace || Pagan? cans) Faasa Fig, 54 (8) Nencontiguous memory allocation ‘Table contains information shout memory staing address for rocesprogram and thei sie “© CPU sends the logical adess of the process to the MMU and ihe MMU ues the memory allocation information stored in the table for nlcuating logical address. We called this adress a effective memory adress of the dutwinscton, “efor Egg Seon ae _— Memory Managemen — ‘as Explain iference betwee memory aca. Se cre cates, at eer ‘ans: Dlference Nevenigm eatin | ‘Contiguous allocation popen cwmene wae, Mr eee BSE win wet Sagan process a pad Swapp eee "oe el say whee meme ‘Suter tom itera ‘Only paging, sues from agmestation. __ formal tener seen vege ma cf acury Alin moe noo Wack fer peees. _ st nen poe {a7 What i fragmentation? Explain types of fxgmen eaomenon in which storage space 8 use nce and offen both, The exe tem of storage ‘Ans: ¢ Fragmentation is 2 9 ‘nefcienly, reducing capacity or pefors (Guteqences of fpmentton depend onthe specific 5 ‘Seeaon in use andthe paricult for of fragmentation + Fragmentation are of to pes 1, Intra fapmeatton 2. Extemal fagmentatin. + In fngmenttion, OS caret use certain aca of avaiable memory Interna ragmentation Operating Systems “7 Memory Management 1 To keep track ofthis fe hole is oveead for sytem, ‘External fragmentation ‘et occurs when enoveh teal main Senay tp aise e mi + [RE eqns bu tae congo, | PRT storage is Sragmentated into) a [rage tage mone al hols 2m sie 072 shows exert | PO” fepneston ae ‘Following ae the soln for Fig. @7.2 External fragmentation extemal fagmentaton : 1. Compaction 2, Logical dates space of » processprogram 108 Explain the difference between internal and exter ‘rapmentation. as ‘Se Internal fragmentation External fragmentation No, 1 Mam aleid to «proces say be sly Inger tan te equeid memary. The ‘ierece beeen tase two ‘mie is etal ages ee Fit nd best memory External fagmeniation eis when ‘ere enough wal emery space 0 a) equ, bat valle Spaces Fir tan bes memory alata Thee is wased space intemal [eres] [Se ees dees fon sen fom ener Papen. to a poton die 10 the fst tht the Block of data oaea is "8" | [ERE a tae ana fools paaptgebeagra | e romnew ons wih we dad aocaion te oe oF pt range | [Pa Bea cu mh wee mie pti — co ‘ogi punions scheme and scherae and segmentation sulle fom fragmento "am" “ een ne fom ia) cel pension $F Q2 shows an intemal Ga corre fragmento, Fig. 7 Interna fragmentation = ane ae “Gar fi raving Sat Memory Managemen, cpenigspis EE at ways to remove external fragmentation, (Hapa eet Wa se Sem Ha ans. + Compecion solves probe of exteral Sagmetiation a opening yen oes all te fe hoes 1 oe ie of main memary | and eens lage block of fee sz. «1h must be performed on ech new allocation of process to memery or Completion of proces for memory. System must also mantsin relation information + All fee blocks ae brought together as one Inge block of fee space. ‘Compaction requires dynamic relocation, 4 Fig, Q91 shows compaction, femme] emer a Rs ra, 81 Conpacton + Conpcion isn md seo fm opti coupson suey i dtr On etd fr npn i rapping el ose proces that ae to be moved iin be menoy a Seapeog hein Set eon cis + Conmcion is set abaytpotbl, Compaton i ine con ‘method and wastage of the CPU time, amass clacton Some pepsi yumi Snail ad diame tates ree ener loin ata suerte. These programs 101 space. Technically, the deleted “Ge fr Engen Se Operating Systems “9 Memory Management “+ But in practice the OS doesnot collect such fie space immediately for allocation. This is because that affects performance, Such ares, therefore are called garbage, ‘When such garbage exceeds a cern thethld the OS would not have enough memory availabe fr any further allocation. (240 Explain following terms in brit (any to) ‘Ans. £ 1) Internal fragmentation : Refer Q7. {i External fragmentation: Refer Q7. {uy Compaction : Refer Q8. G41 Free memory holes of sues 15 K, 10 K, $ K, 25 K, 30 K, 40K fare avallable. The processes of se 12 K, 2 K, 28 K, 20 K, are to be silocated. How processes are placed using first ft, best ft and worst {Gt partitioning algorithm. Calewlate internal and external fragmentation. (SU + Hay 8, Dee, 19, Ed Sem, Maks 10] ‘Ans. + Free memory les "15 K, 10 KK, 25 K, 30K, 40K. Process size = 12 K, 2K, 28 K, 20K First Ft: 12K 15K, 2K 10K, 28K 425K, 20K 30K Ben Ft: 2K 418K, 2K 45K, 25K925K, 20K 430K Worst Fit: 12 K-40 K, 2 K 30 K, 25 K-28 K (40 K~ 12 K), 20K 28K GOK-2%) .12 Given memory partitions of 100 K, £00 K, 200 K, 300 K and {600i Gavorder, how would each of Frst-Ft, Best-Fit and Worst-Fit algorithms place processes of 212 K, 417 K, 112 K, 426 K ? Which Algorithm makes the mos elfileat use of memory ? 1 (SPP: May 7, Ed sem, Maks) ‘Ans. Fistst 212 K is putin 500 K partion {417K ie put in 600 K parton 112 Kis put in 288 K pation (new partion 288 K = 500 K ~ 212 K) 426 K mast wait <= nie for Ere Sens Memory Managemen, opertng 5 Best: iz Kis pt in 300 K prion {17 is pt in $00 pation 112K is put in 200K pation £26 Kis pin 600 parton Worst 22K is pt in 600 K pstition 47 Kis pt in 500 K pation 112 Kf putin 388 K parton (600 K ~ 212 K) 426K must at In this example, esti tums 0 be the Best, “43 : Buddy System dy syste srr «bees, ‘Ans: + The buddy system i a simple dynamic storage location ‘met. The boddy system is a memory allocation and management Slgorden that manages memery in power of two increments, Linx operating yee manages memory using bud algorithm. 1+ Fig. QU2 shows buddy system. The boddy system asumes that memory is of size 2" for some intepe: 1, Both fee and resered blocks wil abways be of size 2 for k< N. [At any given time, thee might be both fee and reserved blocks of vious ies. +The buddy sytem Keeps a separate list fr fee blocks of each siz: ‘There can be at most N such lists, because there ean only be NY distin het only be N 243 Write short note on sy, Ed Sem, Mat "+ Single allacton block tobe spl, to form two blocks half the sie of the are block. These two blocks are known as ude. SS —F A ile or ngivetingS® pei Stone an Manor Manageent Te oy wae a | ea wa | 100 KB | 128 KB | 268 KS Bi2k8 100 4B Request Tra aw [pera | toons) 00 Recon | (en Boone] 10 Ranenes Fig. O34 : Buddy aystem a titlly memory conse of 2 single contiguous area of 128 poses. ‘When wser send request for memory, iti fest rounded up to 2 power of. All he lists ae inlly empty, exept for the 1 MB list, which as one hot listed. All allocation are rounded up to a power of two. SUPPOSE the request for memory is 75 K then allocations rounded vp wo 128 K, 13K allocations rounded upto 16 Ke |e a lock of that sine i free, i is take; oterwise, the smallest fee ‘block larger than the desired size is found and split in two halves. This ‘spliting continuous wat he appropiate size is reached “When memory is dellocated te buddy system groups contiguous fee pages. When proces fee a block of memory, the memory manager ‘Checks the bionap for checking block sie. If adjacent block & also fee, the memory manager combine the two blocks into a larger block. 4 This method makes dealloeton fst. IF block of size 2 is fee then the memory manager checks only the Hst of 2* holes to merge them into a 2**! aed. partion. Itemal fagmenation is exused since ‘memory requests ae fied in 2 sized paritons. ‘Advantages 48) Easy to implementa buddy system Ee = “Tie for Engincrng Sens Opting Sytons +2 Memory Managemen 1) Allocates block of comect size ) eis easy to merge adjacent hoes 4) Fast to allocate memory and deallocating memory Disadvantages 2) Te equtes al llostion unit tobe powers of 0 1) Be eas 10 internal fragmentation ) Merging of holes ie recurve, s0 poor worst-case behavior, 44: Paging 024 Wat pacing? Felina dts Ans: + I psig, opting sytem dies each incoming pregame into pags of egal san. The selon of dst called Mock’ secon The seins of main emery ae ele pgs aes. One Secor Sil bld one page fj nats sd tit oe pee me f rece. © Th pans loi oss apace of a progam canbe pevcetis Isles ena fngmetton problem ©The reon tewen vinml ade and lyse! memory Ble en ty pgs + red set lock we eld ames ad ring of lg ema ino ek of same sie alld page + Menon) manger pepe filling things Defe executing.» ewan 1 Find ot he manker of pgs the proah, 2. iene tn meno 3 Loatig of al the programs pgs ino mene. * Pac oo ded conimosy in msn memory. Fach page can stdin ny aah age fe ene a mala memes Ma) ‘manager keeps the tack of pages of program. Paging avoids extetal ‘frogmentation and need for compaction. ~ =Ss-—cuwWwW A Gul for Engine operating Sytem a i Menor Management Maney MAMHES wes Gee bles to ep mack of process and 1. Sob table +1 stores the sie here its page table i stored, 2. Page map table : ofthe ative job and memory loation Sequential order 3. Memory map table and its tans, ‘Page size depends upon undedying andware, Operating system amaintains page table for each process. The page ble shows the fame location fr each page of « process Fig. Q.14.1 shows the viral adress format for paging system, MMT is wed to sore page fame location ge number ()] paceman rotor Fig. 14:1 Vitual adress format + Processor hardwite performs the logical to piyscal adress translation, Logical address contains page number and ofet. The physical address Contains fame number and offset. OMet is a relative fico. I ie used to locate that ine within its page frame. Fig. Q14.2 shows address translation Page nber()] age otter (©) ] Vina satraee oP onlay Priel aden Physical page umber 7 lef Egneng Stns Fig. 0.182 Adres i ou Memory Management | representing both piscal and viru renting sent as 1 mst significant bit (y ssn ge mane: ye me a de pene eee seen penne vial es pyle fans i 2 ei rem es 206 aon | cae Tm er hse po esd | cw ee common fecnghs for srctring 8 pane oe Yl atte te fhe tele ae ‘ea (SPU + Déc-17, End Sem, Marks 10) ‘Ans Page Table Structure + 4) Matilevel or Blrarebeal page table: 1 Page ales can consume a signifiant amount of memory. ‘For example: A 32-bit viual address space using 4 KB pages Page size = 2 bytes Space for page munbers = 232-2! = 2 bytes + so page table may consists of pio I milion ents, on for each pass, for wl adress capacity of about four billion byes: 1 Hierarchical page table is suo called as forward mapped page table ‘This approach is 50 effective that many modem operating systems employ In his method each level contsining a tble tat stores pointers to ‘ables inthe level below, Each able inthe hierarchy is the sizeof one age It enables the operating system to wansfer page tables beret, ‘main memory and secondary storage device easy For two lvls of page table + Vira ales consis page aera pace it that ‘Virtual address (v) = (p, t, d) . ce 0) = Page number 4 = Displacement ‘Heep san index into the outer page able ‘Fg, Q151 shows hihi poge able, | es “Geo Enginerng Sm where operating Systems on Memory Menageent oem oa 2 Fg, 0.18.4 Two level page table method ntl IA » 32 architecture suppor two levels of page tbls. ‘navantage 1, Ttis compact and support sparse adress spec. 2. Teaily manage the memory. 3 It reduce table fragmentation Diesdvantages 1, Overhead due to one more page table 2. On TLB miss, to loads fom memory wil be reuied to get the right adress translation iafoenation fom the page table 2) Mashed page tables ‘+ Hasbed page table suppor address space of 32 bits and more, Hash ‘alu i wed ar visa page umber ‘Hashtable contuins tink Hit of elements, Each elements consists of, following elds: 1, Vital page number 2. Mapped page frame value 3. Pointer to the next element 1 Hash table improves search spect + Fig. Q.152 shows Bock dagram of hashed page table. Ps ss ue for Egierig Sens Memory Managem, table Fig, 0.15.2 Hashe pat Working 1. Viral page number i taken from virtual address. 2. Virtual page mumber is hashed into the hash table. 3. Virtual page number is compared with the first element of linked list 44 Both the value i matched, that value is (Le. page ftame) used fe calculating physica address 5. Ifthe both value isnot matched, the entre Inked list is searched for: matching. «Clustered page table is same as hashed page table but only difference i that each entry in the hash table refers to several pages. 3) Inverted page table ‘Te uses a page tble that contains an enty for each physical frame, Thi ensure that the page table occupies a fixed fraction of memory. The sit {is proportional tothe physical memory. ‘Page table overhead increases with address space size, Page table 100 big to fit in memory. ‘Invered page table has one entry for each real enty for each real page of memos ‘ookap time is increased because it requires a search on the inert = A Guide for Engineering S08 operating Systems 1 Logical address is as follows ‘Inverted page table is used by Ianium, Power PC and Ulta SPARC. 2.46 Explain with the help of a neat diagram how TLB can be used to improve effective access time ? 53 (s7u : beeA7, Ee Sem, Mark 10} ‘Ans, + + Set of registers are used for implementing page table, Registers are suitable only for small page table. If page table size increases then special purpose hardware cache is wed for page table. # Special cache memory called a Translation Lookaside Buffer (TLB) is ‘used with the address translation hardware. The full page table is kept in primary memory 1s TLB is very effective in improving the performance of page frame aceess, The cache buffer i implemented in 8 technology whichis faster than the primary memory technology. # Fig. Q.16.1 shows paging with TLB. —_ Pu Oe rset] T 1 [Prima Page H oe | [ewe beef ne Fig. 16.1 Paging with TLB © The TLB contents may be controlled by the operating system or by hardware, depending on the arcitesture a Gilde for Eien Sader Memory Managemen pena Sens the map i reid fg, ie waned 1 9 pe 6 se 2 ie i i i ey tS pray enory ihe TEE, TT ee es i a ; rans int wes Gi Be mur te pus morrine : ae tee a oh pee mae hn led Pa A) eT it F ores TUB doc at connin a ney fr page hen it cle ws a 3 ie TU nian ese af TL is he oping system Bt mt Tal ny athe pry eon, wih sees ee cue TB is asocnive, hghapeed memory. A wasn baller racecar ew ofthe tapsltion ble eis is very is fr ema mane of ens Op et meioy reece seit wk TLD if h hnows abot the pape. If 30 the referen ved fo 42, Ir 718 beso infomation for page, st g0 trough FARE 2H: a ako gt infomation, Referens takes ng Se, Bi SE ie te is pune to TLB 50 ill ow i fr ex fees. (097 Lis advantages and dinvantaps of Pasig. ‘as :Adrainges of Pala 1 aging clits figment. 2 Sopot higher dere of msligrogamnin 3. ino ineses memory ad procs wiiaton. 4 Conpcionoveheadreued for he Yelcatbe parton schene Sho linac. Dlendaiages of Pasig tages mig Wve ly en cnt of 2 Meno’ mit te wed se vas ; ‘memory map table ete. ie Be eee Some memory wil sil be unused if Sane mene smused if the numberof available Bost sufi for the addres spaces of the jobs tobe run. = a A Guide for Engineering Sos i oprting Stes eu [85 : Segmentation (q.48 Explain segmentation with suitable disgram. [sr Dee, en Sem, rs Memory Management (oR Describe the address translation mechani in segmentation with suitable diagram. [rd Hays, tnd Sem, Maks 6 ‘ans: : In segmentation, 2 progam’s data and instctions are divided into blocks called segments. A sepment isa logical entity in 8 program. 1 Logical view : A process consists ofa set of segments. “sPhysieal view : It coisiste of nonadicentaeas of memory allocated 10 segments “all segment size may be equal or may not be equal, Segmentation ‘support user vew of memory. «collection of segment is called as logical address space. Each segment is identified by its ame Processor genertes logical addresses. These addresses consists of segment number and an offiet ito the segment. Segment number is sed as an index to segment page table + Segment names ae normally symbole names. Operating system maintsne segment table for each process. It is ‘sully stored in main memory as a segment that i not 1 be loaded as Jong a8 the process can run. Each enty in the segment table has @ segment base and 2 segment limit. The base field contains the segment relocation register for the target segment. The sepment limit Gelé contains the length of the segment. “Fig. Q.18.1 shows an addess translation in seamenation + Segment table contain the physical address ofthe start of the seament ‘Then add the offset to the base and generate the physical address EE = “or gins Suds __— - Se | eine Fig. 2.184 Address wanslation In sogmentation site required reference i nat found in one of the segment reise, then eror is genertd. At the sme ne, operating system does looky) in sepeat ible and lode new spent descriptor into the register. (218 Compare segmentation and pag Segmestation opi i viel in ned ie Segments. ae i | ae | ‘LL Program is dived iato variable 2 User (or compte) is responsible Diy fx cancme (ae 7” es Sots : A Guide for Engineering So" ‘Segmentation i slower han ee. Tec isco exer fagnentatin. | Process wes segnct mame, | ‘fer cleie sole ares | | & OS wninain ait of ec oes in OS max main ee fe Ut [mene (020 Explain the addrese translation mechanism in paging and segmentation with proper example. E=SPPU:Mayt, fxdSen, Marts 8] ‘ans. Refer Q14 and QS ‘What are the physical addrestes forthe folowing logical addresses. 90,430 i) 1,10 i) 2,80 iy) 3,400) 4,90 (MPU: May 36, En sm, ark 8 ‘Ans. Physical Address = Ose + Segment Base D 0,60 omiet = 430 Oo “afr Engng Sues ae: a Segment = 4 : Menor angen me ed een = 500 i seg th sere“ 9 i tan eget gh 0 ed rig ein Sata tn ane = 430 + 219 = 649 Psd aes = Offet + Segment Base » 10 fie = 10 Segment length = 18 Segnea= 0 Cnet 10 is ess than segment length 14 and staring Location of sepmext Vis star fom 2500. ‘Physical address = Offset + Segment Base = 10 + 2300 = 2310 w 38 . | oe = #0 Seznet ag = 10 Semen =2 : oe 0 tan spt gh 10d sang lon vee] Sten bon 3 | | Physical adress = Ofet + Segment Base = 80+ 90, Pica addess = 170 3400 tet = 400, Segment length = 580 Segment = 3 COftet 400 is ess than segment length $80 and stating location of Segment 3 is sta from 1327 Physical adess = Ofiet + Segment Base » 490 one = 99 Segment length = 96 = adeatnigeans A Gude for Engineering So | 400+ 1527 = 1727 “oe 90 ss than segment “4 is start from 1952. a _ Physi aes: = Of + Sepent Base = 90+ 1982 = 2082 "ah 96 and stating Ioeston of segment : (46: Vira emo | (22 Explain the concept of virtual memory with suitable diagram. ERP: owt Sem, Mate ‘Ans. + Viral memory i a method of wing hard dik space to provide extra memory. It simulates ddional main memory. 1a Windows operating. system, the amount of viral memory availble cquls the mount of fee main memory ps the mou of disk spice alles 12 the swap file “A swap file i an ares of your hard dik tht is set aide for virusl ‘memory. Swap files can be eer temporary or permanent. Vir memory is stored in the secondary storage device. It helps to extend additional memory capacity and work sth primary memory 10 toad applications. The vival memory will reduce the cost of expanding the capacity of physical memory. ‘Each process adress space is paronel into pars tat can be loaded 10 primary memory when they are needed and writen back to Secondary storage othersse. Address space partons have been used for the code, data and stack ened by the compiler and relocating hardware Ii pon of he proce at scl la menor toe 1 suet be te ten to he poses Te op stl fc rere wm ial een Te val ses pace mosh pre pea rina Tec aces nen Tae al meno wots wih lp Brena seen cee tls ied ow engl oe Phra! sag sion a = Tame gaara

You might also like