A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 1

Size: px
Start display at page:

Download "A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 1"

Transcription

1 Sub Code:CS2257 Dept: CSE Sub Name: Operating Systems Sem/Year:IV/II UNIT III: Storage Management PART A (2 Marks ) 1. What do u mean by swapping technique? (AUC JUNE2009) A process needs to be in memory to be executed. However a process can be swapped temporarily out of memory to a backing tore and then brought back into memory for continued execution. This process is called swapping. 2. Why page sizes are are always powers of 2? (AUC NOV/DEC 2008) Page size is always a power of 2 because all addresses are binary and are divided into page (or) page frame number and offset. 3. Define TLB. (AUC ARR/MAY2011) It is a special,small,fast lookup hardware cache used to solve a problem in swapping. 4. Define dynamic loading. To obtain better memory-space utilization dynamic loading is used. With dynamic loading, a routine is not loaded until it is called. All routines are kept on disk in a are locatable load format. The main program is loaded into memory and executed. If the routine needs another routine, the calling routine checks whether the routine has been loaded. If not, the relocatable linking loader is called to load the desired program into memory. 5. Define dynamic linking. Dynamic linking is similar to dynamic loading, rather that loading being postponed until execution time, linking is postponed. This feature is usually used with system libraries, such as language subroutine libraries. A stub is included in the image for each library routine reference. The stub is a small piece of code that indicates how to locate the appropriate memory-resident library routine, or how to load the library if the routine is not already present. 6. What are overlays? To enable a process to be larger than the amount of memory allocated to it, overlays are used. The idea of overlays is to keep in memory only those instructions and data that are needed at a given time. When other instructions are needed, they are loaded into space occupied previously by instructions that are no longer needed. 7. Define logical address and physical address. An address generated by the CPU is referred as logical address. An address seen by the memory unit that is the one loaded into the memory address register of the memory is commonly referred to as physical address. 8. How do you limit the effect of thrashing? (AUC ARR/MAY2011) To limit the effect of thrashing we can use local replacement algorithm. With Local replacement algorithm, if the process starts thrashing, it cannot steal frames from another process and cause the latter to thrash as well. The problem is not entirely solved.thus the effective access time will increase even for the process that is not thrashing 9. What is address binding? (AUC NOV2010) A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 1

2 Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme. 10. What do you mean by page fault? (AUC NOV 10,MAY 12). During address translation, if valid invalid bit in page tableentry is 0 page fault. 11. What is the advantage of demand paging? (AUC MAY/JUNE 2012 ) Bring a page into memory only when it is needed. 1. Large virtual memory. 2. More efficient use of memory. 3. Unconstrained multiprogramming. There is no limit on degree of multiprogramming. 12. Define lazy swapper. Rather than swapping the entire process into main memory, a lazy swapper is used. A lazy swapper never swaps a page into memory unless that page will be needed. 13. Define effective access time. Let p be the probability of a page fault (0 p 1). The value of p is expected to be close to 0; that is, there will be only a few page faults. The effective access time is Effective access time = (1-p) * ma + p * page fault time. a : memory-access time 14. Differentiate a page from a segment. (AUC ARR/MAY2010) In paging, memory is divided in to equal size segments called pages whereas memory segments could vary in size (this is why each segment is associated with a length attribute). Sizes of the segments are determined according to the address space required by a process, while address space of a process is divided in to pages of equal size in paging. Segmentation provides security associated with the segments, whereas paging does not provide such a mechanism. 15. What is meant by thrashing? Give an example. (AUC ARR/MAY2010,NOV 2007) If the process is spending more time in paging than executing is called as thrashing. For example, if two nodes compete for write access to a single data item, it may be transferred back and forth at such a high rate that no real work can get done ( a Ping-Pong effect ) 16. What are the various page replacement algorithms used for page replacement? FIFO page replacement Optimal page replacement LRU page replacement LRU approximation page replacement Counting based page replacement Page buffering algorithm. 17. What is page frame? (AUC NOV/DEC 2011) The physical address space is likewise divided into page frames. The MMU is responsible for maintain a map of pages to page frames. A page frame will be the same size as a page, A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 2

3 and it will have the same page alignment. This simplifies the mapping the MMU must maintain explicitly only a map between the pages and page frames. 18. What are the major problems to implement demand paging? The two major problems to implement demand paging is Developing a. Frame allocation algorithm b. b. Page replacement algorithm 19. What is a reference string? An algorithm is evaluated by running it on a particular string of memory references and computing the number of page faults. The string of memory reference is called a reference string. 20. What is internal fragmentation? (AUC NOV/DEC 2011) The unusable memory is contained within an allocated region. This arrangement termed fixed partitions suffers from inefficient memory use - any process, no matter how small, occupies an entire partition. This waste is called internal fragmentation 21. What are the common strategies to select a free hole from a set of available holes? The most common strategies are First fit Best fit Worst fit 22. What do you mean by best fit? Best fit allocates the smallest hole that is big enough. he entire list has to be searched, unless it is sorted by size. This strategy produces the smallest leftover hole. 23. What do you mean by first fit? First fit allocates the first hole that is big enough. Searching can either start at the beginning of the set of holes or where the previous first-fit search ended. Searching can be stopped as soon as a free hole that is big enough is found. PART-B (16 Marks) 1. Explain the most commonly used techniques for structuring the page table (16) (AUCAPR 11,NOV 11) Page Table Structure Hierarchical Paging Hashed Page Tables Inverted Page Tables Hierarchical Page Tables Break up the logical address space into multiple page tables. A simple technique is a two-level page table. Example: Two-Level Paging A logical address (on 32-bit machine with 4K page size) is divided into: A page number consisting of 20 bits. A page offset consisting of 12 bits. Since the page table is paged, the page number is further divided into: 10-bit page number, 10-bit page offset. Where pi is an index into the outer page table, and p2is the displacement within the page of the outer page table. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 3

