System page table based address mapping method, apparatus, and storage medium
By using system page tables to store the virtual and physical address mapping relationships of processes on smart devices, the problem of excessive memory consumption by page tables is solved, and device operating efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TONGJI UNIV
- Filing Date
- 2023-03-31
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies using page tables on smart devices consume excessive memory, leading to reduced device operating efficiency.
The system page table is used to store the mapping relationship between the virtual address and physical address of the process in the current processor. By creating the system page table during system initialization and establishing the mapping relationship between the virtual address and physical address of process data in the system page table, the memory occupied by storing the address mapping relationship is reduced.
It effectively reduces the memory occupied by storage address mapping relationships, improves device operating efficiency, and is suitable for special scenarios with small system memory.
Smart Images

Figure CN116541314B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of computer system storage management, and in particular to an address mapping method, apparatus and storage medium based on system page tables. Background Technology
[0002] In an operating system, one of the functions of memory management is to provide strategies for managing memory space. Implementing this management requires configuring a memory management module within the operating system.
[0003] The memory management module typically creates a separate page table for each running process to store the address mapping relationship of the corresponding process, that is, the mapping relationship between virtual addresses and physical addresses.
[0004] However, in some special fields, such as operating systems on smart devices, the page tables used by existing technologies consume too much memory relative to the system memory in that scenario due to the relatively small system memory. This ultimately leads to reduced operating efficiency of smart devices and a degraded user experience. Summary of the Invention
[0005] Based on the above analysis, this application aims to propose an address mapping method, apparatus, and storage medium based on system page tables to reduce the memory occupied by storage address mapping relationships, thereby improving device operating efficiency.
[0006] Firstly, one or more embodiments of this specification provide an address mapping method based on a system page table, wherein a system page table is created during system initialization, and the method includes:
[0007] The system page table is used to store the mapping relationship between the virtual addresses and physical addresses of the processes currently running in the processor.
[0008] Furthermore, the system page table includes multiple page table entries for storing the physical addresses of process data, and each page table entry corresponds to a virtual space of a fixed size;
[0009] Before using the system page table to store the mapping relationship between the virtual addresses and physical addresses of the processes currently running in the processor, the method further includes:
[0010] After a new process is created, the process data includes: code segment data, data segment data, and stack segment data;
[0011] Obtain the starting physical address of the code segment data, the data segment data, and the stack segment data stored in physical memory, respectively.
[0012] Calculate the number of physical page frames occupied by the code segment data, the data segment data, and the stack segment data respectively;
[0013] Obtain the starting address of the process data in the virtual space;
[0014] Based on the starting address in the virtual space, determine its starting page table entry in the system page table;
[0015] The step of using the system page table to store the mapping relationship between the virtual addresses and physical addresses of processes currently running in the processor includes:
[0016] Based on the starting page table entry of the process data in the system page table, and according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, a mapping relationship between the virtual address and the physical address of the process data is established and stored in the system page table.
[0017] Furthermore, the system page table includes multiple page table entries for storing the physical addresses of process data, and each page table entry corresponds to a virtual space of a fixed size;
[0018] The step of establishing and storing the mapping relationship between the virtual address and physical address of the process data in the system page table based on the starting page table entry of the process data in the system page table, and based on the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, includes: determining the page table entry corresponding to the code segment data, the page table entry corresponding to the data segment data, and the page table entry corresponding to the stack segment data respectively, according to the order of code segment data, data segment data, and stack segment data;
[0019] Based on the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, the corresponding physical page frame number of the code segment data, the data segment data, or the stack segment data is filled in the corresponding page table entry to establish and store the mapping relationship between the virtual address and the physical address of the process data.
[0020] Further, determining the page table entry corresponding to the code segment data based on the starting page table entry of the process data in the system page table and the number of physical page frames occupied by the code segment data includes:
[0021] The starting page table entry of the process data in the system page table is determined to be the starting page table entry corresponding to the code segment data;
[0022] Based on the number of physical page frames occupied by the code segment data, determine the other page table entries corresponding to the code segment data;
[0023] The number of physical page frames occupied by the code segment data is the same as the number of page table entries corresponding to the code segment data.
[0024] Further, determining the page table entry corresponding to the data segment includes:
[0025] The last page table entry corresponding to the code segment data is determined to be the target page table entry;
[0026] The next page table entry of the target page table entry is determined to be the starting page table entry corresponding to the data segment data;
[0027] Based on the number of physical page frames occupied by the data segment, determine the other page table entries corresponding to the data segment;
[0028] The number of physical page frames occupied by the data segment is the same as the number of page table entries corresponding to the data segment.
[0029] Further, determining the page table entry corresponding to the stack segment data includes:
[0030] The last page table entry in the system page table is determined to be the last page table entry corresponding to the stack segment data;
[0031] Based on the number of physical page frames occupied by the stack segment data, determine the other page table entries corresponding to the stack segment data;
[0032] The number of physical page frames occupied by the stack segment data is the same as the number of page table entries corresponding to the stack segment data.
[0033] Furthermore, the method also includes: when the processor schedules a new process, using the mapping relationship between the virtual address and physical address of the new process to overwrite the mapping relationship between the virtual address and physical address currently stored in the system page table.
[0034] Secondly, one or more embodiments of this specification provide an address mapping device based on a system page table, including: a page table creation module and a data processing module;
[0035] The page table creation module is used to create a system page table during system initialization.
[0036] The data processing module is used to store the mapping relationship between the virtual address and physical address of the currently running process in the processor using the system page table.
[0037] Furthermore, after creating a new process, the process data includes: code segment data, data segment data, and stack segment data;
[0038] The device further includes: an acquisition module;
[0039] The acquisition module is used to acquire the starting physical addresses of the code segment data, the data segment data, and the stack segment data stored in physical memory, respectively; calculate the number of physical page frames occupied by the code segment data, the data segment data, and the stack segment data, respectively; the starting address of the process data in the virtual space; and determine the starting page table entry of the process data in the system page table based on the starting address in the virtual space.
[0040] The data processing module is used to establish and store a mapping relationship between the virtual address and the physical address of the process data in the system page table based on the starting page table entry of the process data, according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data.
[0041] Thirdly, one or more embodiments of this specification provide a storage medium, including:
[0042] Used to store computer-executable instructions, which, when executed, implement the method described in the first aspect.
[0043] Compared with the prior art, this application can achieve at least the following technical effects:
[0044] This application establishes address mapping relationships based on the system page table created during system startup. This means that this application does not require the creation of additional page tables to store the virtual and physical address mapping relationships for each process, which can minimize the memory occupied by storing address mapping relationships. At the same time, considering the characteristics of special scenarios such as small system memory and processes usually operating in serial mode, address mapping relationships are only created for currently running processes, which reduces the memory occupied by storing address mapping relationships while also ensuring the applicability of the address mapping method to the operating system. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in one or more embodiments of this specification or in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 A virtual-to-real mapping table used in existing technologies;
[0047] Figure 2 This specification provides a schematic diagram of the page table storage mapping relationship in a single-processor system for one or more embodiments;
[0048] Figure 3 This specification provides a schematic diagram of page table storage mapping relationships in a multiprocessor system for one or more embodiments;
[0049] Figure 4 This specification provides a flowchart of an address mapping method based on a system page table for one or more embodiments. Detailed Implementation
[0050] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this document.
[0051] In existing technologies, the establishment of address mapping relationships is as follows: Figure 1 As shown, each smallest storage area in memory is called a block or frame, and a running user program is called a process. The smallest unit for storing virtual addresses in a process is called a page. Therefore, in the prior art, a separate page table is established for each process, and a mapping relationship between virtual addresses and physical addresses is established in the page table based on the page number and block / frame number. It should be noted that, in the embodiments of this application, the address mapping relationship is the mapping relationship between virtual addresses and physical addresses.
[0052] For typical personal computer devices, a page table is usually 4KB in size, and the device's memory is relatively large. The memory space required to establish the address mapping page table in the above manner is only a small fraction of the total memory, or even negligible. Therefore, this method does not affect the operating system's efficiency. However, for micro-devices and some small intelligent devices, such as smart cars with hundreds of various intelligent modules, the memory occupied by the operating system of each module is usually not very large. In this case, the memory occupied by a 4KB data table cannot be ignored.
[0053] To address the above problems, this application proposes an address mapping method based on system page tables:
[0054] During system initialization, a system page table is created. This page table stores the mapping between the virtual and physical addresses of processes currently running on the processor. This application utilizes this system page table to store these address mappings. Figure 2 As shown, the page table of the single-processor system consists of two physical page frames, 0x300# and 0x301#. 0x300# is the kernel page table, and 0x301# is the user page table. This application uses 0x301# to create and store the mapping relationship between the virtual address and physical address of the user process pa. Without loss of generality, both the kernel page table and the user page table are 4KB in size. It should be noted that... Figure 2 This is a specific implementation of this application on an x86 system with only 32MB of memory. To highlight the user space address mapping relationship, the details of the second-level page table and the kernel-mode page table are omitted.
[0055] In multi-core systems, a separate system page table is used for each CPU, rather than a separate page table for each process. This means that each process running on a different CPU will use its own page table, which significantly reduces the memory usage of processes running on a multi-core system. Figure 3 As shown, all processes running on CPU0 use the user page table stored in physical page frame 0x301#, while all processes running on CPU1 use the user page table stored in physical page frame 0x302#. This ensures that each CPU runs independently while minimizing the memory space occupied by the calling processes.
[0056] like Figure 4 As shown, the address mapping method provided in this application embodiment specifically includes the following steps:
[0057] Step 1: Obtain the starting physical addresses of the code segment data, data segment data, and stack segment data stored in physical memory, respectively.
[0058] In this embodiment of the application, process data includes: code segment data, data segment data, and stack segment data. That is, storing process data essentially means storing code segment data, data segment data, and stack segment data.
[0059] Step 2: Calculate the number of page frames occupied by the code segment data, data segment data, and stack segment data respectively.
[0060] In this embodiment, code segment data, data segment data, and stack segment data are stored in physical memory within one or more consecutive page frames. Therefore, by calculating the number of page frames and combining it with the starting address, the physical page frame number of each data item can be obtained.
[0061] Specifically, the process code segment length is divided by 4KB (page frame size) and rounded up to obtain the number of page frames occupied by the process code segment. The process data segment length is divided by 4KB and rounded up to obtain the number of page frames occupied by the process data segment; the process stack segment length is divided by 4KB and rounded up to obtain the number of page frames occupied by the process stack segment.
[0062] Step 3: Obtain the starting page table entry of the process data in the system page table.
[0063] In this embodiment of the application, the starting page table entry of process data in the system page table is stored in the process control block (PCB).
[0064] Step 4: Based on the starting page table entry of the process data in the system page table, according to the starting physical address of the code segment data, the starting physical address of the stack segment data, the starting physical address of the data segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, establish and store the mapping relationship between the virtual address and the physical address of the process data in the system page table.
[0065] In this embodiment, when the CPU accesses process data in physical memory, it first provides the virtual address of the process data, and then calculates the physical address of the process data based on the virtual address. The key to this process is creating and storing the mapping relationship between virtual addresses and physical addresses.
[0066] Establishing a mapping relationship requires finding two symbols to represent the virtual address and the physical address, respectively. In the embodiments of this application, process data (code segment data, data segment data, and stack segment data) exists in multiple consecutive regions (e.g., Figure 2 , Figure 3As shown in the diagram, this contiguous region comprises multiple page frames. Therefore, the physical memory address of a process can be described using the starting physical address of this contiguous region and the number of page frames occupied by process data. Similarly, the virtual memory address of a process can be described using the starting virtual address and the number of pages occupied by process data. In the operating system, the number of page frames / pages occupied by code segment data, data segment data, and stack segment data can be set. For example, dividing the code length by 4KB and rounding up yields the number of page frames / pages occupied by code segment data, data segment data, and stack segment data. That is, the number of page frames / pages occupied by code segment data, data segment data, and stack segment data can be preset, allowing the physical and virtual memory addresses to be represented using only the starting physical and virtual addresses.
[0067] Specifically, in practice, the system page table includes multiple page table entries for storing the physical addresses of process data, with each page table entry corresponding to a fixed-size virtual space. Based on the starting page table entry for process data in the system page table, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, the page table entries corresponding to the code segment data, data segment data, and stack segment data are determined respectively, in the order of code segment data, data segment data, and stack segment data. Based on the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, the corresponding physical page frame number of the code segment data, data segment data, or stack segment data is filled into the corresponding page table entry to establish and store the mapping relationship between the virtual address and physical address of the process data.
[0068] It should be noted that the system page table includes multiple page table entries for storing the physical addresses of process data, with each page table entry corresponding to a fixed-size virtual space. The starting addresses and lengths of the physical and virtual spaces are registered in the Process Control Block (PCB). The PCB is a private kernel data structure for each process. Therefore, the page table entry corresponding to each piece of data can be determined based on its starting address and the number of physical page frames.
[0069] exist Figure 2 In the illustrated embodiment, the page frame containing the starting physical address of the code segment data corresponds to the starting page table entry for the process data in 0x301#. Since there is a correspondence between the page table entry in 0x301# and the virtual address space, filling in the physical page frame numbers occupied by the process data into the corresponding page table entries completes the establishment and storage of the mapping relationship between the virtual address and physical address of the process data.
[0070] After determining the starting page frame of the process data in the system page table, based on the starting page frame of the process data in the system page table, and according to the number of physical page frames occupied by the process data, the page table entries corresponding to the code segment data, the data segment data, and the stack segment data are determined respectively in the order of code segment data, data segment data, and stack segment data.
[0071] Specifically, for code segment data:
[0072] The starting page table entry for process data in the system page table is determined to be the starting page table entry corresponding to the code segment data; other page table entries corresponding to the code segment data are determined based on the number of physical page frames occupied by the code segment data.
[0073] The number of physical page frames occupied by the code segment data is the same as the number of page table entries corresponding to the code segment data.
[0074] For the data segment:
[0075] The last page table entry corresponding to the code segment data is identified as the target page table entry; the next page table entry corresponding to the target page table entry is identified as the starting page table entry corresponding to the data segment data. Based on the number of physical page frames occupied by the data segment data, the other page table entries corresponding to the data segment data are determined.
[0076] The number of physical page frames occupied by the data segment is the same as the number of page table entries corresponding to the data segment.
[0077] For stack segment data:
[0078] Determine the last page table entry in the system page table as the last page table entry corresponding to the stack segment data; determine the other page table entries corresponding to the stack segment data based on the number of physical page frames occupied by the stack segment data.
[0079] The number of physical page frames occupied by stack segment data is the same as the number of page table entries corresponding to the stack segment data.
[0080] In this embodiment, when the processor calls a new process, the virtual address-physical address mapping of the new process is used to overwrite the virtual address-physical address mapping currently stored in the system page table. In this way, the system page table does not occupy too much memory, while ensuring the normal operation of the operating system.
[0081] In this embodiment, in addition to filling in the corresponding physical page frame number in the page table entry, an existence bit (P value), a read / write bit (R / W), and a U / S identifier are also filled in. The existence bit indicates whether the physical page frame corresponding to code segment data, data segment data, and stack segment data exists in physical memory. The read / write bit indicates whether the relevant data is readable or writable, and the U / S identifier distinguishes between application pages and operating system pages.
[0082] For example, when P=1, the physical page frames corresponding to code segment data, data segment data, or stack segment data exist in physical memory. When P=0, the physical page frames corresponding to code segment data, data segment data, or stack segment data do not exist in physical memory. R / W=1 indicates that code segment data, data segment data, or stack segment data are read-only, and R / W=0 indicates that code segment data, data segment data, or stack segment data are both readable and writable. In the U / S identifier, S represents kernel pages, and U represents user pages.
[0083] The address mapping method proposed in this invention is accurate and effective. We have implemented a... Figure 2 The system shown in the specific embodiment. This single-core computer system has only 32MB of memory, but it can support multiple concurrent programs using only a 4KB system user page table. It can run many applications, including the command-line interface bash, the standard Unix Utility set, and ordinary user interface C programs. In addition, we wrote a test program Stack to examine the time required to establish address mapping relationships. The specific method is as follows: the Stack test program repeatedly generates stack overflow events through recursive function calls, activating the kernel to expand the stack segment in the process's virtual space and the swappable part in the physical space, forcing the kernel to modify the relative virtual and physical address mapping table, refresh the memory mapping table, and rebuild the address mapping relationship for the process. From the beginning to the end of the Stack test program, the code segment and data segment sizes remain unchanged at 4KB each; the stack segment expands from 4KB to 44KB. During the test, the kernel code of this embodiment of the invention is optimized to the maximum extent of efficiency, the Stack test program is run, and the number of CPU clock cycles spent establishing address mapping relationships is measured. The experimental results are shown in Table 1. The average time taken to calculate and set each page table entry of the system page table in this invention is only 14.2 CPU clock cycles, which is an address mapping method with very low time overhead.
[0084] Table 1. Time required to establish address mapping relationship using this method.
[0085]
[0086] This application provides an address mapping device based on a system page table, including: a page table creation module and a data processing module;
[0087] The page table creation module is used to create a system page table during system initialization.
[0088] The data processing module is used to store the mapping relationship between the virtual addresses and physical addresses of processes currently running in the processor using the system page table.
[0089] In this embodiment of the application, the device further includes: an acquisition module;
[0090] The acquisition module is used to acquire the starting physical address of the code segment data, the data segment data, and the stack segment data stored in physical memory, respectively; calculate the number of physical page frames occupied by the code segment data, the data segment data, and the stack segment data, respectively; and acquire the starting page table entry of the process data preset by the system in the system page table;
[0091] The data processing module is used to establish and store a mapping relationship between the virtual address and the physical address of the process data in the system page table based on the starting page table entry of the process data, according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data.
[0092] This application provides a storage medium, including:
[0093] Used to store computer-executable instructions, which, when executed, implement the methods described in the above embodiments.
[0094] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0095] In the 1930s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many improvements to the methodology today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that an improvement to the methodology cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0096] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0097] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0098] For ease of description, the above apparatus is described by dividing it into various functional units. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in one or more software and / or hardware.
[0099] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0100] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0101] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0102] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0103] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0104] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0105] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0106] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0107] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0108] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0109] The above description is merely an embodiment of this document and is not intended to limit the scope of this document. Various modifications and variations can be made to this document by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of the claims of this document.
Claims
1. An address mapping method based on system page tables, characterized in that, During system initialization, a system page table is created, the method of which includes: The system page table is used to store the mapping relationship between the virtual addresses and physical addresses of the processes currently running in the processor; After a new process is created, the process data includes: code segment data, data segment data, and stack segment data; Before using the system page table to store the mapping relationship between the virtual addresses and physical addresses of the processes currently running in the processor, the method further includes: Obtain the starting physical address of the code segment data, the data segment data, and the stack segment data stored in physical memory, respectively. Calculate the number of physical page frames occupied by the code segment data, the data segment data, and the stack segment data respectively; Obtain the starting address of the process data in the virtual space; Based on the starting address in the virtual space, determine its starting page table entry in the system page table; The step of using the system page table to store the mapping relationship between the virtual addresses and physical addresses of processes currently running in the processor includes: Based on the starting page table entry of the process data in the system page table, according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, a mapping relationship between the virtual address and the physical address of the process data is established and stored in the system page table. When the processor schedules a new process, it uses the virtual address and physical address mapping of the new process to overwrite the virtual address and physical address mapping currently stored in the system page table.
2. The method according to claim 1, characterized in that, The system page table includes multiple page table entries for storing the physical addresses of process data, and each page table entry corresponds to a virtual space of a fixed size; The step of establishing and storing the mapping relationship between the virtual address and physical address of the process data in the system page table based on the starting page table entry of the process data in the system page table, according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, includes: Based on the starting page table entry of the process data in the system page table, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, the page table entries corresponding to the code segment data, the page table entries corresponding to the data segment data, and the page table entries corresponding to the stack segment data are determined respectively in the order of code segment data, data segment data, and stack segment data. Based on the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data, the corresponding physical page frame number of the code segment data, the data segment data, or the stack segment data is filled in the corresponding page table entry to establish and store the mapping relationship between the virtual address and the physical address of the process data.
3. The method according to claim 2, characterized in that, The step of determining the page table entry corresponding to the code segment data based on the starting page table entry of the process data in the system page table and the number of physical page frames occupied by the code segment data includes: The starting page table entry of the process data in the system page table is determined to be the starting page table entry corresponding to the code segment data; Based on the number of physical page frames occupied by the code segment data, determine the other page table entries corresponding to the code segment data; The number of physical page frames occupied by the code segment data is the same as the number of page table entries corresponding to the code segment data.
4. The method according to claim 3, characterized in that, Determining the page table entry corresponding to the data segment includes: The last page table entry corresponding to the code segment data is determined to be the target page table entry; The next page table entry of the target page table entry is determined to be the starting page table entry corresponding to the data segment data; Based on the number of physical page frames occupied by the data segment, determine the other page table entries corresponding to the data segment; The number of physical page frames occupied by the data segment is the same as the number of page table entries corresponding to the data segment.
5. The method according to claim 2, characterized in that, Determining the page table entry corresponding to the stack segment data includes: The last page table entry in the system page table is determined to be the last page table entry corresponding to the stack segment data; Based on the number of physical page frames occupied by the stack segment data, determine the other page table entries corresponding to the stack segment data; The number of physical page frames occupied by the stack segment data is the same as the number of page table entries corresponding to the stack segment data.
6. An address mapping device based on a system page table, characterized in that, include: Page table creation module and data processing module; The page table creation module is used to create a system page table during system initialization. The data processing module is used to store the mapping relationship between the virtual address and physical address of the processes currently running in the processor using the system page table; After a new process is created, the process data includes: code segment data, data segment data, and stack segment data; The device further includes: an acquisition module; The acquisition module is used to acquire the starting physical addresses of the code segment data, the data segment data, and the stack segment data stored in physical memory, respectively; calculate the number of physical page frames occupied by the code segment data, the data segment data, and the stack segment data, respectively; the starting address of the process data in the virtual space; acquire the starting address of the process data in the virtual space; and determine the starting page table entry of the process data in the system page table based on the starting address in the virtual space. The data processing module is used to establish and store the mapping relationship between the virtual address and physical address of the process data in the system page table based on the starting page table entry of the process data, according to the starting physical address of the code segment data, the starting physical address of the data segment data, the starting physical address of the stack segment data, the number of physical page frames occupied by the code segment data, the number of physical page frames occupied by the data segment data, and the number of physical page frames occupied by the stack segment data. When the processor schedules a new process, it uses the virtual address and physical address mapping of the new process to overwrite the virtual address and physical address mapping currently stored in the system page table.
7. A storage medium, characterized in that, include: Used to store computer-executable instructions, which, when executed, implement the method according to any one of claims 1-5.