Windows Memory Architecture 井民全製作. A Process ’ s Virtual Address Space Every Process has its own private virtual address 32-bits processes  4 GB address.

Slides:



Advertisements
Similar presentations
Windows 2000 I/O System, Cache Manager and File Systems Computing Department, Lancaster University, UK.
Advertisements

Memory Management: Overlays and Virtual Memory
Memory Management Operating Systems Lecture 4, April 3, 2003 Mr. Greg Vogl Uganda Martyrs University.
Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions.
© Neeraj Suri EU-NSF ICT March 2006 Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék Zoltán Micskei
CS 620 Advanced Operating Systems Lecture 6 – Windows Architecture Professor Timothy Arndt BU 331.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
Case Study: Windows 2000 Part I Will Richards CPSC 550 Spring 2001.
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
1 CE6130 現代作業系統核心 Modern Operating System Kernels 許 富 皓.
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH. Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly.
Introduction to NT Operating system
Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?
Chapter 6 - Implementing Processes, Threads and Resources Kris Hansen Shelby Davis Jeffery Brass 3/7/05 & 3/9/05 Kris Hansen Shelby Davis Jeffery Brass.
 Demand Technology Software, Inc. 32-bit Virtual Memory Constraints in Windows 2000 and 2003 Mark Friedman Demand Technology 1020 Eighth Avenue South,
 Demand Technology Software, Inc. Memory Leaks Demand Technology 1020 Eighth Avenue South, Suite 6, Naples, FL phone: (941) fax: (941)
Introduction to Windows System Internals part II by Tim Shelton Black Security
Oracle Memory Configuration on Windows Server Configuring Large Memory for Oracle on 32-bit and 64-bit Windows.
Windows 2000 Memory Management Computing Department, Lancaster University, UK.
By Matthew Smith, John Allred, Chris Fulton. Requirements Relocation Protection Sharing Logical Organization Physical Organization.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Ceng Operating Systems
Module 3: Resolving Boot Process Issues. Overview Understanding the Boot Process Using Advanced Boot Options Using the Boot.ini file to Change Startup.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 11 Case Study 2: Windows Vista Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
 Demand Technology Software, Inc. 32-bit Virtual Memory Constraints in Windows: an Update Mark Friedman Demand Technology 1020 Eighth Avenue South,
EMB426 Windows CE Memory Architecture Steve Maillet CEO/Chief Software Architect EmbeddedFusion.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
CS 444 Introduction to Operating Systems
April 2000Dr Milan Simic1 Network Operating Systems Windows NT.
The disk surface is divided into tracks. into tracks. 1.
Windows XP. History Windows XP is based on the NT kernel developed in 1988 Windows XP is based on the NT kernel developed in 1988 XP was originally sold.
Windows 2000 Course Summary Computing Department, Lancaster University, UK.
Dr. Richard Ford  Szor 12  Virus Scanners – why they need to scan memory and what issues there are in this area.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Topic 2d High-Level languages and Systems Software
Chapter 14 Supporting Windows 2000 Professional. 14 You Will Learn… n About the different operating systems within the Windows 2000 suite n About the.
2003 Dominic Swayne1 Microsoft Disk Operating System and PC DOS CS-550-1: Operating Systems Fall 2003 Dominic Swayne.
Win32 Programming Lesson 14: Introducing Windows Memory (C Rox…)
Introduction to Operating Systems and Concurrency.
Copyright © 2002 Heathkit Company, Inc. All rights reserved. Unit 5 Windows 2000/XP History, and Data Management.
Operating System Concepts Part II Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki
System Components ● There are three main protected modules of the System  The Hardware Abstraction Layer ● A virtual machine to configure all devices.
UNIX & Windows NT Name: Jing Bai ID: Date:8/28/00.
Memory Management: Overlays and Virtual Memory. Agenda Overview of Virtual Memory –Review material based on Computer Architecture and OS concepts Credits.
Chapter Eleven Windows XP Professional Application Support.
Win32 Programming Lesson 19: Introduction to DLLs.
Windows Threading Colin Roby Jaewook Kim.
“WALK IN” SLIDE. August Memory Management Internals Steve Smith Software Design Engineer Game Technology Group Microsoft Presentation/Presenter.
Overview of Windows Driver Development Reference: us/gstart/hh/gstart/gs_intro_031j.asp.
Memory Management Chapter 5 Advanced Operating System.
CITA 171 Section 1 DOS/Windows Introduction. DOS Disk operating system (DOS) –Term most often associated with MS-DOS –Single-tasking operating system.
Introduction to Operating Systems Concepts
Chapter 3: Windows7 Part 5.
Microsoft in the Enterprise
Windows API.
Windows 95 & 98 Steve Boyle Mike Forster Maggie Hamill Nancy O’Brien.
Unit OS2: Operating System Principles
CS490 Windows Internals Quiz 2 09/27/2013.
Chapter 3: Windows7 Part 1.
Chapter 3: Windows7 Part 5.
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
Oracle Memory Configuration on Windows Server
Lecture Topics: 11/1 General Operating System Concepts Processes
Windows NT History Design Principles System Components
Assembly Language for Intel-Based Computers, 5th Edition
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.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/22.
CS444/544 Operating Systems II Virtual Memory
Presentation transcript:

Windows Memory Architecture 井民全製作

A Process ’ s Virtual Address Space Every Process has its own private virtual address 32-bits processes  4 GB address space 64-bits processes  16 EB (extrabytes) A thread in a process can access its own address space Other process’s address space hidden and inaccessible

A thread in process A cannot access the data in process B ’ s address space Process A 0x Process B code 0x Win2K: 作業系統的 記憶體位址是被隱藏 的不被 thread 看到 Win98: 則 thread 可 能會意外存取道系統 的資料 ( 詳情請看後面的 記憶體分佈表 ) Thread access

How a Virtual Address Space is Partitioned Partition32-bit Win bit Win2000 (x86 w/3 GB user mode) Win98 NULL- Pointer Assignment 0x ~ 0x0000FFFF ( 64 KB) 與 32-bit Win2000 一樣 0x ~ 0x00000FFF ( 4 KB) 給 16-bit DOS 程 式 /Windows 相 容區間 沒有 0x ~ 0x003FFFFF ( 4MB ) User-Mode ( 你可使用的區 域 ) 0x ~ 0x7FFEFFFF ( 你可以使用 ~ 2 GB 的空間 ) 0x ~ 0xBFFEFFFF ( 你可以使用 ~ 3 GB 的空間 ) ( 由於一部份用來使用 16-bit 相容, 故可用範圍比較小 ) 0x ~ 0x7FFFFFFF 64-KB 禁區 (Only Win2000) 0x7FFF0000 ~ 0x7FFFFFFF ( 64 KB) 0xBFFF0000~0xBFFFFFFF ( 64 KB) 沒有 DLL 或 Memory Map file 共享區 間 (Only Win98) 沒有 0x ~0xBFFFFFFF ( 1GB) Kernel-Mode ( 作業系統與驅 動程式存放處 ) 0x ~ 0xFFFFFFFF ( 作業系統 2GB) 0xC ~ 0xFFFFFFFF ( 作業系統 1GB) 0xC ~0xFFFFFFFF ( 作業系統 1GB)

Partition 32-bit Win2000 ( 對照組 ) 64-bit Win2000 NULL- Pointer Assignment 0x ~ 0x0000FFFF ( 64 KB) 0x ' ~ 0x '0000FFFF ( 64 KB) 給 16-bit DOS 程式 /Windows 相容區間 沒有 User-Mode ( 你可使用的區域 ) 0x ~ 0x7FFEFFFF ( 你可以使用 ~ 2 GB 的空間 ) 0x ' ~ 0x000003FF'FFFEFFFF ( 你只能使用 ~ 2 GB 的空間, 為了相容 32bit 程式 ) ( 使用 /LARGEADDRESSAWARE link 才能使用 ~4 TB) 64-KB 禁區 (Only Win2000) 0x7FFF0000 ~ 0x7FFFFFFF ( 64 KB) 0x000003FF'FFFF0000 ~ 0x000003FF'FFFFFFFF ( 64 KB) DLL 或 Memory Map file 共享區間 (Only Win98) 沒有 Kernel-Mode ( 作業系統與驅動程式 存放處 ) 0x ~ 0xFFFFFFFF ( 作業系統 2GB) 0x ' ~ 0xFFFFFFFF'FFFFFFFF ( 作業系統 16,777,212-TB ) 數量單位對照表 修正 並沒有完全使用到

How a Virtual Address Space is Partitioned (64k for W2k, 4K for W98) Null-Pointer Assignment Partition Help to detect NULL-pointer assignments Any thread attempts to read/ write this partition  access violation int* pnSomeInteger=(int*) malloc(sizeof(int)); *pnSomeInteger=5; 當 malloc 配置記憶體不足時, 會傳回 NULL, 上面的程式會導致存取位址空間 0x