4 One simple solution to this problem is to divide the page table into smaller pieces. One way is to use a two-level paging algorithm, in which the page table itself is also paged.32-bit machine with a page size 4 KB. A logical address is divided in to a page number consisting of 20 bits, and a page offset consisting of 12 bits. Two-level page table scheme. Address-translation scheme for a two-level 32-bit paging architecture Hashed Page Table A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 4

5 Common in address spaces > 32 bits. The virtual page number is hashed into a page table. This page table contains a chain of elements hashing to the same location. Virtual page numbers are compared in this chain searching for a match. If a match is found, the corresponding physical frame is extracted. Hashed Page Table Inverted page Table Entry for each real page of memory. Entry consists of the virtual address of the page stored in that real memory location, with information about the process that owns that page.decreases memory needed to store each page table, but increases time needed to search thetable when a page reference occurs. Use hash table to limit the search to one or at most a few page-table entries. Shared Pages Inverted page table A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 5

6 Shared code. One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems). Shared code must appear in same location in the logical address space of all processes. Private code and data. Each process keeps a separate copy of the code and data. The pages for the private code and data can appear anywhere in the logical address space. 2. Explain FIFO, Optimal and LRU page replacement algorithms (16) (AUC APR 2011) There are many different page replacement algorithms. We evaluate an algorithm by running it on a particular string of memory reference and computing the number of page faults. The string of memory references is called reference string. Reference strings are generated artificially or by tracing a given system and recording the address of each memory reference. In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 6

7 Graph of Page Faults Versus The Number of Frames First-In-First-Out (FIFO) Algorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 3 frames (3 pages can be in memory at a time per process) 4 frames FIFO Replacement Belady s Anomaly more frames less page faults Figure. FIFO Page Replacement FIFO Illustrating Belady s Anamoly A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 7

8 Optimal Algorithm Replace page that will not be used for longest period of time. 4 frames example 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Optimal Page Replacement Least Recently Used (LRU) Algorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Counter implementation o Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter. o When a page needs to be changed, look at the counters to determine which are to change. LRU Page Replacement Stack implementation keep a stack of page numbers in a double link form: a.page referenced: move it to the top. ii. requires 6 pointers to be changed. b.no search for replacement A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 8

9 Use Of A Stack to Record The Most Recent Page References LRU Approximation Algorithms Reference bit a. With each page associate a bit, b. initially = 0 b. When page isreferenced bit set to 1. c. Replace the one which is 0 (if one exists). Second chance a. Need reference bit. b. Clock replacement. c. If page to be replaced (in clock order) has reference bit = 1. then: set reference bit 0. leave page in memory. replace next page (in clock order), subject to same rules. Second-Chance (clock) Page-Replacement Algorithm Keep a counter of the number of references that have been made to each page. LFU Algorithm: replaces page with smallest count. MFU Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used. 3. (i) Why are segmentation and paging sometimes combined into one scheme? (4) Paging operating system uses a paging scheme, memory is divided up into fixed sized blocks. These are called frames, and they usually range between half a kilobyte to eight kilobytes in size. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 9

10 When a program runs, it requests memory from the operating system. The operating system assigns it a number of frames to meet that requirement. Programs know the page they have been assigned and can address memory there. Unfortunately, they can also address memory outside of their assigned pages. Segmentation By contrast, segmentation divides the system up into segments that can grow and shrink in size. The segments are isolated from each other, providing each program with the illusion that it has access to unlimited memory. Paging and segmentation combining the two, the benefits of each can be claimed. Paging prevents programs from fragmentation all over the memory space, and segmentation protects the operating system and other programs from badly written or malicious software. (ii)consider the following reference string: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6. How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, and seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each. (1) LRU replacement (2) FIFO replacement (3) Optimal replacement (12) (AUC MAY/JUNE2012) A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 10

11 A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 11

12 A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 12

13 A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 13

14 4. i) Consider the following segment table. Segment Base Length what are the physical addresses for the following logical addresses? (1) 0, 430 (2) 1,10 (3) 2,500 (4) 3,400 (8) A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 14

15 (ii) Discuss briefly about memory management in Linux. (16) (AUC MAY/JUNE2012) Memory management under Linux has two components. The first deals with locating and freeing physical memory pages, groups of pages, and small blocks of memory. The second handles virtual memory, which is memory mapped into the address space of running processes. Management of Physical Memory Intel x86 processes have segments Linux tries to avoid using segmentation Memory management is simpler when all processes use the same segment register values Using segment registers is not portable to other processors Linux uses paging 4k page size A three-level page table to handle 64-bit addresses On x86 processors Only a two-level page table is actually used Paging is supported in hardware TLB is provided as well A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 15

