Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ The virtual memory     - iOS in the event delivery and the responder chain (Programming)

- CentOS7 installation hardware monitoring for Zabbix enterprise applications (Server)

- Vagrant failed to start, stuck in Waiting for VM to boot solution (Linux)

- About Hibernate cache, you want the latest data have trouble even session.clear (Database)

- CentOS yum source deployment (Linux)

- Oracle to create an external table (Database)

- Different versions of MongoDB achieve master-slave replication (Database)

- Linux yum command Detailed (Linux)

- How to download apk file from the Google Play store on Linux (Linux)

- cursor_sharing induced error ORA-00600 (Database)

- Linux systems use IP masquerading anti-hacker (Linux)

- C # and JavaScript arrays to re-summary (Programming)

- How to install with JSON support in Ubuntu 15.04 SQLite 3.9.1 (Database)

- Linux more command Detailed (Linux)

- Linux system boot process detail (Linux)

- Ubuntu under Spark development environment to build (Server)

- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)

- Setting CentOS firewall open port (Linux)

- Ubuntu 14.04 How to set up an SSH without password (Linux)

- Oracle row and column switch to turn columns (Database)

 
         
  The virtual memory
     
  Add Date : 2017-08-31      
         
         
         
  What is virtual memory?

First introduce some extract directly on wikipedia.

Virtual memory is a computer system memory management technology. It makes the application thinks it has successive available memory (complete a continuous address space), but in fact, it usually is divided into a plurality of physical memory fragmentation, there are some temporarily stored on an external disk storage is required when data exchange.

For the C language variables, we can use the & operator to obtain its address, since it is a virtual address refers to the address of the virtual.

Virtual address mechanism is not necessary, in a simple microcontroller, compiled code written when physical RAM is required to specify the spatial distribution, there will be no concept of the virtual address, the address refers to a physical address in RAM.

Why do we need virtual memory?

The following is my understanding, there may be an inappropriate place.

Suppose you run a program on the bare metal, then there is no way to re-execute other programs at the same time, the need to introduce the operating system to manage. Once you have the operating system, we might be able to run several different programs, but it may not be able to execute multiple instances of the same program at the same time, because the program uses the same physical address is the same (assuming the old compiler), together running conflict there. Want to run multiple instances of the same program, it seems there are two kinds of programs.

Use a different address to recompile a program, and not before a conflict.
Use the Add address offset other ways to ensure that the use of a different address when running the program.
The first is to allow the compiler to complete, in theory you can, but it will be too much trouble, if I want to run three, four do, it is necessary to compile more than a few times.
Second it is to allow the operating system to complete, should be regarded as the prototype of the virtual memory. After using this mode, the program inside the compiler gives the associated address is not the actual physical address, and be a virtual address.

X86 virtual memory technology

GDT / LDT

GDT and LDT are introduced into the x86 system in 80286 when, LDT and GDT has a similar structure. LDT is the emergence of multiple processes to use a separate address space and services, typically one process per LDT, and shared memory and kernel memory use GDT. Each program to determine the base address of the descriptor based on, but there is also a limit for each Entry field, just to make space for program access restrictions. But in the 80386 introduced better after paging technology, LDT basically no longer in use.

Paging

As the implementation of the current paging virtual memory technique, there must be a better place than the LDT, but their realization of ideas are similar. The operating system maintains a handle for each process, the handle is associated with the relevant data blocks of the conversion process from the virtual to physical address. The handle is in the LDT LDT pointer and length, data block is LDT itself. By paging mode data block is called paging structure, handler is a pointer thereto.

paging structure has 4096 bytes, contains separate entries, different in different modes of the size of each entry. Each entry contains a physical address, you can point to a page frame, can also point to another paging structur, it is the cascade. Points to the first page structure pointer in the CR3 register, then from the linear address to a physical address in the process is an iterative process. Part of the linear address to indicate corresponding entry, if the entry points to another page structure will continue until the point of a page frame address indicates that the conversion is complete, use this last entry as the base linear address the remaining portion of the partial representation shift.

Now devoted tab 32bit mode. 32bit Under each entry 4bytes, each paging structure contains 1024 entries, 10bit need to distinguish each entry. In fact under 32bit mode using Level 2 pageing structure. The first stage is called Page Directory, use 32bit linear address bits 31-22 to distinguish, the second stage called the Page Table, using 32bit linear address bits 21-12 to distinguish, and the rest is just bits 11-0 calculated in 4K page in the offset.

In all linear addresses to physical address translation, CR3, PDPTE, PDT, PTE, etc. are stored in the base address of the next, the linear address is stored in the offset.
     
         
         
         
  More:      
 
- Installation Elementary OS Freya to do some settings (Linux)
- RabbitMQ tutorial examples: RabbitMQ installation under Windows (Linux)
- C ++ precision performance test function (Programming)
- Oracle first Automated Installation Packages (Database)
- Linux device driver development small example --LED lights (Programming)
- Ubuntu 14.04 compile and install Apache (Server)
- Large computer network security policy Experience (Linux)
- Spring AOP for logging (Programming)
- Shell script to crawl through AWR SQL Report Problems (Database)
- C ++: Postmodern systems programming language (Programming)
- Git bulk delete remote tag (Linux)
- 5 fast Node.js application performance tips (Programming)
- Ubuntu prevent arp attacks (Linux)
- Terminal multiplexing tool tmux use (Linux)
- Ordinary users how to use the firewall software (Linux)
- Java object initialization (Programming)
- Under Linux using Magent + Memcached cache server cluster deployment (Server)
- Python KNN algorithm of actual realization (Programming)
- Ubuntu install code editor Sublime Text 3 (Linux)
- See Linux kernel, CPU, memory, and various versions of the command module and means (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.