Windows 98 Only - MS-DOS/16 Bits Windows AP compatibility partition 4MB address space (0x – 0x003fffff) For MS-DOS or 16-bits Windows AP Our 32-bits AP should not attempt to access this partition 在 Win2000 中, 這區段屬於 User Mode

User-Mode Partition (0x x7FFEFFFF 大約是 2 G bytes) 剩下空間的給 User-Mode The process’s private address space One process cannot access another process’s data in this partition Win2000: 1. all.exe and DLL modules load in this area 2. System also maps all memory-mapped files within this partition Win98: 1. System DLLs load in the Shared Memory Mapped File partition 2. all shared DLLs will be the same virtual address for all processes 3. memory-mapped files never appear in the user-mode area System DLLs  Kernel32, AdvAPI32, User32 and GDI32

A Large outcry from developers Getting a 3-GB User-Mode Partition (1G for Kernel) Enable this mode [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Pro" multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Pro with /3GB" /3GB Windows XP Professional (and greater) - Windows Server Windows Server 2003, Enterprise Edition - Windows Server 2003, Datacenter Edition - Windows 2000 Advanced Server - Windows 2000 Datacenter Server - Windows NT Server 4.0, Enterprise Edition 參考資料 : Linking setup /LARGEADDRESSAWARE boot.ini

Penalty for the 3-GB Mode Reduce the number of threads, stack and other resource 使你程式可以存取 3 GB 的相關資料 ms-help://MS.MSDNQTR.2004JAN.1033/memory/base/4gt_ram_tuning.htm 參考資料

64-bits Windows A lots of source code in which pointers are assumed to be 32-bit values 系統必須保證動態配置的 記憶體不會高於 0x FFFFFFF 位址空間 除非, 你的 AP 使用 /LARGEADDRESSAWA RE 建立, 否則預設的情 況下, 只能使用 2-GB 位 址空間 (DLL 不受影響 ) 4-TB address space in 64-bits Windows 在 64-bit 環境配置記憶體 位址可能高於 2G, 但是你的 程式卻以為位址只有 32 bits 這樣會發生 Pointer Truncation 問題. 在 64-bit 環境配置記憶體 位址可能高於 2G, 但是你的 程式卻以為位址只有 32 bits 這樣會發生 Pointer Truncation 問題. user mode 在 64-bit 環境中, 呼叫 32-bit DLL 並傳送位址 ( 超過 2G) 給它處理 在 64-bit 環境中, 呼叫 32-bit DLL 並傳送位址 ( 超過 2G) 給它處理

64-KB Off-Limits Partition (W2k Only) (0x7FFF0000-0x7FFFFFFF) Access  access violation 因為高層的位址空間 (0x 以上 ) 只有 Kernel mode 程式能夠存取, 為了檢查位址 更快速,Windows 2000 保留這部分的記憶 體區間. 0x 以上 64k 空間保留 User-Mode 可使用 的空間 0x7FFF0000 0x7FFFFFFF access violation

Win98 Only Shared MMF Partition (0x xBFFFFFFF 大約1GB ) System store data that is shared all 32-bits processes System DLLs are all loaded in this area with the same address for every processes System also maps all memory- mapped file in this partition

Kernel-Mode Partition The area is where the OS’s code resides Thread scheduling, memory management, File systems support, networking support, All device drivers is loaded in this partition Shared among all processes Access  access violation (win2000) Win98: the data in this partition is not protected (Any AP can corrupt the OS)

Regions in an address space VirtualAlloc  allocating a region The region begins on an allocation granularity boundary (64KB) The size is a multiple of the page size (4-KB for win2K) Ex: If you attempt to reserve a 10-KB region of address space  12-KB VirtualFree  releasing the region The system reserves regions for your process 1. PEB (Process environment block) 2. TEB (Thread environment block) 不同 CPU 有不同的 page size (Intel Itanium  8k bytes) Process 用來管理 Thread 的區塊 System 用來管理 Process 的區塊 這兩個由系統管理的 Region 並不受起始位址的限制 12 % 4 =0 你可以用 GetSysteInfo API 得到 page size 你可以用 GetSysteInfo API 得到 page size 使用的部分 0x xxxxx 下一個配置的起點 0x K-byte

Committing Physical Storage Within a Region Before you use a reserved regions, you must Allocate physical storage Map this storage to the reserved region Note Physical storage is always committed in pages Call VirtualAlloc( ) to do this Decommitting by calling VirtualFree( ) Committing process 看範例程式 : VirtualAlloc 動態配置記憶體

重要參考資料 ms- help://MS.MSDNQTR.2004JAN.1033/dngenli b/html/msdn_ntvmm.htm