16 Linux memory management Linux Kernel Memory Management Approximately the first two megabytes of physical memory are reserved For the PC architecture and for OS text and data The rest is available for paging The logical address space of a process is divided into two parts 0x to PAGE_OFFSET-1 can be addressed in either user or kernel mode PAGE_OFFSET to 0xffffffff can be addressed only in kernel mode PAGE_OFFSET is usually 0xc Linux Page Frame Management The kernel keeps track of the current status of each page frame in an array of struct page descriptors, one for each page frame Page frame descriptor array is called mem_map Keeps track of the usage count (== 0 is free, > 0 is used) Flags for dirty, locked, referenced, etc. The kernel allocates and release frame via get_free_pages(gfp_mask, order) andfree_pages(addr, order) paging eliminates the need for contiguous memory allocation, but Some operations like DMA ignores paging circuitry and accesses the address bus directly while transferring data As an aside, some DMA can only write into certain addresses Contiguous page frame allocation leaves kernel paging tables unchanged, preserving TLB and reducing effective access time A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 16

17 As a result, Linux implements a mechanism for allocating contiguous page frames Contiguous Page Frame Allocation Buddy system algorithm All page frames are grouped into 10 lists of blocks that contain groups of 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512 contiguous page frames, respectively The address of the first page frame of a block is a multiple of the group size, for example, a 16 frame block is a multiple of The algorithm for allocating, for example, a block of 128contiguous page frames First checks for a free block in the 128 list If no free block, it then looks in the 256 list for a free block If it finds a block, the kernel allocates 128 of the 256 page frames and puts the remaining 128 into the 128 list If no block it looks at the next larger list, allocating it and dividing the block similarly If no block can be allocated an error is reported Buddy system algorithm When a block is released, the kernel attempts to merge together pairs of free buddy blocks of size b into a single block of size 2b Two blocks are considered buddies if Both have the same size They are located in contiguous physical addresses The physical address of the first page from of the first block is a multiple of 2b 212 The merging is iterative Linux makes use of two different buddy systems, one for page frames suitable for DMA (i.e., addresses less than 16MB) and then all other page frames Each buddy system relies on The page frame descriptor array mem_map An array of ten free_area_struct, one element for each group size; each free_area_struct contains a doubly linked circular list of blocks of the respective size Ten bitmaps, one for each group size, to keep track of the blocks it allocates The buddy algorithm is fine for dealing with relatively large memory requests, but it how does the kernel satisfy its needs for small memory areas? In other words, the kernel must deal with internal fragmentation Linux 2.2 introduced the slab allocator for dealing with small memory area allocation View memory areas as objects with data and methods (i.e., constructors and destructors) The slab allocator does not discard objects, but caches them Kernel functions tend to request objects of the same type repeatedly, such as process descriptors, file descriptors, etc. Slab allocator Groups objects into caches A set of specific caches is created for kernel operations Each cache is a store of objects of the same type (for example, a file pointer is allocated from the filp slab allocator) Look in /proc/slabinfo for run-time slab statistics Slab caches contain zero or more slabs, where a slab is one or more contiguous pages frames from the buddy system A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 17

18 Objects are allocated using kmem_cache_alloc(cachep), where cachep points to the cache from which the object must be obtained Objects are released using kmem_cache_free(cachep, objp) A group of general caches exist whose objects are geometrically distributed sizes ranging from 32 to bytes To obtain objects from these general caches, use kmalloc(size, flags) To release objects from these general caches, use kfree(objp) Noncontiguous Memory Area Allocation Linux tries to avoid allocating noncontiguous memory areas, but for infrequent memory requests sometimes it makes sense to allocate noncontiguous memory areas This works similarly as the lecture discussions on paging Linux uses most of the reserved addresses above PAGE_OFFSETto map noncontiguous memory areas To allocate and release noncontiguous memory, use vmalloc(size) and vfree(addr), respectively Linux Kernel Memory Allocation Kernel functions get dynamic memory in one of threeways get_free_pages() to get pages from the buddy system kmem_cache_alloc() or kmalloc() to use slab allocator to get specialized or general objects vmalloc() to get noncontiguous memory areas Process Address Spaces The address space of a process consists of all logical addresses that the process is allowed to use Each process address space is separate (unless shared) The kernel allocates logical addresses to a process in intervals called memory regions Memory regions have an initial logical address and a length, which is a multiple of 4096 Typical situations in which a process gets new memory regions Creating a new process (fork()), loading an entirely new program (execve()), memory mapping a file (mmap()), growing its stack, creating shared memory (shmat()),expanding its heap (malloc()) Process Memory Region Linux represents a memory region (i.e., an interval of logical address space) with vm_area_struct Contains a reference to the memory descriptor that owns the region (vm_mm field), the start (vm_start field) and end (vm_end field) of the interval Memory regions never overlap Kernel tries to merge contiguous regions (if their access rights match) All regions are maintained on a simple list (vm_next field) in ascending order by address The head of the list and the size of the list are in the mmap field and the map_count fields, respectively, of the mm memory descriptor If the list of regions gets large (usually greater than 32), then it is also managed as an AVL tree for efficiency Process Memory Region Abstract view of memory descriptor, regions, and logical address space A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 18

