0% found this document useful (0 votes)
5 views8 pages

Chapter 3

The document discusses various memory management schemes used in operating systems, including contiguous and non-contiguous memory allocation, as well as the challenges of fragmentation. It explains the concepts of virtual memory, paging, and segmentation, highlighting their advantages and disadvantages. Additionally, it addresses the importance of efficient memory allocation and the impact of fragmentation on system performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Chapter 3

The document discusses various memory management schemes used in operating systems, including contiguous and non-contiguous memory allocation, as well as the challenges of fragmentation. It explains the concepts of virtual memory, paging, and segmentation, highlighting their advantages and disadvantages. Additionally, it addresses the importance of efficient memory allocation and the impact of fragmentation on system performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
ch3iMemory Management Le Use of swapping is feasible in time-sharing systems because time-sharing supervisor can estimate when a program is likely to be scheduled next. It can use this estimate to ensure that the program is swapped in before its turn on the CPU. Note that swapping increases the operating system expenses duc to the need to ___ perform swap-in and swap-out operation. . 33 MEMORY MANAGEMENT SCHEMES TI irnony fiio cation ‘(There are many different: memor c management scheme for a specific management schemes. Selection of a memory g stem depends on many factors, especially the hardware design of the system. A few of the schemes are given below with diagram] ingle Partt Allocation nm MEMORY MANAGEMENT SCHEMES [l]Program Initiation: In a contiguous memory allocation, an OS must decide how to allocate memory to different programs. This basic approach followed is to program the memory and allocate a memory partition to each program. ( 2) Contiguous Memory Management; (AMocxtion) [ This approach uses the classical program model wherein cach program is allocated a single contiguous area in memory. The memory allocation decision is made statically, ie. before execution of a program begins. Example of contiguous memory allocation like... ] SUPERVISOR Pl Pp: CONTIGUOUS MEMORY ALLOCATION Scanned with CamScanner’ ng Systems Concepts with Unix/ Ling op 1 eT eee approach. The memory is divided jp, ying ‘i management apy emory is divided in, [ This is the si ee Paoas parts for operating system progr ( calles two sections, is P foverans monitor) ‘and second section is for user program, SUPERVISOR | (4)Single Parti / | User Program SINGLE PARTITION ALLOCATION METHOD { Here, only one process (program) resides in memory at a time. The Eee tobe executed is loaded into the free space area of the memory; in general, a part ol the memory space will be unused. Early MS-DOS systems operated in this way ‘The main drawback of this allocation is an External Fragmentation. / (2)Multiple Partition Allocation Method : There are two methods to manage this scheme. _fa] Fixed / Static Partition memory Allocation : On a multiprogramming environmeat, several program reside in primary memory at a time and the CPU passes its control rapidly between these programs. Here, the memory can te divided into a number of separate fixed 320 areas, each of which can hold one process. When a program terminates, that 20 partition is free for another program waiting in a queue. The main disadvantage of this allocation is an Internal Fragmentation. | ox) | Pox-t (20x) [SUPERVISOR foe uned ~2(4or [PL mee -3 (ep 2 P3 JE j -4 (tox) [Bree 5 (sor) 1T4 (oO FRED / STATIC PARTITION MEMORY ALLOCATION ariable / Dynami iti | a thie sppynamie Partition memory Allocation : Nn. reauirement. Hence no internal fra entatior wever, exter 1 i : agmentation exists. Hov aecommodate a job step] ®xistence of holes, which are too small! A ssume that we have 640K of ™main-memory operating system et . Program, There 4 iueue Applying FCPS scheduling ye oes available in which 40K is occupied i Waiting for me 4 aj immediate] ling policy, Py; ‘emory allocation in cis cet! allocated in memory. Proce eee8S Ls Provese2 and process 8 cP there ig a ty. Pr Only 600-550 = 50K lett for seo 4 CARMOE be allocated in rogeay bee Scanned with CamScanner Ch.3 : Memory Management 3.7, | SUPERVISOR ProcessS Piece User 300K 10K 260K 200K program ° 9 PERV SUPERVIS se{_ SUPERVISOR sog{_ SUPERVISOR sux Process] zanx |_Free(200K) ess4__| ¢ (50K) seox | Process? % | Process > sx |_Process3 senx | Process3 vnc Free0K) ‘vox | Free(30) ‘ox Hain Hern oy 20 ‘| SUPERVISOR i n 30 eS) es vex SU sog|_SUPERVISOR oy tas J2(308) 30k Process4 Process4 yh 20 T3 (Hoe) HO Free (30K) TH (or) 2ok Process2 —> ProcessS Free(150K) Free a tok VARIABLE / DYNAMIC PARTITION MEMORY ALLOCATION. Let us assume that after some time Process] is terminated, releasing 200K of memory space. After than the control is returned to the process queue and . next process4 is swapped, in the memory. After than Process] and Process3 going terminated and release 100K memory but Process5 cannot be put up due to external fragmentation, After the swapping out of process2 due to termination, process 5 will be loaded for execution, Here, external fragmentation may be cither a minor or a major problem in some cases, Dynamic memory management requires lots of operating system space, time, and complex memory management algorithm and bookkeeping operation. One advantage with variable partition is that memory utilization is generally better than fixed size partitions, since partitions are created accordingly to the size of process. ae Scanned with CamScanner Operating Systems Concepts with Unix/ Lin, 3.8 coed i ‘areas or in another yw, re ene Ee ‘anusual space in memory rim another win rey) . (Fragmentation means an poet puter eystem. va memory resence of unusable | oon Jragmentations avises in system memory F mentation : . | + can go free, calle . External Fragmentation. It arises when free peer ut eee ireaned eno amall to be allocated to programs. Example like...) SUPERVISOR Program 1 | Program 2 [FREE Program 3 ™ External Fragmentation —_ FRE) (2)Internal Fragmentation : [Internal fragmentation means unused internal area of program in memory, arises when memory allocated to a program is not fully utilized by it.) VISOR er FREE a ™ Taternal Frogmentation Program 2 (3)Memory Fragmentation Handling Techniques : Fragmentation means remain unused area of a memory. Which is altes reallocated for specific program. Two approaches can be used to avoid ! memory fragmentation problem. > Merging free areas /Memory Compaction : In this approach memory allocations are changed such that all free areas? be combined into a single free area called the merged free area. This is by allocating alternative memory areas to programs and data existing it’ allocated a ; : allocated areas of memory. All fresh allocations are made from the met In another We . free mea okt an OS may attempt to combine all free areas into 2% pe ine some adjoining free areas into a free area of Scanned with CamScanner ¢ Systems Vonvere = ‘ing! jicies are considered best. B,.\ rt yy contrast, worst fit doesn't tooR i a vmunimize the unused could create q 4 “cut as it first appears. ly prove to be the most effective, Operatin 3.10 a Tn the given policies, Best-fit and W orst fit p! appear that minimum space 3S Te promising. However, worst fit, in try aa too small to be useful. So it is not as © In the practice, the best fit and first fit general Program L Program 2 Proaram 6 foo — ” 150k Program 3 a First Fil Hole / Partition remains 150K Ready Queue 300K 200K Program 5 ~ Warst-fit, Hole / Partition remains 250K _ ee? 400K ALLOCATION SELECTION FOR PROGRAM 6 In the diagram shows typical situation where a new process is to be loaded and, choice of spaces is available to the loader. The effect on the choice using each three algorithms can be seen. 45] Non-Contiguous Memory Management: (Allocation) Here, program allocated in non-contiguous area of memory. Example of no contiguous memory allocation like... } SUPERVISOR | P2 FREE NON-CONTIGUOUS MEM ; ORY AVirtual Memory ; MHOCATION The common problem b U r efore few years a ° ars ago for progr: Y os.] us] (Secondary Storage) and Swappedin ant revs ee oa swapped-out of memory Scanned with CamScanner Ch.3 : Memory Management 3.11 Virtual memory is memory management scheme that allows the execution of processes that may not be completely in main memory. In other words, virtual memory allows execution of partially loaded processes. As a consequence user programs can ke larger than the physical memory.]In the another definition, (virtual memezy is a memory management technique, which does splitting of a program into nmber of pieces as well as swapping. ] The basic idea behind virtual memory is that the combined size of the program, data and stack may exceed the amount of physical memory. The OS keeps those parts of the program in the memory, which are required during execution and the rest on the Secondary Storage (Hard Disk). (Two fundamental approzches used in implementing virtual memory systems are. — Paging + Segmentation] > Advantages — The CPU is utilized more fully. Pages of many different programs can reside in main storage (Also called Physical / Primary Memory or RAM) at a time, which will cause increase throughput (or also called Fast Processing). + The programmers no longer need to worry. themselves about primary storage size limitation when writing programs. > Disadvantages : —» More CPU time is required for Reading and Writing page, also in page-in and page-out from main storage. + Additional storage is required to hold the tables that keep path of pages and to hold it also in a virtual storage. — Another potential problem is thrashing, which occur when one or more pages of a program have (9 be paged-in and paged-out of primary storage frequently during execution of the program. Thrashing could reach a point where the CPU is spending too much time on paging In and Out as compared to time spent on program execution. The problem of thrashing occurs because of control statements (like goto statement) in a program — Page fault, segment fault are also limitations of Virtual Memory. @ Paging: VWWtucd Temony Using Paging Paging is a memory management scheme. Basically, the pb conceptually divided into a number of fixed size slots called it “Page Frames’ or “Page Blocks”, each capable of holding exactly one page of a program. Thus, each block also has a size of n words. The virtual address space of a process is also divided into fixed blocks of the same size, called it “Pages” : Scanned with CamScanner ne 3.12 Operating Systems Concepts with Unix / Ling (In another words, a program can be divided into fixed blocks. Each blocks. of program called Page. | Each logical address used in a program is considered to be a pair (Pi,Wi), Whe Di is a Page number and Wi is a Number of words in Pi page. Allocation“ Ionia of crass, Of finding a sufficiont number of unused page frames fy loading of the requesting process pages, lalWorking with Address Translation Unit (ATU) : An address translation mechanism is used to map virtual pages to thei, al counter parts, © (PMT) onty Memory, Tf Pt Page Pj indicates whethe! sin, °S Not exist in memory whe! 1 © ing 3 interrupt, also called a pat Scanned with CamScanner : Memory Management 24 — Memory management ao! with page replacement algorithms becomes slightly @) Segmentation: Vistuat enon Segmentation is a Using Aeqmentation memory management scheme, which support " Begmer isa mer : pports programmers words. Rather 7eexammers never think of their programs as a linear array of lities, ncn Chey think of their programs as a collection of logically related entities, suc 7 such as subroutines or procedures, functions, global or local data areas, stack eta] Subroutine/ Procedure Funetion VY Segment 0 Segment 2 Stack Segiment3 Global Local Data . Data Area Area Segment 1 Segment 4 Logical Address Space {Segments are formed at program translation time by grouping together logically “related entities. Formations of these Segments differ from one compiler to another. A PASCAL compiler might crete separate segments for (1) code of each procedure (2) global data (3) local data or variable (4) stack for calling procedure and storing its parameter. & A FORTRAN compiler, for example, might create a separate segment for each common block. Arrays might be formed as separate segments. To simplify implementation procedures, each segment in a program is numbered and referred to by a segment number rather than a segment name. In segmented system, components belonging to a single segment reside in one contiguous area but different segments belonging to the same process occupy non-contiguous area of physical memory because each segment is individually relocated.[ _~ > Address Translation in a Segmented System : ‘An important component of address mapping in a segmented system is a segment table. Its use is illustrated in the following diagram. A virtual (logical) address consists of two parts- a segment number and an offset into that segment. The segment number provided in the virtual address Scanned with CamScanner

You might also like