当前位置:网站首页>Virtual address space

Virtual address space

2022-07-07 08:28:00 Scroll_ C

Virtual address space

  • project
  • 2021/11/27

Is this page helpful ?

When the processor reads or writes to a memory location , It uses a virtual address . During a read or write operation , The processor converts the virtual address to the physical address . Accessing memory through a virtual address has the following advantages :

  • Programs can use a series of contiguous virtual addresses to access discontinuous large memory buffers in physical memory .

  • A program can use a series of virtual addresses to access memory buffers larger than the available physical memory . When the supply of physical memory changes , The memory manager will put physical memory pages ( Usually the size is 4 KB) Save to disk file . Data or code pages move between physical memory and disk as needed .

  • Virtual addresses used by different processes are isolated from each other . Code in one process cannot change the physical memory being used by another process or operating system .

The range of virtual addresses available to a process is called the “ Virtual address space ” . Each user mode process has its own private virtual address space . about 32 Bit process , The virtual address space is usually 2 GB, Range from 0x00000000 to 0x7FFFFFFF. about 64 position Windows Upper 64 Bit process , The virtual address space is 128 TB, Range from 0x000'00000000 to 0x7FFF'FFFFFFFF. A series of virtual addresses is sometimes called a series “ Virtual memory ” . For more information , see also Memory and address space limitations .

This figure illustrates some important functions of virtual address space .

The figure shows two 64 Virtual address space of bit process :Notepad.exe and MyApp.exe. Each process has its own virtual address space , Range from 0x000'0000000 to 0x7FF'FFFFFFFF. Each shadow block represents a page of virtual memory or physical memory ( The size is 4 KB). Be careful ,Notepad Process use from 0x7F7'93950000 Three consecutive pages of the starting virtual address . However, these three consecutive pages of the virtual address will be mapped to discontinuous pages in physical memory . Attention, please. , Both processes use from 0x7F7'93950000 Start virtual memory page , But these virtual pages map to different pages of physical memory .

User space and system space

Such as Notepad.exe and MyApp.exe The process of runs in user mode . The core operating system components and multiple drivers run in a more privileged kernel mode . More about processor mode , see also User mode and kernel mode . Each user mode process has its own private virtual address space , But all code running in kernel mode is shared as “ System space ” A single virtual address space . The virtual address space of user mode processes is called “ User space ” .

stay 32 position Windows in , The total virtual address space available is 2^32 byte (4 GB). Usually , Lower 2 GB For user space , Higher 2 GB For system space .

stay 32 position Windows in , You can choose to specify ( When it starts ) exceed 2 GB Available in user space . As a result, less virtual addresses are available in the system space . You can increase the size of user space to 3 GB, under these circumstances , The system space is only 1 GB You can use . To increase the size of user space , Please use  BCDEdit /set increaseuserva.

stay 64 position Windows in , The theoretical size of virtual address space is 2^64 byte (16 Ebyte ), But in fact, only 16 A small part of the byte range .

Code running in user mode can access user space , But you cannot access the system space . This restriction prevents user mode code from reading or changing protected operating system data structures . Code running in kernel mode can access user space , You can also access system space . namely , Code running in kernel mode can access the system space and the virtual address space of the current user mode process .

Drivers running in kernel mode must be very careful when reading or writing these addresses directly from user space addresses . This scheme explains the reason .

  1. The user mode program initiates a request to read some data from the device . The program provides the starting address of the buffer to receive data .

  2. The device driver routine running in kernel mode starts the read operation and returns control to its caller .

  3. later , The device interrupts any currently running thread to show that the read operation is complete . Interrupt this arbitrary thread ( Belongs to any process ) Kernel mode driver routines running on .

  4. here , The driver must not write data to the user mode program in step 1 The starting address provided in . This address is in the virtual address space of the process that initiated the request , This process is likely to be different from the current process .

Paging buffer pool and non paging buffer pool

In user space , All physical memory pages can be called out to disk files as needed . In system space , Some physical pages can be called , Other physical pages cannot . The system space has two areas for dynamically allocating memory : Paging buffer pool and non paging buffer pool .

The memory allocated in the paging buffer pool can be called out to disk files as needed . The memory allocated in the non paged buffer pool can never be called out to disk files .

原网站

版权声明
本文为[Scroll_ C]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130640312678.html