19 To allocate a logical address interval, the kernel uses do_mmap() Checks for errors and limits Tries to find an unmapped logical address interval in memory region list Allocates a vm_area_struct for new interval Updates bookkeeping and inserts into list (merging if possible) To release a logical address interval, the kernel uses do_munmap() Locates memory region that overlaps, since it may have been merged Removes memory region, splitting if necessary Updates bookkeeping Page Fault Handler When a process requests more memory from the kernel, it only gets additional logical address space, not physical memory When a process tries to access its new logical address space, a page fault occurs to tell the kernel that the memory is actually needed (i.e., demand paging) The page fault handler compares the logical address to the memory regions owned by the process to determine if The memory access was an error Physical memory needs to be allocated to the process An address may also not be in physical memory if the kernel has swapped the memory out to disk A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 19

20 5. Discuss how memory is allocated in variable partition multiprogramming. (6)(AUC APR2010) When a process arrives, it is allocated memory from a hole large enough to accommodate it. Hole block of available memory; holes of various sizes are scattered throughout memory. Operating system maintains information about: a) allocated partitions b) free partitions (holes) Managing allocated and free partitions Example: memory with 5 processes and 3 holes: tick marks show memory allocation units. shaded regions (0 in the bitmap) are free. Memory Management with Linked Lists A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 20

21 6. Discuss segmentation in detail. Compare it with paging. (8) (AUC APR2010) Memory-management scheme that supports user view of memory. A program is a collection of segments. A segment is a logical unit such as: Main program, procedure, function, method, object, local variables, global variables, common block stack, stack symbol table, arrays. 1. Segmentation Architecture Segmentation is memory-management scheme that support this user view of memory. A A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 21

22 logical-address space is a collection of segments. Each segment has a name and a length. the addresses specify both the segment name and offset within the segment.the user therefore specifies each address by two quantities: a segment name and an offset. Logical address consists of a two tuple: <segment-number, <segment-number,offset> offset>, Segment table maps two-dimensional physical address. Each table entry has: base contains the starting physical address where the segments reside in memory limit specifies the length of the segment Segment-table base register (STBR) points to the segment table s location in memory Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR Segmentation Hardware Define an implementation to map two-dimensional user-defined addresses into one dimensional physical addresses. This mapping is affected by a segmentation table. Each entry of the segmentation table has a segment base and a segment limit. The segment base contains the starting physical address where the segment resides in memory, whereas the segment limit specifies the length of the segment. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 22

23 Segmentation Hardware Segmentation Segmentation With Paging The IBM OS/2 32-bit version is an operating system running on top of the intel 386 architecture. The 386 uses segmentation with paging for memory management.the maximum number of segment per process is 16 KB, and each segment can be as 4 gigabytes. The page size is 4 KB. Comparison between paging and segmentation In order to compare these two virtual addresing schemes and to discover situations where each is appropriate, let us evaluate each scheme using the folowing criteria: 1. Memory Utilization 2. Memory Allocation 3. Sharing of Code Memory Utilization: Paging achieves very good utilization of memory. One can arrange concurrent user programs in memory, each being represented by only those pages that it is currently using. the main memory available to user programs will normally be allocated and in active use. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 23

24 Of course, paging entails the allocation of some integral number of page frames to a process; it is unlikely that a process will actually fit exactly in an integral number of page frames and consequently one has internal fragmentation. Though internal fragmentation is present in paged systems, the wastage is not much. It will only be on the last pages of programs currently being multiprogrammed. As a system runs, segments are loaded, used and then freed. Once freed, the spaces in memory that they occupied are reallocated. It would be typical for an incoming segment to exactly fit in the space released by a departing segment; consequently, one has extrnal fragmentation. Memory Allocation: Paging simplifies the task of memory allocation. With paging, the system has a pool of identical resource units - the page frames. Requests by processes for additional resources (page frames) can be satisfied by the allocation of any of the free page frame. The only problem that may arise are due to the requests for new page frames coming much faster than the voluntary release of page frames (this situation is normal during job termination). Usually there will be no page frame free; so the system has to preempt a page frame, i.e., swap out a page occupying a frame. This preempted page frame may be a frame allocated to the same process. Allocation of spaces for segment is more difficult. Memory allocation schemes that attempt to find the best-fit/ first-fit/ worst fit are all very well so long as there are "holes" sufficient in size to take a new segment. but if external fragmentation has got too rampant, then though there may be lots of unused memory there might be no areas of sufficient size to allocate to a new segment. Then the system could "compact" memory - but it is firesome, lots of copying, lots of updating of segment maps, and nesty restrictions of I/O is in progress for any of the segments that must be moved. Alternatively, the system can try swapping segments out. This is even more difficult. The system could try to swap out several neighboring segments, or maybe one segments adjacent to a couple of small "holes" so as to get a "hole" suffecient for the new segment.this however, involves lots of messy adress translations and calculations - and these will have to be repeated when a swapped out segment is swapped back in. Sharing of Code Segmentation was designed in part to allow for sharing of code and / or read- only data among processes. Segments can be made to specify allowed usage on it - any execute - only/ read-only segment is intrinsically sharable. The system can keep track of segments loaded (particularly easy if a segment identifier can be related to a file identifier as a possible in many segmented system) and can determine when one process is requesting a segment already loaded by some other process. Arrangements for sharing simply require that the segment maps of various processes are kept consistent. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 24

