0% found this document useful (0 votes)
11 views

p5 Managing memory

The document discusses key concepts in memory management, including the differences between logical and physical addresses, and various memory allocation strategies such as first fit, best fit, and worst fit. It explains external and internal fragmentation, highlighting their implications on memory utilization. Additionally, it describes hierarchical paging, hashed page tables, and inverted page tables, detailing their structures and functionalities in managing memory efficiently.

Uploaded by

jayomaer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

p5 Managing memory

The document discusses key concepts in memory management, including the differences between logical and physical addresses, and various memory allocation strategies such as first fit, best fit, and worst fit. It explains external and internal fragmentation, highlighting their implications on memory utilization. Additionally, it describes hierarchical paging, hashed page tables, and inverted page tables, detailing their structures and functionalities in managing memory efficiently.

Uploaded by

jayomaer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Managing

memory
Mosab_2802
objectives

-Difference between a logical and a physical address


-Difference strategies applied for allocating memory [first fit,
best fit, worst fit]
-Explain the distinction between external and internal
fragmentation
-Describe hierarchical paging, hashed page, and inverted page
tables
Difference between a logical and a
physical address
● An address generated by the CPU is commonly referred to as a logical
address, whereas 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 a physical address.
● The compile-time and load-time address-binding methods generate
identical logical and physical addresses. However, the execution-time
address binding scheme results in differing logical and physical
addresses.
● we usually refer to the logical address as a virtual address.
●The set of all logical addresses generated by a program is a logical
address space.
● The set of all physical addresses corresponding to these logical addresses
is a physical address space
Difference strategies applied for allocating
memory first fit best fit worst fit

● First fit: Allocate the first hole that is big enough. Searching can start either at the
beginning of the set of holes or at the location where the previous first-fit search ended. We
can stop searching as soon as we find a free hole that is large enough.

● Best fit: Allocate the smallest hole that is big enough. We must search the entire list,
unless the list is ordered by size. This strategy produces the smallest leftover hole.

● Worst fit: Allocate the largest hole. Again, we must search the entire list, unless it is sorted
by size. This strategy produces the largest leftover hole, which may be more useful than the
smaller leftover hole from a best-fit approach.

● Simulations have shown that both first fit and best fit are better than worst fit in terms of
decreasing time and storage utilization. Neither first fit nor best fit is clearly better than the
other in terms of storage utilization, but first fit is generally faster.
Explain the distinction between external
and internal fragmentation
External fragmentation
External fragmentation exists when there is enough total memory space
to satisfy a request but the available spaces are not contiguous: storage is
fragmented into a large number of small holes. This fragmentation
problem can be severe. In the worst case, we could have a block of free
(or wasted) memory between every two processes. If all these small
pieces of memory were in one big free block instead, we might be able to
run several more processes.

•external fragmentation will be a problem. Depending on the total amount


of memory storage and the average process size, external fragmentation
may be a minor or a major problem. Statistical analysis of first fit, for
instance, reveals that, even with some optimization, given N allocated
blocks, another 0.5 N blocks will be lost to fragmentation. That is, one-
third of memory may be unusable! This property is known as the 50-
percent rule.
Explain the distinction between external
and internal fragmentation

Internal fragmentation
Consider a multiple-partition allocation scheme with a hole of
18,464 bytes. Suppose that the next process requests 18,462
bytes. If we allocate exactly the requested block, we are left with
a hole of 2 bytes. The overhead to keep track of this hole will be
substantially larger than the hole itself. The general approach to
avoiding this problem is to break the physical memory into fixed-
sized blocks and allocate memory in units based on block size.
With this approach, the memory allocated to a process may be
slightly larger than the requested memory. The difference
between these two numbers is internal fragmentation—
unused memory that is internal to a partition.
Describe hierarchical paging, hashed
page, and inverted page tables

hierarchical paging
• Break up the logical address space into multiple page
tables
• A simple technique is a two-level page table
• We then page the page table
A logical address (on 32-bit machine with 1K page size) is
divided into:
a page number consisting of 22 bits
a page offset consisting of 10 bits
Describe hierarchical paging, hashed
page, and inverted page tables
Since the page table is paged, the page number is further
divided into:
a 12-bit page number
a 10-bit page offset
Thus, a logical address is as follows:

Address-Translation Scheme
where p1 is an index into the outer page table, and p2 is the
displacement within the page of the inner page table
Known as forward-mapped page table
Describe hierarchical paging, hashed page,
and inverted page tables
● 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
● Each element contains (1) the virtual page number (2) the
value of the mapped page frame (3) a pointer to the next
element
● Virtual page numbers are compared in this chain searching
for a match
● If a match is found, the corresponding physical frame is
extracted
● Variation for 64-bit addresses is clustered page tables
● Similar to hashed but each entry refers to several pages
(such as 16) rather than 1
● Especially useful for address spaces (where memory
references are non-contiguous and scattered)
Describe hierarchical paging, hashed
page, and inverted page tables

inverted page tables


• Rather than each process having a page table and keeping track of
all possible logical pages, track all physical pages
• One 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 the table when a page reference occurs
• Use hash table to limit the search to one — or at most a few —
page-table entries
• TLB can accelerate access
• But how to implement shared memory?
• One mapping of a virtual address to the shared physical address

You might also like