Address Translation Mechanism of 80386

Slides:



Advertisements
Similar presentations
Memory Management Unit
Advertisements

EECS 470 Virtual Memory Lecture 15. Why Use Virtual Memory? Decouples size of physical memory from programmer visible virtual memory Provides a convenient.
16.317: Microprocessor System Design I
CSIE30300 Computer Architecture Unit 10: Virtual Memory Hsin-Chou Chi [Adapted from material by and
Memory Management (II)
Chapter 3.2 : Virtual Memory
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
Virtual Memory I Chapter 8.
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
UNIT 2 Memory Management Unit and Segment Description and Paging
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Address Translation Mechanism of 80386
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Fall 2000M.B. Ibáñez Lecture 17 Paging Hardware Support.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
80386DX.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
1 i386 Memory Management Professor Ching-Chi Hsu 1998 年 4 月.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Memory Management CS Spring Overview Partitioning, Segmentation, and Paging External versus Internal Fragmentation Logical to Physical Address.
Lab4: Virtual Memory CS 3410 : Computer System Organization & Programming Spring 2015.
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
1 Virtual Memory. 2 Outline Case analysis –Pentium/Linux Memory System –Core i7 Suggested reading: 9.7.
Computer Architecture Lecture 12: Virtual Memory I
Translation Lookaside Buffer
ECE232: Hardware Organization and Design
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
From Address Translation to Demand Paging
CS703 - Advanced Operating Systems
Paging COMP 755.
Section 9: Virtual Memory (VM)
From Address Translation to Demand Paging
Today How was the midterm review? Lab4 due today.
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory Chapter 8.
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Operating Modes UQ: State and explain the operating modes of X86 family of processors. Show the mode transition diagram highlighting important features.(10.
Computer Architecture
Lecture 29: Virtual Memory-Address Translation
Introduction to the Intel x86’s support for “virtual” memory
Translation Lookaside Buffer
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
Virtual Memory Overcoming main memory size limitation
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management CSE451 Andrew Whitaker.
COMP3221: Microprocessors and Embedded Systems
Paging and Segmentation
CS703 - Advanced Operating Systems
CSE 153 Design of Operating Systems Winter 2019
Translation Buffers (TLBs)
Virtual Memory.
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory 1 1.
Presentation transcript:

Address Translation Mechanism of 80386 Unit 2

Protected Mode Addressing Mechanism 80386 transforms logical addresses into physical address two steps: Segment translation: a logical address is converted to a linear address. Page translation: a linear address is converted to a physical address.(optional) These translations are performed in a way that is not visible to applications programmers.

The following figure illustrates the two translations:

Segmentation

Segmentation Unit Logical(Virtual) Address Linear Address

Base Address in LDTR Register Base Address in GDTR Register

Segment Descriptor

For currently executing task

For each Task

Paging

Second Phase Paging Unit Linear Address Physical Address

Page Translation Mandatory if:- Virtual 8086 Page protection Page virtual memory E.g: LA 4GB mapped to 16MB PA Total Pages= 1,048,496 pages in PA Page size= 4096 bytes

Segmentation Vs Paging Sr.No Segmantation Paging 1 PA Organized as Segments PA Organized as Page 2 Size is Variable Size is Fix 3 1 byte to 4GB 4KB 4 More efficient use of memory Less efficient use of memory 5 Less Fragmentation More Fragmentation 6 Implementation of memory management software is not simplified Implementation of memory management software is simplified

Pages begin onebyte boundaries and are fixed in size. Page Frame A page frame is a 4K-byte unit of contiguous addresses of physical memory. Pages begin onebyte boundaries and are fixed in size.

Components of Paging Mechanism Page Directory Page tables Page frame Table Form 32 bit descriptors Total 1024 descriptors 4KB long

Linear to Physical Address Translation

Page Descriptor Base Register CR2 is used to store the 32-bit linear address of page fault. CR3 (Page Directory Physical Base Address Register) stores the physical starting address of Page Directory.

Page Descriptor Base Register The lower 12 bits of CR3 are always zero to ensure that the Page Directory is always page aligned A move operation to CR3 automatically loads the Page Table Entry caches and a task switch through a TSS changes the value of CR0. MOV CR3,EAX

Page Directory PDE:-It is at the most 4KB in size and allows upto 1024 entries are allowed. The upper 10 bits of the linear address are used as an index to corresponding page directory entry Page directory entry points to page tables.

Page Directory Entry

Page Tables PTE:-Each Page Table is 4KB and holds up to 1024 Page Table Entries. PTEs contain the starting address of the page frame and statistical information about the page. Upper 20 bit page frame address is concatenated with the lower 12 bits of the linear address to form the physical address. Page tables can be shared between tasks and swapped to disks.

Page Table Entry P(Present)Bit: indicates if the entry can be used in address translation. P-bit of the currently executed page is always high. A (Accessed) Bit: It is set before any access to the page.

Page Table Entry D (Dirty) bit: It is set before a write operation to the page is carried out. The D bit is undefined for PDEs. OS Reserved Bits: They are defined by the operating system software. U/S (User/Supervisor)Bit and R/W (Read/Write) Bit: They are used to provide protection. They are decoded as

Linear Address : 0301008A Binary Hex 00C 010 08A Example 0000 0011 0000 0001 0000 0000 1000 1010 Binary 00 0000 1100 (10bits) 00 0001 0000 (10bits) 0000 1000 1010 (12bits) Hex 00C 010 08A

Example

Hex Binary 00 0000 1100 00 0000 1100 x 0100 _____________ 00 0011 0000 00C(DIR) x4 030 Binary 00 0000 1100 00 0000 1100 x 0100 _____________ 00 0011 0000

CR3 DIR*4 + Index to PDE = (20-bit) (12-bit) 00010H 030H 00010030H + =

Example

Page Directory Entry

Hex Binary 00 0001 0000 00 0001 0000 x 0100 _____________ 00 0100 0000 010(TABLE) x4 040 Binary 00 0001 0000 00 0001 0000 x 0100 _____________ 00 0100 0000

PTA Table*4 05001H 05001040H + 040H + Index to PTE = = (20-bit)

Example

Page Table Entry

PFA Offset 03000H 03000 08AH + 08AH + Physical Address = = (20-bit)

Example

Translation Lookaside Buffer(TLB) Performance degrades if the processor access two levels of tables for every memory reference. To solve this problem, the Intel386 DX keeps a cache of the most recently accessed pages and this cache is called Translation Lookaside Buffer (TLB). TLB is a 4 way set associative 32 entry page table cache

Translation Lookaside Buffer(TLB)

Translation Lookaside Buffer(TLB) TLB has 4 sets of eight entries each. Each entry consists of a TAG and a DATA. Tags are 24 bit wide. They contain 20 upper bits of linear address, a valid bit (Validation of Entry) and three attribute bits(D,U/S and R/W) Data portion of each entry contains upper 20 bits of the Physical address.

TLB Entry V D U/S R/W Upper 20 bit Linear Address Upper 20-bit Physical Address

Translation Lookaside Buffer(TLB) It automatically keeps the most commonly used Page Table Entries. 32-entry TLB coupled with a 4K page size results in the coverage of 128KB of memory addresses.

Paging Operation The paging unit hardware receives a 32-bit linear address from the segmentation unit. The upper 20 linear address bits are compared with all 32 entries in the TLB to determine if there is a match. If there is a match (i.e. a TLB hit), then the 32-bit physical address is calculated and will be placed on the address bus.

Paging Operation If PTE entry is not in TLB, the 80386 DX will read the appropriate PDE Entry. If P = 1 on PDE (the page table is in memory), then the 80386 DX will read the appropriate PTE and set the Access bit. If P = 1 on PTE ( the page is in memory), then the Intel386 DX will update the Access and Dirty bits as needed and fetch the operand.

Paging Operation The upper 20 bits of the linear address read from the page table will be stored in the TLB for future accesses. If P = 0 for either PDE or PTE, then the processor will generate a page fault exception This exception is also generated when protection rules are violated and the CR2 is loaded with the page fault address

Paging Operation Linear Address Y Upper 20 bits available in TLB (Page is present in physical memory, set A and D(if needed)) N N P=1 in PDE? (Page Table is present in physical memory, set access bit) Y N P=1 in PTE? Y (Page is present in physical memory but entry is not there in TLB,set A and D(if needed) ) Page Fault Exception Update TLB

Paging Operation

Paging Main Memory The operating system uses page tables to map the pages in the linear virtual address space onto main memory . . . Page 0 Page 1 Page 2 . . . Page m Page 0 Page 1 Page 2 . . . Page n linear virtual address space of Program 1 linear virtual address space of Program 2 Hard Disk The operating system swaps pages between memory and the hard disk Each running program has its own page table Pages that cannot fit in main memory are stored on the hard disk As a program is running, the processor translates the linear virtual addresses onto real memory (called also physical) addresses