25 Sharing is difficult in paged systems. Pages do not correspond to logical divisions of a program. One FORTRAN program on a paged system might on any page contain some marvelous mixture of code and data. Each process must keep its private data separate. 7. Explain about contiguous memory allocation with neat diagram.(16) ( AUC NOV/DEC2011) Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector. User processes then held in high memory. Single-partition allocation Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data.relocation register contains value of smallest physical address; limit register contains range of logical addresses each logical address must be less than the limit register Hardware Support for Relocation and Limit Registers Contiguous Allocation Multiple-partition allocation o Hole block of available memory; holes of various size are scattered throughout memory. o When a process arrives, it is allocated memory from a hole large enough to accommodate it. o Operating system maintains information about: allocated partitions, free partitions Dynamic Storage-Allocation Problem How to satisfy a request of size n from a list of free holes. First-fit: Allocate the first hole that is big enough. Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole. First-fit and best-fit better than worst-fit in terms of speed and storage utilization. Fragmentation A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 25

26 External Fragmentation total memory space exists to satisfy a request, but it is not contiguous. Internal Fragmentation allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. Reduce external fragmentation by compaction o Shuffle memory contents to place all free memory together in one large block. o Compaction is possible only if relocation is dynamic, and is done at execution time. 10. Given memory partition of 100 KB, 500 KB, 200 KB and 600 KB (in order). Show with neat Sketch how would each of the first-fit, best-fit and worst-fit algorithms place processes of 412 KB,317 KB, 112 KB and 326 KB(in order). Which algorithm is most efficient in memory allocation? (AUC NOV 2010) First fit 412KB is put in 500KB position 317KB is put in 600KBposition 112KB is put in 283KB position(new partition 283= ) 326 KB must wait. Best fit 412KB is put in 500 KB position 317 KB is put in - Best - Fit: 212K is put in 300K partition. 417K is put in 500K partition. 112K is put in 200K partition. 426K is put in 600K partition. Worst - Fit: 212K is put in 600K partition. 417K is put in 500K partition. 112K is put in 388K partition. 426K must wait. In this example, Best - Fit turns out to be t he best A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 26

27 11. Explain the concept of demand paging. How can demand paging be implemented with Virtual memory (16) (AUC NOV 2010) A demand paging is similar to a paging system with swapping.when we want to execute a process, we swap it into memory. Rather than swapping the entire process into memory. When a process is to be swapped in, the pager guesses which pages will be used before the process is swapped out again Instead of swapping in a whole process, the pager brings only those necessary pages into memory. Thus, it avoids reading into memory pages that will not be used in anyway, decreasing the swap time and the amount of physical memory needed. Hardware support is required to distinguish between those pages that are in memory and those pages that are on the disk using the valid-invalid bit scheme. Where valid and invalid pages can be checked checking the bit and marking a page will have no effect if the process never attempts to access the pages. While the process executes and accesses pages that are memory resident, execution proceeds normally. Transfer of a paged memory to continuous disk space Access to a page marked invalid causes a page-fault trap. This trap is the result of the operating system's failure to bring the desired page into memory. But page fault can be handled as following A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 27

28 Steps in handling a page fault 1. We check an internal table for this process to determine whether the reference was a valid or invalid memory access. 2. If the reference was invalid, we terminate the process. If.it was valid, but we have not yet brought in that page, we now page in the latter. 3. We find a free frame. 4. We schedule a disk operation to read the desired page into the newly allocated frame. 5. When the disk read is complete, we modify the internal table kept with the process and the page table to indicate that the page is now in memory. 6. We restart the instruction that was interrupted by the illegal address trap. The process can now access the page as though it had always been memory. Therefore, the operating system reads the desired page into memory and restarts the process as though the page had always been in memory. The page replacement is used to make the frame free if they are not in used. If no frame is free then other process is called in. Advantages of Demand Paging: 1. Large virtual memory. 2. More efficient use of memory. 3. Unconstrained multiprogramming. There is no limit on degree of multiprogramming. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 28

29 Disadvantages of Demand Paging: 1. Number of tables and amount of processor over head for handling page interrupts are greater than in the case of the simple paged management techniques. 2. due to the lack of an explicit constraints on a jobs address space size. 12. A page-replacement algorithm should minimize the number of page faults. Minimization by distributing heavily used pages evenly over all of memory, rather having They compete for a small number of page frames. We can associate with each page frame a Counter of the number of pages that are associated with that frame. Then, to replace a page, We search for the page frame with the smallest counter. a.define a page-replacement algorithm using this basic idea. b.specifically address the problems of (1) what the initial value of the counters is, (2) when counters are increased, (3) when counters are decreased, and (4) how the page to be replaced is selected. (8) c. How many page faults occur for your algorithm for the following reference string, for four page frames? 1, 2, 3, 4, 5, 3, 4, 1, 6, 7, 8, 7, 8, 9, 7, 8, 9, 5, 4, 5, 4, 2. (4) d. What is the minimum number of page faults for an optimal page-replacement Strategy for the reference string in part b with four page frames? (4) solution a. Define a page-replacement algorithm addressing the problems of: i. Initial value of the counters 0. ii. Counters are increased whenever a new page is associated with that frame. iii. Counters are decreased whenever one of the pages associated with that frame is no longer required. iv. How the pages to be replaced are selected find a frame with the smallest counter. Use FIFO for breaking ties. b. 14 page faults c. 11 page faults 13. Which of the following programming techniques and structures are good for a demand-paged environment? Which are not good? Explain your answers. a. Stack b. Hashed symbol table c. Sequential search d. Binary search e. Pure code A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 29

