We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11
Ebtehal A.
Alsaggaf
Lab 9&10: Memory Management
Cpcs 361 Spring 2013
Objectives • understand some Basic Memory Management Concepts likePaging and Segmentation • First Fit Best Fit and Worst Fit Algorithms and solve the exercise. • understand page replacement algorithms, concept of Demand Paging, Converting virtual addresses to their equivalent physical addresses in hexadecimal and solving the exercise Paging • Paging – Computer memory is divided into small partitions that are all the same size and referred to as, page frames. • Then when a process is loaded it gets divided into pages which are the same size as those previous frames. The process pages are then loaded into the frames. Segmentation • Segmentation – Computer memory is allocated in various sizes (segments) depending on the need for address space by the process. These segments may be individually protected or shared between processes. Commonly you will see what are called “Segmentation Faults” in programs, this is because the data that’s is about to be read or written is outside the permitted address space of that process.. • Best Fit: The allocator places a process in the smallest block of unallocated memory in which it will fit.
• First Fit: simply scans the free list until a large enough hole is found. Despite the name, first-fit is generally better than best-fit because it leads to less fragmentation.
• Worst Fit: The memory manager places process in the largest
block of unallocated memory available. The idea is that this placement will create the largest hole after the allocations, thus increasing the possibility that, compared to best fit, another process can use the hole created as a result of external fragmentation. Question # 1 Assume that the main memory has the following 5 fixed partitions with the following sizes: 100KB, 500KB, 200KB, 300KB and 600KB (in order) – a) Explain the following allocation algorithms: First-fit, Best-fit and Worst-fit. – b) How would each of the First-fit, Best-fit and Worst-fit algorithms place processes of 212KB, 417KB, 112KB and 426KB (in order)? – c) Compute the total memory size that is not used for each algorithm. – d) Which algorithm makes the efficient use of the memory? Answer # 1: Answer # 1: a. First-fit: 1. 212K is put in 500K partition 2. 417K is put in 600K partition 3. 112K is put in 288K partition (new partition 288K = 500K − 212K) 4. 426K must wait c. Worst-fit: l. 212K is put in 600K partition b. Best-fit: 2. 417K is put in 500K partition 1. 212K is put in 300K partition 3. 112K is put in 388K partition 2. 417K is put in 500K partition 4. 426K must wait In this example, best-fit turns out to be the 3. 112K is put in 200K partition best. 4. 426K is put in 600K partition Converting virtual addresses to their equivalent physical addresses Consider the page table for a system with 12-bit virtual and physical addresses with 256-byte pages. The list of free page frames is D, E, F (that is, D is at the head of the list, E is second, and F is last). Question # 2 Consider the following segment mapping table (SMT)
What are the physical
addresses of the following logical addresses? a) <0, 430> b) <1, 10> c) <2, 500> d) <3, 500> Answer : e) <4, 122> a) <0, 430> 219 + 430 = 649 b) <1,10> 2300 + 10 = 2310 f) <6, 1952> c) <2,500> Trap (500 >= 100) d) <3,500> 1327 + 500 = 1827 e) <4,122> Trap (122 >= 96) f) <6,1952> Trap (6 is an invalid entry)