143A: Principles of Operating Systems Lecture 5: Address translation

Slides:



Advertisements
Similar presentations
Memory Management Unit
Advertisements

1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching,
Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
16.317: Microprocessor System Design I
Intel MP.
OS Memory Addressing.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
UQC152H3 Advanced OS Memory Management under Linux.
IA-32 Processor Architecture
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Memory Management (II)
Chapter 3.2 : Virtual Memory
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.
Segmentation CS 537 – Introduction to Operating Systems.
UNIT 2 Memory Management Unit and Segment Description and Paging
Intel MP (32-bit microprocessor) Designed to overcome the limits of its predecessor while maintaining the software compatibility with the.
Address Translation Mechanism of 80386
1/2002JNM1 With 20 bits, 1,048,576 different combinations are available. Each memory location is assigned a different combination. Each memory location.
Microprocessor system architectures – IA32 segmentation Jakub Yaghob.
The Intel Microprocessors. Real Mode Memory Addressing Real mode, also called real address mode, is an operating mode of and later x86-compatible.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
80386DX.
1 i386 Memory Management Professor Ching-Chi Hsu 1998 年 4 月.
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
ICOM Noack Memory management Virtual memory Paging and segmentation Demand paging Memory management hardware.
1 Microprocessors CSE Protected Mode Memory Addressing Remember using real mode addressing we were previously able to address 1M Byte of memory.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
Chapter 2 The Microprocessor Architecture Microprocessors prepared by Dr. Mohamed A. Shohla.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
What You Need to Know for Project Three Steve Muckle Wednesday, February 19 th Spring 2003.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
Information Security - 2. CISC Vs RISC X86 is CISC while ARM is RISC CISC is Compiler’s heaven while RISC is Architecture’s heaven Orthogonal ISA in RISC.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
CS 140 Lecture Notes: Virtual Memory
16.317: Microprocessor System Design I
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
Paging COMP 755.
Microprocessor Systems Design I
Anton Burtsev February, 2017
143A: Principles of Operating Systems Lecture 6: Address translation (Paging) Anton Burtsev October, 2017.
Anton Burtsev February, 2017
Address Translation Mechanism of 80386
Information Security - 2
x86 segmentation, page tables, and interrupts
Instructor: Junfeng Yang
Page Replacement Implementation Issues
Paging and Segmentation
Virtual Memory Partially Adapted from:
CSCI206 - Computer Organization & Programming
CS 140 Lecture Notes: Virtual Memory
Operating Modes UQ: State and explain the operating modes of X86 family of processors. Show the mode transition diagram highlighting important features.(10.
CS 301 Fall 2002 Computer Organization
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Page Replacement Implementation Issues
CS 140 Lecture Notes: Virtual Memory
Main Memory Session - 16.
Lecture 3: Main Memory.
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Information Security - 2
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
CS 140 Lecture Notes: Virtual Memory
CS444/544 Operating Systems II Virtual Memory
Presentation transcript:

143A: Principles of Operating Systems Lecture 5: Address translation Anton Burtsev October, 2017

Two programs one memory

Very much like car sharing

What are we aiming for? Illusion of a private address space Identical copy of an address space in multiple programs Remember fork()? Simplifies software architecture One program is not restricted by the memory layout of the others

Two processes, one memory?

Two processes, one memory?

This is called segmentation

All addresses are logical address They consist of two parts Segment selector (16 bit) + offset (32 bi

Segment selector (16 bit) Is simply an index into an array (Descriptor Table) That holds segment descriptors Base and limit (size) for each segment

Elements of that array are segment descriptors Base address 0 – 4 GB Limit (size) Access rights Executable, readable, writable Privilege level (0 - 3)

Segment descriptors

Offsets into segments (x in our example) or “Effective addresses” are in registers

Logical addresses are translated into physical Effective address + DescriptorTable[selector].Base

Logical addresses are translated into physical Effective address + DescriptorTable[selector].Base

Logical addresses are translated into physical Effective address + DescriptorTable[selector].Base

Logical addresses are translated into physical Effective address + DescriptorTable[selector].Base

Same picture

Offsets (effective addresses) are in registers Effective address + DescriptorTable[selector].Base But where is the selector?

Right! Segment registers Hold 16 bit segment selectors Pointers into a special table Global or local descriptor table Segments are associated with one of three types of storage Code Data Stack

Programming model Segments for: code, data, stack, “extra” A program can have up to 6 total segments Segments identified by registers: cs, ds, ss, es, fs, gs Prefix all memory accesses with desired segment: mov eax, ds:0x80 (load offset 0x80 from data into eax) jmp cs:0xab8 (jump execution to code offset 0xab8) mov ss:0x40, ecx (move ecx to stack offset 0x40)

Segmented programming (not real) static int x = 1; int y; // stack if (x) { y = 1; printf (“Boo”); } else y = 0; ds:x = 1; // data ss:y; // stack if (ds:x) { ss:y = 1; cs:printf(ds:“Boo”); } else ss:y = 0;

Programming model, cont. This is cumbersome, so infer code, data and stack segments by instruction type: Control-flow instructions use code segment (jump, call) Stack management (push/pop) uses stack Most loads/stores use data segment Extra segments (es, fs, gs) must be used explicitly

Code segment Code CS register EIP is an offset inside the segment stored in CS Can only be changed with procedure calls, interrupt handling, or task switching

Data segment Data DS, ES, FS, GS 4 possible data segments can be used at the same time

Stack segment Stack SS Can be loaded explicitly OS can set up multiple stacks Of course, only one is accessible at a time

Segmentation is ok... but

What if process needs more memory?

What if process needs more memory?

You can relocate P2

Or even swap it out to disk

Problems with segments But it's inefficient Relocating or swapping the entire process takes time Memory gets fragmented There might be no space (gap) for the swapped out process to come in Will have to swap out other processes

Paging

Pages

Pages

Paging idea Break up memory into 4096-byte chunks called pages Modern hardware supports 2MB, 4MB, and 1GB pages Independently control mapping for each page of linear address space Compare with segmentation (single base + limit) many more degrees of freedom

Page translation

Page translation

Page directory entry (PDE) 20 bit address of the page table Pages 4KB each, we need 1M to cover 4GB R/W – writes allowed? To a 4MB region controlled by this entry U/S – user/supervisor If 0 – user-mode access is not allowed A – accessed

Page table entry (PTE) 20 bit address of the 4KB page Pages 4KB each, we need 1M to cover 4GB R/W – writes allowed? To a 4KB page U/S – user/supervisor If 0 user-mode access is not allowed A – accessed D – dirty – software has written to this page

Page translation

Back of the envelope If a page is 4K and an entry is 4 bytes, how many entries per page? 1k How large of an address space can 1 page represent? 1k entries * 1page/entry * 4K/page = 4MB How large can we get with a second level of translation? 1k tables/dir * 1k entries/table * 4k/page = 4 GB Nice that it works out that way!