30 f. Vector operations g. Indirection Answer: a. Stack good. b. Hashed symbol table not good. c. Sequential search good. d. Binary search not good. e. Pure code good. f. Vector operations good. g. Indirection not good. A.Joyce-AP/CSE- MAHALAKSHMI ENGINEERING COLLEGE Page 30

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management Part Four - Memory Management 8.1 Background Chapter 8: Memory-Management Management Strategies Program must be brought into memory and placed within a process for it to be run Input queue collection of

More information

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

CS6401- Operating System UNIT-III STORAGE MANAGEMENT UNIT-III STORAGE MANAGEMENT Memory Management: Background In general, to rum a program, it must be brought into memory. Input queue collection of processes on the disk that are waiting to be brought into

More information

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

Part Three - Memory Management. Chapter 8: Memory-Management Strategies Part Three - Memory Management Chapter 8: Memory-Management Strategies Chapter 8: Memory-Management Strategies 8.1 Background 8.2 Swapping 8.3 Contiguous Memory Allocation 8.4 Segmentation 8.5 Paging 8.6

More information

Chapter 9: Memory Management. Background

Chapter 9: Memory Management. Background 1 Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory and placed within a process for

More information

Chapter 8: Memory Management Strategies

Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies, Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 8: Memory Management Background" Swapping " Contiguous Memory Allocation" Paging" Structure

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 8.2 Silberschatz, Galvin

More information

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science Virtual Memory CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those from an earlier edition of the course text Operating

More information

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition Chapter 7: Main Memory Operating System Concepts Essentials 8 th Edition Silberschatz, Galvin and Gagne 2011 Chapter 7: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Gordon College Stephen Brinton Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Program must be brought into memory

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Background Program must be brought into memory and placed

More information

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time Memory Management To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including paging and segmentation To provide a detailed

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY MANAGEMENT Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY MANAGEMENT Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of

More information

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9: Memory Management Background Swapping Contiguous Memory Allocation Segmentation

More information

CS307: Operating Systems

CS307: Operating Systems CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

Part-A QUESTION BANK UNIT-III 1. Define Dynamic Loading. To obtain better memory-space utilization dynamic loading is used. With dynamic loading, a routine is not loaded until it is called. All routines

More information

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science Memory Management CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture are based on those from Operating Systems Concepts, 9th ed., by Silberschatz, Galvin,

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.1 Background Program must be brought into memory

More information

Chapters 9 & 10: Memory Management and Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory Chapters 9 & 10: Memory Management and Virtual Memory Important concepts (for final, projects, papers) addressing: physical/absolute, logical/relative/virtual overlays swapping and paging memory protection

More information

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses. 1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and

More information

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory Module 9: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and 64-bit Architectures Example:

More information

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition Chapter 8: Memory Management 8.1 Silberschatz, Galvin and Gagne 2009 Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts 8.1 Silberschatz and Galvin

More information

Chapter 8: Memory-Management Strategies

Chapter 8: Memory-Management Strategies Chapter 8: Memory-Management Strategies Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and

More information

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts Memory management Last modified: 26.04.2016 1 Contents Background Logical and physical address spaces; address binding Overlaying, swapping Contiguous Memory Allocation Segmentation Paging Structure of

More information

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University Main Memory CISC3595, Spring 2015 X. Zhang Fordham University 1 Memory Management! Background!! Contiguous Memory Allocation!! Paging!! Structure of the Page Table!! Segmentation!! Example: The Intel Pentium

More information

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s

Chapter 8: Memory- Manage g me m nt n S tra r t a e t gie i s Chapter 8: Memory- Management Strategies Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 2009/12/16

More information

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Memory Management 1 Hardware background The role of primary memory Program

More information

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

