Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
92 views
Os 2 & 3 Units
Uploaded by
Aparna Gunde
AI-enhanced title
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
Download now
Download
Save OS 2 & 3 UNITS For Later
Download
Save
Save OS 2 & 3 UNITS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
92 views
Os 2 & 3 Units
Uploaded by
Aparna Gunde
AI-enhanced title
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
Download now
Download
Save OS 2 & 3 UNITS For Later
Carousel Previous
Carousel Next
Save
Save OS 2 & 3 UNITS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 106
Search
Fullscreen
Memory m Ty management strategies with example architectures: Swappis | UNIT i Threshing, 9.1 Memory MANAGEMENT STRATEGIES WITH Exampte ARCHITECTURES 2.1.1 Swapping 1, What is Memory management? Explain briefly. fas i ‘There are two types of memories first is the logial memory and second isthe physical memory the memory which is temporary such as rem is al mown as the temporary memory and the memory aihich is permanent such as hard disk is also known as the physical memory of system. When we wants to execute any programs then that programs must be brought from the physical memory into the logical memory So that ihe uses the concept of the memory management. this is the responsibility of the operating system to provide the memory spaces to each and every frogram. Also manage which process will be ‘executed at that time. Operating system translates the physical address into the logical address, if he wants to perform the operation, then he must translate the physical address into the logical address This is the a oesinown as binding. Means when 2 physical address is mapped or convert into the logical address, and then this is called as the binding. ‘There is also a concept which is also known as the dynamic loading, in this a program doesn’ reside into the memory of the computer and we must have to load that process for processing. So that when a process is loaded only when a request has found, then it is called as the loading of the Process.‘ (imp.) (75 es = Contiguous allocation, Paging, Segmentation, Segmentatios ain ging. Virtual memory management: Demand paging. Page replacement. th Q2. What is process address space.? Process Address Space’ “The process address space is the set of logical addresses that a process references in its code. ‘The operating system takes care of mapping the logical addresses to physical addresses at the time of memory allocation to the program. ‘There are three types of addresses used in a program before and after memory is allocated. Logical address - generated by the CPU: also referred to as virtual address Physical address - address seen by the memory unit Virtual Address - is a binary number in virtual memory that enables a process to use a location in primary storage (main memory) independently of other processes and to use more space than actually exists in primary storage by temporarily relegating Some contents to a hard disk or internal flash drive Logical and physical addresses are the same time and load time address-binding irtual) and physical addresses binding scheme in compile: schemes; logical (v differ in execuliontime address Virtual and physical addresses are the same in compile-time and load-time address-binding schemes, Virtual and physical addresses differ in execution-time address-binding scheme, +The set ofall logical addresses generated by logical address a program is referred to as Space. The set of all physical addresses Rahul Publications Samal th CantonLYEAR Ii) noe A Ee, address space. esses is referred to 05 @ physical dares is done iq mechanisin to convert comepending to thew logical addre the memory mani sal to physical by iagemeny | to physical al address top ** U uses followin The runt (AML) which isa hardware device address, 1 is added to every address generated by 2 USEr process, uiiy 2 ne ernay, For example, i the base register value is 15 it 10 Tae ion 100 will be dynamically reallocated tole, 1 rapping from vit , The value in the base register treated 25 offset at the time it is e user to use addres then an atternipt by the 16100 .ces the real physical addresses. 1 addresses it never 5 1 deals with 7 The wer pon Q3. What is Swapping? Explain. Aus: Fs (Imp, ha rt 5 can be swapped temporarily out ‘of main memery epee veg available to other processes, At some ax (disk) and make that mem: t ‘rom the secondary storage to main memory. Sweppingisa mechat mone} to secondary storage time, the gstem swaps back the process " is .cess but it helps in running mubtiple ax, vovugh pertormance is usually affected by SwaPPIE pro tees tig ce erlel = ty thats the reason Swapping is also known 26 2 technique for mem, compact ‘When there is a situation to perform swapping, 1. Seléeting vihich process to be out 2. _ Selecting which process to be in 2, Providing the memory Space to the processes those are newly entered. “In this sueeper il select the suspended proceis then brings the ready process in memory andate the execution that suspended process will be again entered into the memory by the sweeper. For swapping the sweeper also uses some address those are also known as the logical and physic! sdéress oh processes. For providing the logical address into the physical address there the following to approaches used. 1. Static relocation fin the static relocation swapping never to be performed because the process are always have Es memory. Which is not to be changed at the execution time. For example the memory which § provided to the input and output operations and the memory which is provided to the cp! fe Executing the processes will not be changed so that this is also known as the static relocation ote memory. Dynamic relocation The dynamic relocation is also known asthe memory which is changed and relocat atthe time of execution. So that there must be some mechanism to provide memo those are running. The mapping of the logical address into the physical address wil at the time of execution or at run time. When the memory is provided to the process then the particular address is stored by th i ‘also have a entry into the partition description table means in which partitions a process is cause vihen the process needs swapping that particular address must be reloaded. then we uses the sweeper. The sweeper is used: 1es by the proces ry those proces ll be pero he epost yn Rahul Publications = + Samal th Conangut! OPERATING SYSTEMS Main Memory Secondary Memory | Process P2 i Gout Process P2 PL goes for YO wait ile Swap out 7 | Process PL. . Ls i ‘Swapin { | r + Process P3 | ProcessPa | | Pa comes back after VO = i ‘Swap out i Process P3_-——<— | | i ‘Swapin ! Process P2 “The toial time taken by swapping process includes the time it takes to move the entire process to & seeonvary disk and then to copy the process back to memory, as well asthe time the process takes to regain main memory. Let us assume that the user process is of size will take place has a data transfer rate aroun process to or from memory will take 2048KB / 1024KB per second = 2 seconds = 2000 milliseconds Now considering in and out time, it will take complete 4000 milliseconds plus other overhead where the process competes to regain main memory. 2.1.2 Contiguous Allocation Q4. Describe briefly about contiguous allocation. Ans ; The contiguous allocation means the memory spaces is divided into the small and equal size and the diferent process uses the various partitions for running their applications process. And when @ request has 2048KB and on a standard hard disk where swapping .d. 1 MB per second, The actual transfer of the 1000K 7 om Rahul Publications Samal th CantonAnd {R14 then the process il alate the space in this the cong and ch cor rol in the Process. Means all the process wil = IP Memory of tne computer and when a. eT will request for the memory then this available Mery oF frog Memory will be allotted to him. But there wit be hich ig whi Problem when the memny Fim gq? "eed by 4 ¥ rocess is not enough for Fequirad tthe sie of Memory is less which is mown! PS Drocess. So this Problem is also reason go, t%e intemal frogmentation. The main Memory 9g {8 intemal ‘ragmentation is, all the FeSo the fixed and continuous SSS tequites large memory il not be fit into the ‘small area. Problem ig he inuee Sond bso occured in the also known as the ma then the memeny is Parts of single Memory is high mg 85 of memony then ion. So there are lem when We use the location, In thi OCS comiog 'snot availabte emory, {or allocating P8¢e3 to the 3. Me OY accesy * There MUSt be « fonnad 2 aon hy ar pened for pat Memory othe Bree Q5. How memory ig Allocated to the Process? Explain how to resolve dynamic Storage allocation Problem? Aes: (Imp, Memory Allocation and Dynamic St Allocation Problem Rahul Publications VYEAR 4) Se Maini memory usually has typ Low Memory - Operating sy, . this memory. Partito, em ei sid > High Memory - User process 7 high memory Operating system uses the foll allocation mechanism. One method of allocating contiguous. isto divide all available memory into equs Partitions, and to assign each process to their Partition. This restricts both the nami Simullaneous processes and the maximus, each process, and is no longer used Single-partition allocation In this type of alloc scheme is used to protect each other, and from system code and data treats value of smalest physical 2 whereas limit register contains ys itlesses, Each logical add ‘han the limit regitoy 5 ate hy lowing my, "hog t user processes changing op, Reloc: erating es Se Of locica SS must Multiple-pattition allocation In this type of atl Aivided into a numb where each partition When a pat Selected from the ation, main me eT Of fixed n should ory ig ed partitions cont Search the ist of hoy 9 eNoURh to 5 Portion of th, the req hole. Subs either from the b the point at which Hes Unt one ig ist “tiv the request ot ‘at hole to ation of the hog left on the Saal th ConScnnP - wit tt g, Best fit ‘Alooate the smallest hole that is big enough to satisfy the request, This saves large holes for other vs requests that may need them later, but the resulting unused portions of holes may be too oping the free list sorted can speed up the OPERATING SYSTEMS Tinall to be of any use, and will therefore be wasted. Ke process of finding the right hole 4. Worst fit Aiocate the largest hole available, thereby increasing the likelihood that t bbe usable for satisfying future request he remaining portion will mentation. Q6. Write a briefly note on fas: As processes are loaded and removed from memory, the free mem pieces, It happens after sometimes that processes cannot be allocated to met Pall size and memory blocks remains unused. This problem is known as Fragmentation. ory space is broken into little ory blocks considering their Fragmentation is of two types » — External fragmentation “Total memory space is enough to satisfy a request or to reside a process in it, but itis not contiguous, $0 it cannot be used. > Internal fragmentation Memory block assigned to process is bigger. Some portior used by another process. The following diagram shows how fragmentation can cause waste of memory and a compaction technique can be used to create more free memory out of fragmented memory n of memory is left unused, as it cannot be Fragmented memory before compaction | XN RS \ 7 af \ Nu w | 1 \ \ | | he _ 4 a fragmentation can be reduced by compaction or shuffle memory contents to place alll free ‘ory together in one large block. To make compaction feasible, relocation should be dynamic. couglt® teal fragmentation can be reduced by effectively assigning the smallest parition but large ah or the proces, Samal th Canton—EO~—-—i‘“‘C™é; LYEAR 1, & men eR 2.1.3 Paging Segmentation segmentation. Q7. Explain the mechanism of pasins rn the amount physically installed on th, (mp memory than sa sec hard that’ Vste A computer can address bina Memory and itis a section of Be aa UP to ema hy computers TAM Pag xin os an pnt TE memory, “ey: puter’s i , que in which Paging is a memory management teins an the same size called pages (size is power of 2, betwe is measured in the number of pages. ‘ vided into small fixed:sized blocks of (physical) memory cal 5 larly, main memory Is divides ge to have opium utlization of the maig en process address space is broken j bytes and 8192 bytes). The size fob ° Pro Si and the size of a frame is kept the same as that of a pa and to-void external fragmentation.-» : i Maa Meron Secondary Mery i Geese Rahul Publications {20 } Samal th ConanOPERATING SYSTEMS al adress Translation page address is called logical address and represented by page number and the offset ogical Address = Page Number + Page Offset Fame address is called physical address and represented by @ frame number and the offset. physical Address = Frame Number +Page Offset fa data structure called page map table is used to Keep track of the relation between a page of @ | process to frame in physical memory : iE Maia Memory pace Map Table e, it translates this logical address into a physical “J throughout execution of the program. loaded into any available memory .ccommodate only 5Kb at a given When the system allocates a frame to any past adress and create entry into the page table to be use When a process is to be executed, its corresponding pasks Be k frames Suppose you have a program of BKb but your memory can a point in tine, then the paging concept will come into picture hen a computer runs out of RAM, the operating system (0S) will move idle or unwanted pages of memory to secondary memory 10 free uP RAM for other processes and brings them back when needed by the program. This process continues di idle pages from the main memo! ‘when required by the program. Advantages and Disadvantages of Paging Here is a list of advantages and disadvantages of paging + luring the whole execution of the program where the OS keeps removing wy and write them onto the secondary memory and tring them back | Paging reduces external fragmentation, but stil suffer from ternal fragmentation. at ‘Rahul Publications Samal th CanSatnnI MCA fey Ny : ; : and 5 med as an efficient memory management te he Yen > Paging is simple to impler 4 frames, svapping bevomes Very easy, hig an % > Due to equal size of the pages space, so may not be good for a system having | Page table requires extra memory s rocess of segmentation, Q8. Explain about the characteristics jain al Segmentation ’ , contiguous memory allocation techn, . ‘Segmentation is enother non-cont ique. Like Paging, Segment a > In segmentation, process ct ded ind int fixed Sze > Rather, the process is divided into modules for better visualization. Characteristics > Segmentation is a variable size partitioning scheme. > In seamentation, secondary memery and main memory are divided into partitions o¢ a > The sie of partons depend onthe lnath of moles. > The partitions of secondary memory are celled as segments. Example: _ Consider a program is divided into 5 segments as First colurnn Sores the size or lent of the segment > Second column stores the base address or Samal th CanSatnnga for the above illustration, consider the segment table is nit Base st set seo? sr se Hee, > Limit indicates the length or size of the segment. > Bese indicates the base address or starting address of the segment in the main memory fn accordance to the above segment table. the segments are stored in the main memory s- po Seomento | Segment-3 Segment-2 Segment-t po ! Segment-+ Translating Logical Address into Physical * CPU atuays generates a logical address. A physical address is needed to access the ain memory, OPERATING SYSTEMS steps are followed to translate ical address Step-01: CPU generates a logical address consisting of two parts - 1 Logical Address ‘Segment Number Segment Offset Number specifies the specific m which CPU ent of the process fi 0 read the data. the 5 wants to read. segment numb din the segment rable. Then, segment offset is compared with the Emit Now, two cases are possible- Case-01: Segment Offset >= Limit > If segment offset is found to be greater than or equal to the limit, a trep is generated. Case-02: Segment Offset < Limit If segment offset is found to be smaller than the limit, then request is treated as a valid request The segment offset must always lie in the range (0, limit-1] > Then, segment offset is added with the base address of the segment. > The result obtained after addition is the address of the memory location storing the required word. Rahul Publications Samal th CanSatnnQE q Yep, Ri MCA ‘ sown steps oftanslating logical address ; \ above st dato py The following dingrar iustates th ie, | | segment Table | cr | i | Logical Address | | | Main Memer, f Tap Addressing Error Me Fig. : Translating Logical Address into Physical Address Advantages i ‘ | © The advantages of segmentation are : } Itallous to divide the program into modules which provides better visualization, > ‘Segment table consumes less space as compared to Page Table in paging. % At solves the problem of internal fragmentation, Disadvantages } ‘The disadvantages of segmentation‘are : There is an overhead of maintaining a segment table for each Process, The time taken to fetch the instruction increases since now two memory accesses are required. ‘Segments of unequal size aré not suted for wa Vo¥ VONT 2.1.4 Segmentation With Paging Q9. Explain about Segmented Paging, tas: > Process is first divided into segments an Samal th CaratOPERATING SYSTEMS yur =ll {A segment table exists that keeps track of the frames storing the page tables of segments ’ y Number ‘of entries in the segment table of a process = Number of segments that process is divided. * > The base address of the segment table is stored in the segment table base register. 5) Bach Page table contains the verious information about every page ofthe segment. The Segment Table contains the information about every segment. Each segment table entry points to a page table entry and every page table entry is mapped to one of the page within a segment. Page Table 1 Segment 1 Page Table Entrys- ———»{|_Paget «| Page Tobie Entry 2 | ~~ Page? Page Table Entry3-———*|_ Page segment Table rage een a. es Main Memory bie Entry |.” Page Table 2 ‘Segment 2 age Tle Entry ge Te eg Segment 1 7 Page Table entry 1[}-——>|_Paue Table Ent ara En] __f agree] — o_o Seament? Page Table Entry 2 age Tabet || [Page eee com segment 3 \ a 2 Page Table 3 Segment 3 \ [page tape entry 1} ———»|_P20e Page Tobie Entyy2}-——>|_Paae? Page Table entry3}———*|_P2ae? [Segment Page | _Bise ortset Logical Address. Translation of logical address to physical address The CPU generates a logical address which is divided into two parts: Segment Number and Segment Offset. The Segment Offset must be less than the segment limit. Offset is further divided into Page number and Page Ofiset. To map the exact page number in,the page table, the page number is added into the page table base. Folowing steps are followed to translate logical address into physical address | Step-01: . CPU generates a logical address consisting of three parts: 1, Segment Number 2. Page Number 3. Page Offset @ Samal th Carana rt page Numbet Page Offse' bet segment fom tie CPU wants to reads the ga, fic of that seg segment Num! ent from which CPU wants to read i if Segment Number specifies the sP&S : a Page Number specifies the spect P a Page Offset specifies the spe word O” th t CPU wants to read. ey, Step-02: spas conesonding ety foeated in the segment iahjs For the generated segment number ver ofthe frame’ string the age table of thy he Segment table provides the frame nul . segment. > The frame containing the page table {s located. re the generated page number, corresponding entry is located in the page table, > Page table provides the frame number of the frame storing the required page of the refer segment. i % The frame containing the required page is located. : Step:04: > The frame number combined with the page offset forms the requited physical address. » For the generated page offset, corresponding word is located in tlie page and read. The following diagram illustrates the above steps of translating logical address into physical addres Logica Adress Physical Address Kd [ — L_} Segment Tabi —_ Page Table {_-_4 Main temo”) Tatslaing Loge’ gacrese Into Ph hysical Ae Publications Samal th Conanwot vont ‘The > Seat correspon tpreduoes memory usage. Jes advantages of segmented paging are ment table contains only one entry 1g to each segment. , che size of Page Table is limited by the 7 segment size. |, nsales the problem of external Fagmen- tation. pisadvantages ‘Thedisadvantages of segmented paging are 4) Segmented paging suffers from internal fragmentation. The complexity level is much higher 2s compared to paging. 22.1 Demand Paging 10. What is Demand Paging? Aus: Demand Paging is the Concept in which 2 process i Copied into the Logical Memory from the Physical Memory when we needs them. A Precess ean load either Entire, Copied intothe Main Memory or the part of single Process is copied into the Memory so that is only the single Part of the into the Memory then this is also. called as the Lazy Swapping. For Swapping the Process from the Main Memory or from the Physical Memory, a Page Table must be used, The Page Table is used for Storing the Entries which Contains the Page or Process Number and also the offset Number which indicates the address of the Process where a Process is Stored and there wil also be the Special or Extra Bit which isalso Known asthe Flag Bit which indicates whether the Page is Stored into the Physical Memory. The Page Table Contains two Entries those ‘te used as valid and invalid means whether the Process is Stored into the Page Table. Or Whether the Demand Program is Stored into the Physical Memory So that they can be easily swapped. If the OPERATING SYSTEMS Requested Program is not stored into the Page Table then the Page Table must Contains the Entries as v and I means valid and invatid along the Page Number, When a user Request for any Operation then the Operating System perform the following instructions 1, Fist of all this will fetch all the instructions from the Physical Memory into the Logical Memory. 2. Decode all the instructions means this will find ut which Operation has to be performed ‘on the instructions. Perform Requested Operation. Stores the Result into the Logical Memory ‘and if needed the Results will be Stored into the Physical Memor 2.2.2 Page Replacement Q11. What is the use of page replacement algorithm? Explain about various page replacement algorithms. Aus (Imp.) Page replacement algorithms are the techniques using which an Operating System decides which memory pages to swap Out, write 10 disk when a page of memory needs to be allocated. Paging happens whenever a page fault occurs and a free page cannot be used for allocation purpose ccounting fo reason that pages are not available ar the number of free pages is lower than required pages. When the page that was selected for replacement and was paged out, is referenced again, it has to read in from disk, and this requires for VO Completion. This process determines the quality of the page replacement algorithm: the lesser the time waiting for page-ins, the better is the algorithm, ‘A page replacement algorithm looks at the limited information about accessing the pages provided by hardware, and tries to select which ages should be replaced to minimize the total Prmber of page misses, while balancing it with the coats of primary storage and processor time of the algorithm itself, There are many different page replacement algorithms. Rahul Publications Samal th Canam«1g, Reference strings are generateg 4, : Mtifi Reference String asad! ony reference. For a given ey oc The sting meme ET di te pe ene 200 cr by tracing a given S307 ne wing references by racing en se ai 00 TENCE 10 gg we need to consider pathen ay met et reference the immediate? ve a reference 1 2 PSP aay Slat ult, Page P™ « 23,215,600,1234, 76,96 never cause a page references will not fault nce of 0080885 Jing sea > For example, consider the folowing "1261200 If page size is 100, then the reference First In First Out (FIFO) algorth isthe on > — Oldest page in main memory is the o” ist replace pases 4,0,1, 0: 3 4 22 which will be selected for replacement, e zi rom the.tall and add new pages at the head > ~ Easy to implement, keep Reference String 10,22, 6 Misses: ine XK ® KKK 2 =] , : : a = 1 o 2 2}4, 2 9. |8| 3 0 ; 1 oF : ; [2] 6 6 ‘ ¢ ; : Fault Rate = 9/12 =0.75 FIFO page replacement algorithm =s_ performance is not always good. To illustrate this, consider the following example: v. Reference string: 1, 2, 3, 4, 1, 2,5, 1,2,3,4,5 IfNoof availabe frames -= 3 then the no.of page faults =9 IE Noof available frames =4 then the nof page faults =10 Here the no, of page faults increases when ve is called? . thie no, i 5 calle Belady’s Anomaly, no.of frames increases .This i 2. — Optimal page replacement algorithm Replace the page that will not be used for the longest period of time, Samal th CanSatnnOPERATING SYSTEMS vit example: ference sting 7012030423032 12017 04 Anae & 2 z zl fz dip fe 4 a a lo. qf it 3 3 3 1 q page frames Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 Noof available frames = 3 Drawback {tis difficult to implement as it requires future knowledge of the reference string. 3, Least Recently Used (LRU) algorithm Page which has not been used for the longest time in main memory is the one which will be selected for replacement. Easy to implement, keep a lis, replace pages by looking back into time. ReferenceString: 0, 2, 1, 6,4, 0, 1,0, 3, 1,21 Misses ink xxxK 0 4 4 a 2 4 ° 3 2 2] 4 2) 0) 4» |° fa 1 1 1 1 6 6 3 3 Fault Rate = 8/12 =0.67 _ LRU page replacement can be implemented using (i) Counters > Every page table entry has a time-of-use field an CPU, > The counter o1 Each time a page is referenced, copy the counter into the time~ ith the smallest counter value. d-a clock or counter is associated with the clock is incremented for every memory reference. of-use field. When a page needs to be replaced, replace the page wil 89 —@ Ta ao Samal th CanamSSM Wea sweat Second Chance Algoritn, Qe (ii) Stack jhenevet Keep a stack of page rue we fo" a page is referenced, remove sta’ the stack and put ton toP of the replace When a page needs to b re {LRU the page that is at the! 0% 2 ‘bottom | page). Use of A Stack to Record The Recent Page References 4. Page Buffering algorithm ; . Togeta processtart quid. keep @POE of free frames. > On page fault, select a page '° be replaced. > Write the new page inthe frame of free pool, mark the page table and restart the process. Most s Now waite the dirty page out of disk and place the frame holding replaced page . in free pool 5. LRU Approximation Page Replacement With each page associate a reference bit, Initially set to 0. When page is referenced, the bit is set to 1 ‘When a page needs to be replaced, replace the page whose reference bit is 0:The order of use is not known , but we know which pages were used and which were not used. Additional Reference Bits Algorithm Keep an 8-bit byte for each page ina table in memory. At regular intervals a timer interrupt transfers control to OS. The OS shifts reference bit for each page into higher- order bit shifting the other bits right 1 bit and discarding the lower-order bit. Example: If reference bit is 00000000 then the page @ (iti) (iv) Basic algorithm is FIFO When @ page has been sees reference bit. | Shey | 1f0 proceed to replace the an Page If 1 give the page a second cha, | | on to the next FIFO page, a aa, | oa | When a page gets a secong reference bitis cleared and anival Changs | 5 ime ®t to current time. ei / Hence a second chance page yay replaced until all other pages are a b Enhanced Second Chance Algoxi *e Consider both reference bit and — tb ‘There are four possible classes 1.(0,0) - neither recently usey modified Best page to replace | (0,1) - not recently used but modified | has to be written out before replaceme (1,0) - recently used but not modifies may be used again (1,1) - recently used and modified page be used again and page has to be w disk. Counting-Based Page Replacement Keep a counter of the number of refer: that have been made to each page Least Frequently Used (LFU }Alg replaces page with smallest count Most Frequently Used (MPU )Alsortt replaces page with largest count Itisbased on the argument that the pase | the smallest count was probably just in and has yet to be used. i Mere ere Gace Q12. Consider a main memory with five P| . ce frames and the following seave" «| If reference bit is 11111111 then the page page references: 3, 8, 2, 3, 9: 16? | ce a used atleast once each time period. 9,3, 6,2, 1,3. which one of the follo If the reference bit of page 1 is 11000100 1s true with re: taceme™ ane poge 2 is 01110111 then page 2 is the policies Fist lo eet ee page. * Least Recently Used (LRU)? Banal Publications (20 }- / n-First-out (FIFO) Samal th CanSatnnyr wate! Both incur the same number of page fous jg FIFO incurs 2 more page fault than LRU ¢ LAU incurs 2 more page faults than FIFO FIFO incurs 1 more page faults than LRU OPERATING SYSTEMS Ae + amber of frames = 8 FIFO ‘According to FIFO, the page which first comes in the memory will first goes out wer Pp & P BP Tow pe pb POU UP PRP Frames ames Frames | P Pe frome 2 s | fs bb Bb Pb POP OP OPPO lor b PO POP OPO OUP POPP B & Pp Iaiss7nit fies [Mss [iss [Hit tiss fait aie [oaiss ft foie Number of Page Faults = 9 Number of hits = 6 LRU ‘According to LRU, the page which has not been requested for along time will get replaced with the new one. request Pe PP lo jp ames rh PO framea bb bp bP bP P PP P b Frame 3 bb ke e PP is i fp frrame2 sf fe b bb be PP PP OP lamer bP OPO BB OP Imiss/ait ise [tiss (Miss [Hit [ss 'raiss fe Rahul Publications Samal th Conan 49 be of Page Faull Number of Page cul tree Ie Ansvergg 8 Number of Hits #6 eco th ab a of page fouls n both lady's Anomaly 4 ‘an examples smaly with ? iy QI. Explain Bel ee cement agortns, iis Seen that the (, page rr! " Dune U and oe of ames. However, Balady foung that, 5 bey ay ni fouls will gt increased with the increme,t rs Fry In the case of LR fovults will be reduced if we replacement algorithm, the frames, increase the number of page ‘This the sange behavior shoun by FIFO agri in some of the cases, This i. his i the strange 4 galled as Belady'sAnomaly Let's examine such example : ‘The reference Sng isguen 6015301401534. Letsartalyze the behavior of rpc intwo cases, Case 1; Number of frames = 3 feet} oo for fs }a tofu} 4 fof ads Fame eel eee ce Tae Frame? vfalatofo]felolols tomet{ o fo fo]stafals]ala Mesitit | Mss} ss? ss] ss] is] tis] wis] st | ae Miss | is © Number of Page Faults = 9 Gase 2: Number of frames = 4 tee} tots ta lolal, ofa 5 3 re ame 4 3 3 a 3 3 3 5 5 rane ‘Letsl sli tel pat, Frame? Phedadal, ‘lolol. o | ol Tee aly rere] mel ef oe) ele pet | HW | ey Wis | tgs Miss | ss | ms | ——L | akal Fabio Samal th Conanet puinber of Page Faults = 10 arctore, in this example, the number of faulls is increasing, by increasing the of frames hence this suffers from umber iady'sAnomealy. Belads Za thrashing 4 efi thrashing Explain the techniques QU thrashing. fot (Imp.) When a program need space larger than RAM sed space when RAM isfull, Operating System fatty to allocate space from secondary memory wipemvesieithasthat much amount of memory ‘ening to that program. This concept is called ttl memory. To Know about thrashing we first vegta know what is page fault and swapping it Page fault and swapping: We know every rogam divided into some pages, When a program pred page which is notin RAM that is called page fp Whenever a page fault happens, operating syiem wil try to fetch that page from secondary memory and try to swap it with one of the page in RAM. Thisis called swapping. I this page fault and then swapping happening very frequently at higher rate, then operating system has to spend more time to swap these pages. Ths state is called thrashing. Because dbs, CPU utilization is going to be reduced. Tmrasning degree of mutuprogramming OPERATING SYSTEMS Effect of Thrashing 1 thrashing starts, operating system ‘er Global page replacem- Local page replacement Whenever tries to apply eithi ent Algorithm or algorithm Global Page Replacement replacement can acces bring more pages whenever thrashing found, But what actually will happen 's ddue to this, no process gets enough frames and by fecal thrashing wil be increase more and more, SO global page replacement algorithm is not suitable when thrashing happens: Local Page Replacement Unlike global page replacement algorithm, Tocal page replacement will select pages which only belongs to that process. So there is a chance to reduce the thrashing. But itis proven that there are many disadvantages if we use local page replacement. So local page replacement is just aalemative than global page replacement in thrashing scenario. Techniques to Handle Thrashing Working Set Model This model is based on the above-stated concept of the Locality Model. ‘The basic principle states that if we allocate enough frames to a process to accommodate its current locality it will only fault whenever it moves to some new locality. Butif the allocated frames are lesser than the siz of the current locality, the process is bound to thrash. According-to this model, based on a parameter A the working set is defined as the set of pages in the most cent ‘ page references. Hence, bil the actively used pages would always end up being a part of the working set. ‘The accuracy of the working set is dependant on the value of parameter A. If A is too large, then working sets may overlap. On the other hand, for smaller values of A, the locality might not be covered entirely. IfDis the total demand for frames and is the working set size for a process i, Since global page 5 to bring any page, ittries to 93 Ce Rahul Publications 1 Samal th CaranMCA @ ; ~ If there are en ai a oa S - ses can be loaded in the met at sizes exceeds the availability of fe ioe of the processes have to be suspen¢ 1. This technique prevents threshing ae ensuring the highest desree programming possible. Thus i usisation. 2. Page Fault Frequency 7 i threshing ‘A more direct approach to handle s is the-one that uses Page Fault Frequency concept. | | NI = “The problem essociated with Thrashing s the hhigh page fault rate and thus, the concept here is to control the page fault rate Pagetaot te If the page fault rate is too high. i indicates that the process has too few frames allocated to it On the contrary, a low page fault rate indicates that the process has too many frames Upper and lower limits can be established on the desired page fault rate as shown in the diagram. the page fault rate falls below the lower limit, frames can be removed rom the proces. Sina if the page fault rate exceeds the upper limit, more snumber of frames can be allocated to the process. Baa Pabicaion (ep YEAR ther words, the graphicay tn wuld be Kept limited to yh, Ate formed in the given diagram,“ "eta, i fault ere too. ifthe page fault rate ig, He then some of the proces ra and frames allocated to gp can suspen to other processes, The
$12 Byte 10th 15th 11th. 30th L File aes Sequential Access 1 Sector ——> 512 Byte 1 Sector Hard Disk Most of the operating systems access the file sequentially. In other words, we can say that most of the files need to be accessed sequentially by the operating system, In sequential access, the OS read the file word by word. A pointer is maintained which initially points to the base address of the file. If the user wants to read first word of the file then the pointer provides that word to the user and increases its value by 1 word. This process continues till the end of the file, Modern word systems do provide the concept of direct access and indexed access but the most used method is sequential access due to the fact that most of the files such as text files, audio files, video files, ete need to be sequentially accessed. 2. Direct Random Access ‘The Direct Access is mostly required in the case of database systems. In most of the cases, we need fitered information from the database. The sequential access can be very slow and inefficient in such eases, Suppose every block of the storage stores 4 records and we know that the record we needed is stored in 10th block. In that case, the sequential access will not be implemented because it will traverse all | the blocks in order to access the needed record. Direct access wil give the required result despite ofthe fact that the operating system has to perform Some complex tasks such as determining the desired block number. However, that is generally implemented _ Mdatabase applications. 97 ood Rahul Publications Samal th CanSatnnMCA Database System ee xd then an index can be assigned to a group of certain r, re Foe ene nae way indekThe lndex nothing but fre addiess Fecord in the file. . © Tin dex accessing, searching in a large database became very quick and easy but we need to hag ‘sme extra space in the memory to store the index value. Q4:° What is file protection? Explain various types of file access control techniques. (imp) Protedtion : » Files must be kept safe for reliability (against acidental damage), and protection (against deioens © malicious access.) The former is usually managed with backup copies, This section discusses ts ‘ater. > One simple protection scheme isto remove all access toa file. However this makes the file unussb': ‘So some sort of controlled access must be arranged, ‘Types of Access > The following low-level operations are often controlled: * Read - View the contents ofthe file + Write - Change the contents of the file. * Execute - Load the fle onto the CPU and fellow the instructions contained therein * Append - Add to the end of an existing fl, + Delete - Remove a file from the system, * Uist View the name and other atibutes of files on the system, Ca} { Rahul Publications {28} EE Samal th Cantonna igher-level operat ae level operations, such as copy, can generally be performed through combinations of the ‘access Control y One approach is to have complicated Access C \ i ; ‘ontrol Lists, At access is allowed or denied for specific users or groups. aa ae + The AFS uses this system for distributed access. + Cone sve fins aual, bt maybe compat particularly when the specific users involved are unknown. ( AFS allows some wild cards, so for example all users on a certain remote system may be trusted, or a given username may be trusted when accessing from any remote system. } UNIX uses a set of 9 access contol i, in three grou of thee, These correspond to R, W, and X iesons for each of the Owner, Group, and Others. The RWX bits control the following privileges for ordinary files and directories: Bit Files Directories | Read (view) file contents Read directory contents. Required to get a listing of the directory. W | Write ( change ) file contents, Change directory contents, Required to create or delete files. “Access detailed directory information. Required to get a long tsing, orf access any specific fle in the directory. Note that x. | Execute fle contents asa program. | ifa user has X but not R permissions on a dneeton they can sill access specific files, but only if they already know the ame of the file they are trying to access. In addition there are some special bits that can also be applied: « Theset user ID ( SUID ) bit and/or the set group ID ( SGID } bits applied to executable files temporarily change the identity of whoever runs the program 0 match that of the owner / group of the executable program. + The sticky bit on a directory modifies write permission, all which they are the owner. «The SUID, SGID, and sticky bits are indicated with an S, S, and T in the positions for execute permission for the user, group, and others, respectively. If the letter is lower case, ( s, 5, ts then the comgsponding execute permission isnot also given. Ifit is upper case, ( S, S, T ), then the corresponding execute permission IS given. «The numeric form of chmod is needed to set these advanced bits. { pbg staff 31200 Sep 3.08:30 intro.ps 5 pbg staff 512 Jul8 09.33 _ private 2 pbg staf 512 Jul809:35 doc! 2ywg. student’ 512 Aug3 14:13 _student-proj/ Tpbg staff 9423 Feb 242012 progam i pbg staff 20471 Feb 24 2012, program 4tag faculty 512 Jul31 10:31 | Iib/ 3pbg staff 1024 Aug 29 06:62 mail Gronmwxrwx 3pog staff 512 Jul809:35 tes Sample permissions in a UNIX system. lowing users to only delete files for (99 Rahul Publications Samal th CanSatnnMcA 2 Five System IMPLEMENTATION 3.2.1 File System Structure Q5. Explain the concept of file system structure. (Imp.) File System provide efficient access to the disk by allowing data to be stored, located and retrieved in a convenient way. A file System must be able to store the file, locate the file and retrieve the file. Aus Most of the Operating Systems use layering approach for every task including file systems. Every layer of the. file system: is responsible for some activities. « * The image shown below, elaborates how the file system is divided in different layers, and also the functionality of each layer. Application Programs Logical File ! System | TT JL ~~ |File Organization ° Module jasic File System [ VO Controt — TT L Devices LEAR 4) ' ue Rs < > When an application program 9, i Sy the first request is dire ed tg gts ji log, fi | system. The logical file systeny bic | Meta data ofthe fle and direeya™2ng | If the application program doesn | required permissions of the fle thon He | will throw an error. Logical file pH Hist verify the path to the file, tems = > Generally, files ate divided into vation, | blocks. Files are to be sto-ad inthe na Bea and to be retrieved from t ¢ hard gic disk is divided into various tracks ang seagt Therefore, in order to store and retreys files, the logical blocks need to be mapyat® physical blocks. This mapping is done by p° organization modi. Its also responsi. free space management. % Once File organization module decided wha, physical block the application program need, it passes this information to basic file systen The basic file system is responsible for issuing the commands to YO control in order to fers those blocks. gc VO controls contain the codes by using whic: itcan access hard disk. These codes are know as device drivers. I/O controls are al responsible for handling interrupis. Q6. Explain about file system implemen. tation techniques : Ans + * File systems store several important dat: structures on the disk + A boot-control block, (per volume “a.k.a. the boot block in UNIX the partition boot sector in Windo contains information about how to b: the system off of this disk. This « generally be the first sector of t!» volume if there is a bootable syst loaded on that volume, or the block be left vacant otherwise. * A volume control block, (per volur aka. the master file table in UN” orthe superblock in Windows, wh contains information such .as Rahul Publications i Samal th Caratoe partition table, number of blocks on each filesystem, and pointers to free blocks and free FCB blocks. ‘A directory structure ( per file system ) containing file names and pointers to corresponding FCBs, UNIX uses inode numbers, and NTES uses a master file table. The File Control Block, FCB, (per file ) containing details about ownership, size, permissions, dates, etc, UNIX stores this information in inodes, and NTFS in the master file table as a relational database structure. > There are also several key data structures stored in memory: An in-memory mount table. An in-memory directory cache of recently accessed directory information. A system-wide open file table, containing a copy of the FCB for every currently open file in the system, as well as some other related information. A per-process open table, containing a pointer to the system open file table as well as some other information. When a new file is created, a new FCB is allocated and filled out with important information regarding the new file. The appropriate directory is modified with the new file name and FCB information. When a file is accessed during a program, the opent ) system call reads in thé FCB information from disk, and stores it in the system-wide open file. table. An entry is added to the per- process open file table referencing the system-wide table, and an indexinto the per-process table is returned by the ‘open( ) system call. UNIX refers fo this index as a file descriptor, and Windows refers to it as a file handle. If another process already has a file open when a new request comes in for the same file, and it is sharable, then a counter in the system-wide table is incremented and the per-process table is adjusted to point to the existing entry in the system-wide table. When a file is closed, the per-process table entry is freed, and the counter in the system-wide table is decremented. If that counter reaches zero, then the system wide table is also freed. Any data currently stored in memory cache for this file is written out to clisk if necessary. Partitions and Mounting yi v Physical disks are cor smaller be combined into larger unit commonly done for RAID installations and is left for later chapters. Partitions can either be user’ as raw devices or they can be formatted to !.old a file system mmouly divided into ‘They can also called partition but that is most Raw partitions are general’ used for swap space, and may also be \: ed for certain programs such as database that choose to manage their own disk storaye system. The boot block is accessed as part of a raw partition operating system being loaded. Modern boot programs understand multiple OSes and filesystem formats, and can give the user a choice of which of several available systems to boot. The root partition cont and at least the key portions of the OS needed to complete the boot process. At boot time the root partition is mounted, and control is transferred from the boot program to the kernel found there. Continuing with the boot process, additional filesystems get mounted, adding their information into the appropriate mount table structure. Filesystems may be mounted either automatically or manually. In UNIX @ mount point is indicated by setting a flag in the in- memory copy of the inode, so all future references to that inode get re-directed to the root directory of the mounted filesystem. by the boot program prior to any 1s the OS kernel Rahul Publications Samal th CanSatnnly EAR Is gage .o multiple different filesystem, the entire space, including 4, ingle filesystem, and certainy Vda common interface t ‘ode ) for files across ique only across @ SH Virtual File Systems > Virtual File Systems, VFS. provide @ adltion, it provides for a unique tent | filesystems of diferent ypes.( UNIXinodes are cany across networked file systems.) > The VES in Linux is based upon four key object types: +The inode object, representing an individual file The file object. representing an open file The superblock object, representing 2 fi representing a directory entry. + of common functionalities for each fl lesystem. 7 The dentry object, > Linux, VFS provides a se accessed through a table. 9.2.2 Allocation Methods Q7.."Explain different file allocation methods. Ana: ‘There are various methods allocation method will significantly affect the performance and ef provides a way in which the disk will be utilized and the files will be accessed. There are following methods which can be used for allocation. llesystem, using function poi which can be usd to allocate diskspace tothe file. Selection ofan appropra: fficiency of the system. Allocation met 1. Contiguous Allocation. 2. Linked List Allocation 3. FAT 4. Indexed Allocation Scheme 5. 6. 7. « Linked Indexed Allocation Multilevel Indexed Allocation Inode 1. Contiguous Allocation If the blocks are allocated to the file in such a way that all the logical blocks of the file 9° contiguous physical block in the hard disk then such allocation scheme is known as contiguous alloca® In the image shown below, there are thre fils inthe directory. The starting block and the len each fle are mentioned in the table. We can check in the table that the contiguous blocks are assis" each file as per ils need. Rahul Publications Samal th CanSatnnOPERATING SYSTEMS Fusame | san | toon | “aescee’ adc test video mos ftp docx Hard Disk Directory Contiguous Allocation Advantages 1, Itis simple to implement, 2, We will get Excellent read performance. 43, Supports Random Access into files. Disadvantages 1, The disk will become fragmented. 2, Itmay be difficult to have a file grow. 2, Linked List Allocation . Linked List allocation solves all problems of contiguous allocation. Ih linked list allocation, each file isconsidered 2s the Linke ist of disk blocks. However, the dss blocs ‘allocated to a particular file need acm be contiguous on the disk, Each disk block allocated to file contains 2 pointer which points to the ext disk block allocated to the same file od File Block File Block File Block File Block 1 2 3 4 Physical Block = 7 2 - 10 8 Advantages 1. There is no extemal fragmentation with li Any free block can be utilized inorder to satisfy the file block requests 2. 3. File can continue to grow as long as the free blocks are available. 4 Directory entry will only contain the starting block address. (103) Rahul Publications inked allocation. Samal th Conan ADinadvantagen 1. Random Access is not provide! Hox Polnters requiie some space tn the disk bes ate broken otherwise the fle will get fest the Hinkeed ist mist not be broken BE CoG 3. Any of the point 4. Need to traverse each block, File Allocation Table (PAT) ‘The main disadvantage of inkect list allocation Is that the Provided, In order to access a block, we need! to access all its pre 5 ed list allocation, tn this scheme, File Allocation Table overcomes this drawback of linked Uist allocation. In ME, a ile fable is maintained, which gathers all the disk block links, The table has one entry for each cig, bag Is indexed by block number File allocation table needs to be cached in order to reduce the number of head seoks head doesn't need to traverse all the disk blocks in order to aecess one successive block, Ranclom access to a partic ‘lar by evious blocks, lah. Nov, It simply accesses the file allocation table, reac the desired block entry from there and Access, block, This isthe way by which te random acces is accomplished by using FAT Iti used by MS pg Dre-NT Winclows versions, a by 0 | « Directory Entry 1| 3 } | 7 } | ramepra| 4 2a i | } | | | start pices ‘ a < 4 10 | -| i | oe. 5 | | k 10 1 rt File Allocation Table Advantages 1, Uses the whole disk block for data, 2. Abad disk block doesn't cause all successive ‘blocks lost. 3. Random access is provided although its not too fast, 4. Only FAT needs to be traversed in éach file operation. Rahul Publicattons 104 Samal th Canton
You might also like
Unit 3
PDF
No ratings yet
Unit 3
7 pages
08 Memory Management Strategies (Autosaved)
PDF
No ratings yet
08 Memory Management Strategies (Autosaved)
47 pages
Memory Management Updated
PDF
No ratings yet
Memory Management Updated
115 pages
Unit-5: Memory Management
PDF
No ratings yet
Unit-5: Memory Management
87 pages
Os MM - 021727
PDF
No ratings yet
Os MM - 021727
19 pages
Memory Management - Consider Important
PDF
No ratings yet
Memory Management - Consider Important
141 pages
Memory Management in OS
PDF
100% (1)
Memory Management in OS
76 pages
Lecture 05
PDF
No ratings yet
Lecture 05
50 pages
UNIT-4 - Memory Management
PDF
No ratings yet
UNIT-4 - Memory Management
65 pages
Operating Systems: Memory Management
PDF
No ratings yet
Operating Systems: Memory Management
32 pages
Main Memory
PDF
No ratings yet
Main Memory
63 pages
Memory Management
PDF
No ratings yet
Memory Management
33 pages
Memory Management1
PDF
No ratings yet
Memory Management1
58 pages
CSI3131 Mod 7 Mem Manag
PDF
No ratings yet
CSI3131 Mod 7 Mem Manag
77 pages
ch8- new
PDF
No ratings yet
ch8- new
57 pages
OS UNIT III Material
PDF
No ratings yet
OS UNIT III Material
24 pages
Operating Systems: Memory Management
PDF
No ratings yet
Operating Systems: Memory Management
35 pages
Ch05 Memory MGT
PDF
No ratings yet
Ch05 Memory MGT
40 pages
UNIT-4
PDF
No ratings yet
UNIT-4
66 pages
New OSY PPT - Unit 5.1
PDF
No ratings yet
New OSY PPT - Unit 5.1
25 pages
OS Unit 4
PDF
No ratings yet
OS Unit 4
105 pages
OS Mod4
PDF
No ratings yet
OS Mod4
170 pages
OS4
PDF
No ratings yet
OS4
45 pages
Unit IV-OS
PDF
No ratings yet
Unit IV-OS
28 pages
Memory Management
PDF
No ratings yet
Memory Management
56 pages
Lect 5
PDF
No ratings yet
Lect 5
31 pages
Main Memory: Basic Hardware
PDF
No ratings yet
Main Memory: Basic Hardware
16 pages
Unit 4 Part 1 Updated 1
PDF
No ratings yet
Unit 4 Part 1 Updated 1
13 pages
7 Memory Management
PDF
No ratings yet
7 Memory Management
57 pages
Lecture 07 - Memory Management
PDF
No ratings yet
Lecture 07 - Memory Management
87 pages
Unit 5 OS
PDF
No ratings yet
Unit 5 OS
48 pages
L11 MMU and VirtualMemory
PDF
No ratings yet
L11 MMU and VirtualMemory
92 pages
Week
PDF
No ratings yet
Week
73 pages
MEMORY MANAGEMENT
PDF
No ratings yet
MEMORY MANAGEMENT
150 pages
memory management
PDF
No ratings yet
memory management
46 pages
OS-UNIT-IV
PDF
No ratings yet
OS-UNIT-IV
41 pages
Os Unit - 4
PDF
No ratings yet
Os Unit - 4
25 pages
Memory Management Unit 5
PDF
No ratings yet
Memory Management Unit 5
54 pages
3rd Os
PDF
No ratings yet
3rd Os
5 pages
Memory Management
PDF
No ratings yet
Memory Management
57 pages
Cs8493unit3 Original PDF
PDF
No ratings yet
Cs8493unit3 Original PDF
128 pages
ICS 143 - Principles of Operating Systems
PDF
No ratings yet
ICS 143 - Principles of Operating Systems
52 pages
OS(UNIT-4) (1)
PDF
No ratings yet
OS(UNIT-4) (1)
40 pages
Osmod 3
PDF
No ratings yet
Osmod 3
14 pages
Unit 5 Memory Management
PDF
No ratings yet
Unit 5 Memory Management
51 pages
CS8493_Unit_3-converted
PDF
No ratings yet
CS8493_Unit_3-converted
128 pages
CS8493_Unit_3
PDF
No ratings yet
CS8493_Unit_3
128 pages
5Chapter Five- Memory Management(0) (5)
PDF
No ratings yet
5Chapter Five- Memory Management(0) (5)
38 pages
CSC 453 Operating Systems: Memory Is A Resource
PDF
No ratings yet
CSC 453 Operating Systems: Memory Is A Resource
23 pages
Spos Unit 6
PDF
No ratings yet
Spos Unit 6
133 pages
Ch. 3 Lecture 1 - 3 PDF
PDF
No ratings yet
Ch. 3 Lecture 1 - 3 PDF
83 pages
Osunit 3
PDF
No ratings yet
Osunit 3
72 pages
MOS 3e 03 2010
PDF
No ratings yet
MOS 3e 03 2010
89 pages
9th Lecture OS
PDF
No ratings yet
9th Lecture OS
40 pages
Memory Management: Presented By:-Mr. P C Kaufa ND Computer Architecture and Servicing
PDF
No ratings yet
Memory Management: Presented By:-Mr. P C Kaufa ND Computer Architecture and Servicing
38 pages
oslecture10-13
PDF
No ratings yet
oslecture10-13
80 pages
Main Memory Management
PDF
No ratings yet
Main Memory Management
7 pages