Lecture 12 Cse Gate
Lecture 12 Cse Gate
Segmentation
Paging Implementation
Since address translation must occur for every address reference, translation must be efficient A process logical address is divided into pages and each page maps to a physical page frame, it is necessary to keep a page table that maps pages to frames
Generally, the page table is per process and kept in the process descriptor When a process is scheduled, just like its registers and program counter, the OS must correctly set up the process page table (which may include setting special register values)
This approach increases translation time though, for example, to access location i
Must first index into page table using PTBR + page number from i (this is one memory access) The resulting frame number is combined with the page offset from i to produce the physical address, then we can access the memory (this is another memory access) This means that it takes two memory accesses to access all memory locations, slowing memory access by a factor of 2
Every time a new page table is loaded (i.e., a process switch), the TLB must be flushed The abstract view of a TLB is presented on the next slide
Multilevel Paging
Modern computers support large logical address spaces (232 to 264)
With an address space of 232 and a page size of 4k (212), a page table has one million entries Assuming that each entry is 4 bytes, the page table is 4MB
We need an approach to reduce the memory requirements of the page table One approach is to page the page table
(In truth, since we are currently assuming an entire process must be in memory to execute, this doesnt actually reduce memory usage, but when we talk about virtual memory in the next lecture we will see how this helps.)
Multilevel Paging
A logical address (on 32-bit machine with 4K page size) is divided into two parts
20-bit page number 12-bit frame offset
where p1 is an index into the outer page table, and p2 is the displacement within the page of the outer page table
Multilevel Paging
Abstract view of a two-level page table
Multilevel Paging
Address-translation scheme for a two-level 32-bit paging architecture
Multilevel Paging
Consider a computer with an address space of 264
With a 4k page and for convenience we make the inner page table fit in one page (i.e., 210 * 4 bytes), we have
page number p1 42 p2 10 page offset d 12
We would still need at least four-level paging if we wanted to make the table manageable
Multilevel Paging
Since each level is stored as a separate table in memory, converting a logical address to a physical one may take four memory accesses for a four-level table This would effectively quintupled the memory access time if it were not for caching Four a 4-level page table with a cache hit rate of 98 percent
EAT = (0.98) 120 + (0.02) 520 = 128 nanoseconds.
Since a process does not usually use its entire page table, it is not necessary to have entries for all possible pages in the page table
Can have a page table length register to indicate size of table
Shared Pages
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
10
Segmentation
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, local variables, global variables, common block, stack, symbol table, arrays
11
3 4
user space
Segmentation Architecture
Logical address consists of <segment-number, offset> Segment table maps two-dimensional physical addresses; 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 tables location in memory Segment-table length register (STLR) indicates number of segments used by a program
Segment number s is legal if s < STLR.
12
Segmentation Architecture
Logical address translation
Segmentation Architecture
13
Segmentation Architecture
Sharing
Allows sharing of segments Shared segments must have same segment number
Allocation
First fit/best fit External fragmentation problems
Protection
With each entry in segment table associate Validation bit = 0 illegal segment Read/write/execute privileges
In general, paging is sufficient and segmentation is not necessary or relevant on newer computing systems other than the Intel x86 architecture
Everything that segmentation offers, paging offers too
14
15