Chapter 8: Main Memory. Operating System Concepts 9 th Edition Chapter 8: Main Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 Acknowledgement: This set of slides is partly based on the PPTs provided by the Wiley s companion website (including textbook images, when not explicitly

More information

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Basic Hardware Address Binding Logical VS Physical Address Space Dynamic Loading Dynamic Linking and Shared

More information

Logical versus Physical Address Space

Logical versus Physical Address Space CHAPTER 8: MEMORY MANAGEMENT Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts, Addison-Wesley 1994

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel

More information

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1 Main Memory Electrical and Computer Engineering Stephen Kim (dskim@iupui.edu) ECE/IUPUI RTOS & APPS 1 Main Memory Background Swapping Contiguous allocation Paging Segmentation Segmentation with paging

More information

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES OBJECTIVES Detailed description of various ways of organizing memory hardware Various memory-management techniques, including paging and segmentation To provide

More information

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure. File Systems I/O Management Hard Drive Management Virtual Memory Swap Memory Management Storage and I/O Introduction CSI3131 Topics Process Management Computing Systems Memory CPU Peripherals Processes

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

Chapter 8: Memory- Management Strategies

Chapter 8: Memory- Management Strategies Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and

More information

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed. CHAPTER 8: MEMORY MANAGEMENT By I-Chen Lin Textbook: Operating System Concepts 9th Ed. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the

More information

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it to be run Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Mono-programming

More information

Memory Management. Contents: Memory Management. How to generate code? Background

Memory Management. Contents: Memory Management. How to generate code? Background TDIU11 Operating systems Contents: Memory Management Memory Management [SGG7/8/9] Chapter 8 Background Relocation Dynamic loading and linking Swapping Contiguous Allocation Paging Segmentation Copyright

More information

Lecture 8 Memory Management Strategies (chapter 8)

Lecture 8 Memory Management Strategies (chapter 8) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 8 Memory Management Strategies (chapter 8) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The

More information

Basic Memory Management

Basic Memory Management Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester 10/15/14 CSC 2/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it

More information

Chapter 8: Main Memory. Operating System Concepts 8th Edition

Chapter 8: Main Memory. Operating System Concepts 8th Edition Chapter 8: Main Memory Operating System Concepts 8th Edition Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page

More information

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University CSC 4103 - Operating Systems Spring 2007 Lecture - XII Main Memory - II Tevfik Koşar Louisiana State University March 8 th, 2007 1 Roadmap Dynamic Loading & Linking Contiguous Memory Allocation Fragmentation

More information

SHANDONG UNIVERSITY 1

SHANDONG UNIVERSITY 1 Chapter 8 Main Memory SHANDONG UNIVERSITY 1 Contents Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium SHANDONG UNIVERSITY 2 Objectives

More information

Background. Contiguous Memory Allocation

Background. Contiguous Memory Allocation Operating System Lecture 8 2017.5.9 Chapter 8 (Main Memory) Background Swapping Contiguous Memory Allocation Segmentation - Paging Memory Management Selection of a memory-management method for a specific

More information

Memory Management and Protection

Memory Management and Protection Part IV Memory Management and Protection Sadeghi, Cubaleska RUB 2008-09 Course Operating System Security Memory Management and Protection Main Memory Virtual Memory Roadmap of Chapter 4 Main Memory Background

More information

CS307 Operating Systems Main Memory

CS307 Operating Systems Main Memory CS307 Main Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Background Program must be brought (from disk) into memory and placed within a process

More information

Operating System - Virtual Memory

Operating System - Virtual Memory Operating System - Virtual Memory Virtual memory is a technique that allows the execution of processes which are not completely available in memory. The main visible advantage of this scheme is that programs

More information

Goals of Memory Management

Goals of Memory Management Memory Management Goals of Memory Management Allocate available memory efficiently to multiple processes Main functions Allocate memory to processes when needed Keep track of what memory is used and what

More information

Principles of Operating Systems

Principles of Operating Systems Principles of Operating Systems Lecture 18-20 - Main Memory Ardalan Amiri Sani (ardalan@uci.edu) [lecture slides contains some content adapted from previous slides by Prof. Nalini Venkatasubramanian, and

More information

Chapter 8 Memory Management

Chapter 8 Memory Management Chapter 8 Memory Management Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 Outline Background Swapping Contiguous

More information

Chapter 9 Memory Management

Chapter 9 Memory Management Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual

More information

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit Memory Management All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is to be in memory Memory management activities Keeping

More information

Operating System 1 (ECS-501)

Operating System 1 (ECS-501) Operating System 1 (ECS-501) Unit- IV Memory Management 1.1 Bare Machine: 1.1.1 Introduction: It has the ability to recover the operating system of a machine to the identical state it was at a given point

More information

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01 1 Unit-03 Deadlock and Memory Management Unit-03/Lecture-01 The Deadlock Problem 1. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.

More information

UNIT-III VIRTUAL MEMORY

UNIT-III VIRTUAL MEMORY MEMORY MANAGEMENT: The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be at least partially in main memory during execution. To improve

More information

Main Memory (Part I)

Main Memory (Part I) Main Memory (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Main Memory 1393/8/5 1 / 47 Motivation and Background Amir

More information

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is. Chapter 4 Memory Management Ideally programmers want memory that is Memory Management large fast non volatile 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Silberschatz, Galvin and Gagne 2005 Background Program/Code

More information

Chapter 9: Virtual-Memory

Chapter 9: Virtual-Memory Chapter 9: Virtual-Memory Management Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation of Frames Thrashing Other Considerations Silberschatz, Galvin and Gagne 2013

More information

Virtual Memory Outline

Virtual Memory Outline Virtual Memory Outline Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L17 Main Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Was Great Dijkstra a magician?

More information

Chapter 8 Main Memory

Chapter 8 Main Memory COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 8 Main Memory Zhi Wang Florida State University Contents Background Swapping Contiguous memory allocation Paging Segmentation OS examples

More information

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Memory management is crucial in better utilizing one of the most important

More information

Chapter 8 Memory Management

Chapter 8 Memory Management 1 Chapter 8 Memory Management The technique we will describe are: 1. Single continuous memory management 2. Partitioned memory management 3. Relocatable partitioned memory management 4. Paged memory management

More information

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical

More information

Virtual Memory COMPSCI 386

Virtual Memory COMPSCI 386 Virtual Memory COMPSCI 386 Motivation An instruction to be executed must be in physical memory, but there may not be enough space for all ready processes. Typically the entire program is not needed. Exception

More information

VII. Memory Management

VII. Memory Management VII. Memory Management 1 Intended Schedule Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

More information

OPERATING SYSTEM. Chapter 9: Virtual Memory

OPERATING SYSTEM. Chapter 9: Virtual Memory OPERATING SYSTEM Chapter 9: Virtual Memory Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory

More information

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Memory Management To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time. Basic CPUs and Physical Memory CPU cache Physical memory

More information

Chapter 4 Memory Management

Chapter 4 Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

Memory Management. Memory Management. G53OPS: Operating Systems. Memory Management Monoprogramming 11/27/2008. Graham Kendall.

Memory Management. Memory Management. G53OPS: Operating Systems. Memory Management Monoprogramming 11/27/2008. Graham Kendall. Memory Management Memory Management Introduction Graham Kendall Memory Management consists of many tasks, including Being aware of what parts of the memory are in use and which parts are not Allocating

More information

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University

Main Memory Yi Shi Fall 2017 Xi an Jiaotong University Main Memory Yi Shi Fall 2017 Xi an Jiaotong University Goals Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Background Program must be brought (from disk)

More information

Chapter 4 Memory Management. Memory Management

Chapter 4 Memory Management. Memory Management Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms 4.6 Design issues for paging systems 4.7

More information

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 8: Virtual Memory. Operating System Concepts Chapter 8: Virtual Memory Silberschatz, Galvin and Gagne 2009 Chapter 8: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

CS420: Operating Systems

CS420: Operating Systems Main Memory James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background Program must

More information

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory Multi-Process Systems: Memory (2) What we will learn A detailed description of various ways of organizing memory Discuss various memory-management techniques, including paging and segmentation To provide

More information

CS450/550 Operating Systems

CS450/550 Operating Systems CS450/550 Operating Systems Lecture 4 memory Palden Lama Department of Computer Science CS450/550 Memory.1 Review: Summary of Chapter 3 Deadlocks and its modeling Deadlock detection Deadlock recovery Deadlock

More information

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems Instructor: Dr. Turgay Korkmaz Department Computer Science The University of Texas at San Antonio Office: NPB

More information

P r a t t hr h ee e : e M e M m e o m r o y y M a M n a a n g a e g m e e m n e t 8.1/72

P r a t t hr h ee e : e M e M m e o m r o y y M a M n a a n g a e g m e e m n e t 8.1/72 Part three: Memory Management programs, together with the data they access, must be in main memory (at least partially) during execution. the computer keeps several processes in memory. Many memory-management

More information

Chapter 3 - Memory Management

Chapter 3 - Memory Management Chapter 3 - Memory Management Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 3 - Memory Management 1 / 222 1 A Memory Abstraction: Address Spaces The Notion of an Address Space Swapping

More information

MEMORY MANAGEMENT/1 CS 409, FALL 2013

MEMORY MANAGEMENT/1 CS 409, FALL 2013 MEMORY MANAGEMENT Requirements: Relocation (to different memory areas) Protection (run time, usually implemented together with relocation) Sharing (and also protection) Logical organization Physical organization

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Silberschatz, Galvin and Gagne 2013 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating

More information

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD OPERATING SYSTEMS #8 After A.S.Tanenbaum, Modern Operating Systems 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD MEMORY MANAGEMENT MEMORY MANAGEMENT The memory is one of

More information

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access) Virtual Memory - programmer views memory as large address space without concerns about the amount of physical memory or memory management. (What do the terms 3-bit (or 6-bit) operating system or overlays

More information

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012. CSE 421/521 - Operating Systems Fall 2012 Lecture - XII Main Memory Management Tevfik Koşar University at Buffalo October 18 th, 2012 1 Roadmap Main Memory Management Fixed and Dynamic Memory Allocation

More information

Operating System Concepts

Operating System Concepts Chapter 9: Virtual-Memory Management 9.1 Silberschatz, Galvin and Gagne 2005 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped

More information

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

Outlook. Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium Main Memory Outlook Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 2 Backgound Background So far we considered how to share

More information

Memory Management. Memory

Memory Management. Memory Memory Management These slides are created by Dr. Huang of George Mason University. Students registered in Dr. Huang s courses at GMU can make a single machine readable copy and print a single copy of

More information

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory Chapter 9: Virtual Memory Chapter 9: Virtual Memory 9.1 Background 9.2 Demand Paging 9.3 Copy-on-Write 9.4 Page Replacement 9.5 Allocation of Frames 9.6 Thrashing 9.7 Memory-Mapped Files 9.8 Allocating

More information

UNIT - IV. What is virtual memory?

UNIT - IV. What is virtual memory? UNIT - IV Virtual Memory Demand Paging Process creation Page Replacement Allocation of frames Thrashing- File Concept - Access Methods Directory Structure File System Mounting File Sharing Protection.

More information

CS 3733 Operating Systems:

CS 3733 Operating Systems: CS 3733 Operating Systems: Topics: Memory Management (SGG, Chapter 08) Instructor: Dr Dakai Zhu Department of Computer Science @ UTSA 1 Reminders Assignment 2: extended to Monday (March 5th) midnight:

More information

Memory Management. Dr. Yingwu Zhu

Memory Management. Dr. Yingwu Zhu Memory Management Dr. Yingwu Zhu Big picture Main memory is a resource A process/thread is being executing, the instructions & data must be in memory Assumption: Main memory is infinite Allocation of memory

More information