WO2019159472A1 - Memory management device, memory management method, and information processing device - Google Patents

Memory management device, memory management method, and information processing device Download PDF

Info

Publication number
WO2019159472A1
WO2019159472A1 PCT/JP2018/043083 JP2018043083W WO2019159472A1 WO 2019159472 A1 WO2019159472 A1 WO 2019159472A1 JP 2018043083 W JP2018043083 W JP 2018043083W WO 2019159472 A1 WO2019159472 A1 WO 2019159472A1
Authority
WO
WIPO (PCT)
Prior art keywords
address
region
virtual address
memory
page
Prior art date
Application number
PCT/JP2018/043083
Other languages
French (fr)
Japanese (ja)
Inventor
中村 祐一
マムン カジ
Original Assignee
ソニー株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ソニー株式会社 filed Critical ソニー株式会社
Priority to JP2020500283A priority Critical patent/JP7184074B2/en
Publication of WO2019159472A1 publication Critical patent/WO2019159472A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1027Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1027Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
    • G06F12/1036Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB] for multiple virtual address spaces, e.g. segmentation

Definitions

  • the technology disclosed in this specification relates to a memory management device, a memory management method, and an information processing device that perform address conversion in units of pages.
  • a memory management unit is hardware that performs address conversion from a virtual address to a physical address using a page table. Normally, the MMU performs such an address conversion on the entire virtual address space, thereby realizing a virtual address space for each process and providing a virtual memory larger than the real memory capacity.
  • the page size as a unit of address translation is fixed (typically, one page is about 4 KB).
  • the page size be small.
  • a page table necessary for performing address conversion in the same address range becomes large, and wasteful memory consumption occurs here.
  • An object of the technology disclosed in the present specification is to provide a memory management device, a memory management method, and an information processing device that efficiently perform address conversion in units of pages even on a small-capacity memory system.
  • the technology disclosed in the present specification has been made in consideration of the above problems, and the first aspect thereof is a memory management device that performs address conversion from a virtual address to a physical address in units of pages, Region address translation information defined in the virtual address space, a region information holding unit for holding a unique page size of the region, A search unit that searches for information of a physical address corresponding to the virtual address using the address conversion information of the region including the virtual address; Is a memory management device.
  • the region information holding unit includes a base virtual address of each region defined on the virtual address space, an address of a page table for each region placed on the physical memory, a page size defined in the region, and a region size Is stored in the entry for each region. Therefore, the search unit includes a page table address of a region including the virtual address from the base virtual address in the region information holding unit and an entry including the virtual address in an address range obtained by adding the page size of the region to the base virtual address. And the physical address information can be acquired from the page specified by dividing the difference between the virtual address and the base virtual address by the page size on the page table specified by the page table address.
  • the memory management device includes an address conversion that holds information indicating a correspondence relationship between a base virtual address and a base physical address in page units and information on a page size defined in a region including the virtual address.
  • a buffer and an address conversion unit that converts a base physical address and a virtual address acquired from an entry that hits a virtual address in the address conversion buffer into a physical address corresponding to the virtual address are further provided.
  • the address conversion unit can search the address conversion buffer for a base virtual address and an entry including the virtual address in the address range obtained by adding the region page size to the base virtual address.
  • the memory management device assigns different regions on the virtual address space to a plurality of memory areas storing data having different uses. Specifically, the memory management device allocates different regions each having a unique page size in the virtual address space to the text area, the heap area, and the stack area.
  • the second aspect of the technology disclosed in the present specification is a memory management method for performing address conversion from a virtual address to a physical address in units of pages, Using the address translation information of the region defined in the virtual address space and the address translation information held in the region information holding unit holding the unique page size of the region, information on the physical address corresponding to the virtual address is obtained.
  • a search step for searching It is obtained from the entry that hits the virtual address in the address translation buffer that holds the information indicating the correspondence between the base virtual address and the base physical address in page units and the page size information defined in the region that includes the virtual address.
  • the third aspect of the technology disclosed in this specification is: Physical memory, A region information holding unit that holds the address translation information of the region defined in the virtual address space and a unique page size of the region, and a physical address corresponding to the virtual address using the address translation information of the region including the virtual address.
  • a memory management unit having a search unit for searching for information, and performing address conversion from a virtual address to a physical address in units of pages; Is an information processing apparatus.
  • a memory management device, a memory management method, and an information processing device can be provided.
  • FIG. 1 is a diagram schematically illustrating a configuration example of a system 1 including an embedded device to which the technology disclosed in this specification can be applied.
  • FIG. 2 is a diagram illustrating a hardware configuration example of the sensing device 100.
  • FIG. 3 is a diagram illustrating a configuration example of the MMU 102 together with an address translation mechanism.
  • FIG. 4 is a flowchart showing a processing procedure for initializing the MMU 102.
  • FIG. 5 is a flowchart showing a processing procedure for converting a virtual address to a physical address in the MMU 102 after initialization.
  • FIG. 6 is a flowchart showing a processing procedure for the address translation mechanism 303 to translate a virtual address into a physical address.
  • FIG. 7 is a flowchart showing a processing procedure for the page walk mechanism 304 to refer to the page table on the physical memory 305.
  • FIG. 8 is a diagram illustrating a specific example in which address translation is performed using the MMU 102.
  • FIG. 9 is a diagram illustrating a specific example in which address translation is performed using the MMU 102.
  • FIG. 10 is a diagram illustrating a specific example in which address translation is performed using the MMU 102.
  • FIG. 11 is a diagram illustrating a specific example in which address translation is performed using the MMU 102.
  • FIG. 12 is a diagram showing a configuration example of a region in the virtual address space realized by using the MMU 102.
  • FIG. 13 is a diagram illustrating a configuration example of software that operates on hardware that implements the embedded device illustrated in FIGS. 1 and 2.
  • FIG. 14 is a diagram for explaining a memory management method using an operating system.
  • FIG. 15 is a diagram showing the relationship between the virtual address space provided by the virtual memory manager and each task executed on the virtual address space.
  • FIG. 16 is a diagram for explaining a mechanism for using Region # 0 as a text area among the regions provided by the virtual memory manager.
  • FIG. 17 is a flowchart showing a processing procedure for mapping a file in the flash memory 104 to a memory space.
  • FIG. 18 is a flowchart showing a processing procedure for releasing a file mapped to the memory space.
  • FIG. 19 is a diagram for explaining a mechanism for using Region # 1 and Region # 2 as heap areas.
  • FIG. 20 is a flowchart showing a processing procedure for securing memory from the heap area.
  • FIG. 21 is a flowchart showing a processing procedure for releasing the memory secured in the heap area.
  • FIG. 22 is a flowchart showing a process of allocating a memory from Region # 1 in which the page size is defined as 4 KB.
  • FIG. 23 is a flowchart showing a process of releasing the memory secured in Region # 1 where the page size is defined as 4 KB.
  • FIG. 24 is a flowchart showing a process of allocating memory from Region # 2 in which the page size is defined as 1 KB.
  • FIG. 20 is a flowchart showing a processing procedure for securing memory from the heap area.
  • FIG. 21 is a flowchart showing a processing procedure for releasing the memory secured in the heap area.
  • FIG. 22 is a flowchart showing a process
  • FIG. 25 is a flowchart showing a process of releasing the memory secured in Region # 2 where the page size is defined as 1 KB.
  • FIG. 26 is a flowchart showing a processing procedure for acquiring an empty memory block from the memory block manager.
  • FIG. 27 is a flowchart showing a processing procedure for returning a memory block to the memory block manager.
  • FIG. 28 is a diagram for explaining a mechanism for using Region # 3 as a stack area among the regions provided by the virtual memory manager.
  • FIG. 29 is a diagram showing a processing procedure for dynamically allocating the stack area.
  • FIG. 30 is a flowchart showing a processing procedure for releasing the stack at the end of the task.
  • a plurality of regions (regions) that are subject to address translation are defined in the virtual address space, and address translation is performed in units of pages in each region.
  • a unique page size can be defined, and therefore, address translation using the MMU can be efficiently realized even in a small-capacity memory system.
  • each page has a fixed page size, and one page uses one entry regardless of the page size on the page table that performs address conversion of each region. Address translation can be performed efficiently.
  • a program when a program operates, a plurality of types of areas such as a text area, a heap area, and a stack area are used, but these areas have different characteristics.
  • the text area includes instruction codes and read-only data that is referenced during program execution.
  • data stored in a nonvolatile memory such as a flash memory is often used for this.
  • writing to the flash memory is performed in units of a specific block size (typically about 64 KB), it is efficient to treat the text area in units of such block sizes.
  • the heap area is an area that is dynamically secured and released during execution in order to place data that needs to be retained during program execution.
  • the unit in which the memory is secured from the heap area largely depends on the processing contents and the way of writing the program, and may be several bytes or may exceed several hundred KB. If securing and releasing of memories of different sizes are repeated, memory fragmentation may occur, and it may not be possible to secure a continuous memory that satisfies the request even though there is a free space as a whole. In order to avoid the situation of memory fragmentation, a method of classifying the heap area into several areas and using them properly depending on the size of the memory to be secured can be considered.
  • the stack area is an area where the amount of usage increases dynamically due to the progress of function calls during program execution, etc., but the amount of usage varies greatly depending on how the program is written and the contents of processing. It is difficult to leave. Therefore, it is possible to dynamically allocate memory for each page size depending on the usage status, but if the average stack consumption of tasks running on the system is small, the page that is the allocation unit accordingly It is desirable that the size is small.
  • FIG. 1 schematically shows a configuration example of a system 1 including an embedded device to which the technology disclosed in this specification can be applied.
  • the illustrated system 1 includes a sensing device 100 corresponding to an embedded device, a base station 200, and a server 202 installed on a cloud 201.
  • the sensing device 100 can wirelessly connect to the base station 200 and access the server 202 via the cloud 201.
  • the sensing device 100 includes a CPU (Central Processing Unit) 101, an MMU 102, an SRAM (Static RAM (Random Access Memory)) 103, a memory such as a flash memory 104, a sensor 105, and a communication module 106, and is a device driven by a battery 107. is there.
  • a CPU Central Processing Unit
  • MMU Memory
  • SRAM Static RAM (Random Access Memory)
  • the sensing device 100 is used by being worn by a wearer, for example.
  • the CPU 101 analyzes the wearer's behavior (stopped, walking, running, etc.) based on the detection signal of the sensor 105. Then, the analysis result is wirelessly transmitted from the communication module 106 to the base station 200 and recorded in the server 202 via the cloud 201.
  • the server 202 uses the data received from the sensing device 100 for monitoring the wearer.
  • FIG. 2 shows a hardware configuration example of the sensing device 100 as an example of an embedded device.
  • the CPU 101 is connected to the system bus 110 via the MMU 102.
  • devices such as an SRAM 103, a flash memory 104, a sensor 105, and a communication module 106 are connected.
  • the flash memory 104 stores, for example, data such as an application that estimates the wearer's behavior based on a signal from the sensor 105, a library used when executing the application, and a behavior estimation dictionary for estimating the wearer's behavior. Storing.
  • the sensor 105 includes one or more sensor devices such as an acceleration sensor, an atmospheric pressure sensor, a gyro, a GPS (Global Positioning System), a TOF (Time Of Flight) image distance sensor, and a LIDAR (Light Detection and Ranging) sensor. .
  • the physical address space in which these devices connected to the system bus 110 are arranged is a target of address conversion by the MMU 102.
  • the SRAM 103 is arranged, and the flash memory 104 is arranged so that the contents can be directly seen from the CPU 101 or the MMU 102, or the I / O of various sensor devices included in the communication module 106 or the sensor 105.
  • O port is arranged.
  • FIG. 3 shows a configuration example of the MMU 102 according to the present embodiment.
  • the flow of conversion from a virtual address (Virtual Address: VA) to a physical address (Physical Address: PA) by the MMU 102 is also shown.
  • the illustrated MMU 102 includes two blocks, a translation lookaside buffer (TLB) 301 and a region descriptor 302.
  • TLB translation lookaside buffer
  • the TLB 301 is used to hold information for converting a virtual address to a physical address in units of pages, like a general MMU.
  • the number of entries in the TLB 301 is arbitrary. For example, the MMU designer determines the number of TLB entries based on the tradeoff between the efficiency of address translation and the circuit scale for realizing the MMU.
  • Each entry T 0 to T n of the TLB 301 has a base virtual address TB 0 to TB n , a base physical address TT 0 to TT n , a page size TP 0 to TP n , and entry valid flags TV 0 to TV n , respectively.
  • the base virtual addresses TB 0 to TB n virtual addresses of pages whose addresses are converted by the respective TLB entries T 0 to T n are stored.
  • the base physical addresses TT 0 to TT n converted physical addresses corresponding to the base virtual addresses TB 0 to TB n of the respective TLB entries T 0 to T n are stored.
  • the page sizes TP 0 to TP n store the size of the page indicated by each TLB entry T 0 to T n (that is, the size of the page defined in the region to which the virtual addresses TB 0 to TB n belong).
  • the entry valid flags TV 0 to TV n store flags indicating the validity (valid or invalid) of the respective TLB entries T 0 to T n themselves.
  • the region descriptor 302 is used to set a region (region) that is a target of address conversion by the MMU 102. Therefore, the region descriptor 302 has as many entries as the number of regions that the MMU 102 can provide. In the example shown in FIG. 3, the region descriptor 302 has four entries R 0 to R 3 .
  • Each entry R 0 to R 3 of the region descriptor 302 has a base virtual address RB 0 to RB 3 , a page table address RT 0 to RT 3 , a page size RP 0 to RP 3 , and a region size RS 0 to RS 3 .
  • the base virtual addresses RB 0 to RB 3 store the head addresses in the virtual address space where the regions R 0 to R 3 are arranged.
  • the page table addresses RT 0 to RT 3 store the physical addresses where the page tables P 0 to P 3 used for the conversion from the virtual address to the physical address are stored for each region R 0 to R 3. .
  • the page sizes RP 0 to RP 3 store the size of the page size of each page constituting each region R 0 to R 3 .
  • the region sizes RS 0 to RS 3 store the sizes of the regions R 0 to R 3 themselves.
  • the page tables P 0 to P 3 for each region have the same number of entries as the number of pages in the corresponding region, and each entry stores the physical address of the page conversion destination in the corresponding region.
  • a value obtained by dividing the region size by the page size of the region is the number of pages in the region (in the case of region R x , RS x / RP x is the number of pages in the region).
  • the address translation from the virtual address to the physical address in the illustrated MMU 102 is performed by comparing the virtual address with the base address of each entry of the TLB 301 and the region descriptor 302, and whether or not a matching entry exists.
  • a flow for converting a virtual address to a physical address will be described.
  • the CPU 101 accesses the memory space using a virtual address.
  • the MMU 102 compares the base address portion of the virtual address requested to be accessed with the base virtual addresses TB 0 to TB n of the entries T 0 to T n of the TLB 301.
  • the address translation mechanism 303 translates the base virtual address into a base physical address using the entry.
  • the physical address can be obtained by combining the base physical address and the offset address of the virtual address requested to be accessed.
  • the MMU 102 determines the base address portion of the virtual address requested to be accessed and the region descriptor. compared to the base virtual address RB 0 ⁇ RB 3 in each entry R 0 ⁇ R 3 302, referring to the page table address RT X in the corresponding entry.
  • the page walk mechanism 304 finds a page table entry corresponding to the requested virtual address by referring to the corresponding page table P X on the physical memory 305 using the page table address RT X , it is obtained.
  • An arbitrary entry in the TLB 301 is updated based on the content. In this way, a new entry for mapping the virtual address and physical address requested for access is stored in the TLB 301.
  • FIG. 4 shows a processing procedure for initializing the MMU 102 in the form of a flowchart.
  • the initialization of the MMU 102 is basically performed when the operating system (OS) is started.
  • OS operating system
  • step S401 all entries in the TLB 301 are set to be invalid. Specifically, False is assigned to the entry valid flags TV 0 to TV n of all entries.
  • Region sizes RS 0 to RS 3 are set (step S402).
  • FIG. 5 shows a processing procedure for converting a virtual address to a physical address in the MMU 102 after initialization in the form of a flowchart.
  • the requested virtual address is compared with each entry T 0 to T n in the TLB 301 (step S501), and it is checked whether any entry matches (step S502).
  • the virtual address VA matches the entry T x .
  • step S503 If an entry that matches the requested virtual address is found in the TLB 301 (Yes in step S502), the address conversion mechanism 303 performs a conversion process from the virtual address to the physical address (step S503). Refer to FIG. 6 for details of the conversion process from the virtual address to the physical address by the address translation mechanism 303.
  • step S502 if an entry that matches the requested virtual address is not found in the TLB 301 (No in step S502), that is, if a TLB miss occurs, the requested virtual address and each entry in the region descriptor 302 are subsequently continued.
  • R 0 to R n are compared (step S504), and it is checked whether any entry matches (step S505).
  • the x-th entry R x, base and virtual address RB x if it contains the virtual address VA is in the range obtained by adding the page size RS x to the base virtual address RB x (i.e., RB x ⁇ VA ⁇ RB x + RS x ), the virtual address VA matches the entry R x .
  • step S506 a page table reference process on the physical memory 305 by the page walk mechanism 304 is executed (step S506). ), A new entry is created in the TLB 301 for mapping the requested virtual address and physical address. Thereafter, the process returns to step S501, and the conversion process from the virtual address to the physical address by the address conversion mechanism 303 is executed again. Refer to FIG. 7 for details of the page table reference processing on the physical memory 305 by the page walk mechanism 304.
  • step S505 If no entry matching the requested virtual address is found in the region descriptor 302 (No in step S505), a bus fault error occurs and the physical address is changed from the virtual address to the physical address. Cancel the conversion process.
  • FIG. 6 shows a processing procedure for converting the virtual address to the physical address by the address translation mechanism 303 executed in step S506 in the flowchart shown in FIG. 5 in the form of a flowchart.
  • step S601 When the address translation mechanism 303 obtains the base physical address TT x from the entry T x that matches the requested virtual address in the TLB 301 (step S601), the base physical address and the offset address of the requested virtual address are accessed. Are combined to calculate the physical address (step S602).
  • step S602 specifically, the physical address TT x acquired from the entry T x in TLB301, by adding the difference between the requested virtual address VA and the base virtual address TB x, be determined physical address PA (Ie, PA ⁇ TT x + (VA ⁇ TB x )).
  • the page walk mechanism 304 executed in step S506 in the flowchart shown in FIG. 5 refers to the page table on the physical memory 305, and a new entry for mapping the virtual address and the physical address is displayed in the TLB 301.
  • the processing procedure for creating the data is shown in the form of a flowchart.
  • the page walk mechanism 304 first determines the page number of the corresponding page table in the physical memory 305 based on the information stored in the corresponding entry Rx of the region descriptor 302 and the requested virtual address VA. Is to be acquired (step S701). Specifically, a value n obtained by dividing the difference between the virtual address VA and the base virtual address RB x by the page size RP x of the region and rounding it to an integer becomes an entry in the page table (that is, n ⁇ int (( VA-RB x ) / RP x )).
  • the page walk mechanism 304 requests the value PP of the nth entry from the page table located at the physical address of the page table address RT x stored in the corresponding entry R x of the region descriptor 302, that is, requested.
  • the base physical address corresponding to the virtual address VA is acquired (that is, PP ⁇ P xn ) (step S702).
  • step S703 If there is no invalid entry TV y in the TLB 301 (No in step S703), the page walk mechanism 304 selects an arbitrary y-th entry in the TLB 301 and sets it as an invalid entry ( That is, TV y ⁇ False) (step S704).
  • the page walk mechanism 304 validates the invalid entry y found in the TLB 301 (or the invalid entry y) and sets new address translation information for the entry (step S705). Specifically, the entry valid flag TV y is validated, and a new base virtual address TB y , base physical address TT y , and page size TP y are set (ie, TB y ⁇ RB x + (RP x ⁇ n)). TT y ⁇ PP, TP y ⁇ RP x , TV y ⁇ True).
  • FIG. 8 to 11 show specific examples of performing address conversion using the MMU 102.
  • FIG. Here, as an example, four regions as shown in Table 1 below are defined in the virtual address space (however, 0x indicates that the value is a hexadecimal number).
  • Each region has a page table (P 0 to P 3 ) at a physical address (RT 0 to RT 3 ) set as the page table address.
  • Each page table (P 0 to P 3 ) stores a physical address (P 00 to P 3n ) after the virtual address is converted in page units.
  • the conversion from the virtual address to the physical address is executed according to the processing procedure shown in FIG.
  • the page walk mechanism 304 executes the page walk according to the processing procedure shown in FIG.
  • the page walk mechanism 304 selects the entry T 0 from the invalid entries in the TLB 301 and sets a new base virtual address TB 0 , base physical address TT 0 , and page size TP 0 as follows.
  • the entry T 0 is validated.
  • FIG. 10 shows a state where the entry T 0 is set by the page walk.
  • VA virtual address
  • the address translation mechanism 303 calculates the physical address PA from the base physical address TT 0 acquired from the entry T 0 of the TLB 301 and the requested virtual address VA according to the processing procedure shown in FIG. ⁇ TT 0 + (VA ⁇ TB 0 )).
  • 0x0080000 + (0x10020010-0x10020000) 0x00080010 is the physical address PA obtained by address translation using the TLB 301.
  • the MMU 102 includes, in addition to the TLB 301 that holds information for converting a virtual address to a physical address, information for address conversion for each of a plurality of regions defined as address conversion targets, and A region descriptor 302 that holds page size information defined for each region is provided.
  • the MMU 102 according to the present embodiment in the case of a TLB miss, even if a different page size is defined for each region, the address is efficiently addressed in units of pages using the region descriptor 302. It should be fully understood that conversion can be performed.
  • FIG. 12 shows a configuration example of a region in the virtual address space realized by using the MMU 102 according to the present embodiment.
  • Region # 0 to # 3 In the illustrated virtual address space, four regions of Region # 0 to # 3 are defined. Each region has a page size of 64 KB, 4 KB, 1 KB, and 1 KB, respectively. Region # 0 is used as a text area, Region # 1 and Region # 2 are used as a heap area, and Region # 3 is used as a stack area. However, Region # 1 and Region # 2 use these two regions properly depending on the size of the memory block to be secured.
  • FIG. 13 shows a configuration example of software that operates on hardware that implements the embedded device (sensing device 100) shown in FIGS.
  • the sensing device 100 may be a device that a user holds or wears, such as a smart phone, a smart watch, a smart glass, or a smart headphone, or may be equipped in a mobile transportation means such as an electric vehicle.
  • An application that operates on hardware such as the sensing device 100 includes, for example, a sensing process for sensing a wearer's movement, a behavior estimation process that estimates a wearer's action based on the sensing result, and the estimated result in the cloud It is roughly divided into three communication processes for transmitting to the server 202 via 201. Moreover, the action dictionary used for the action estimation process is included in the application. These applications support the equipment hardware shown in FIG. 1 or FIG. 2, and are provided on the OS that provides the address space (see FIG. 12) realized by the MMU 102 shown in FIG. 3 to each task. Works with.
  • the sensing device 100 performs a sensing process based on the input from the sensor 105.
  • the “behavior” of the sensing device 100 that can be recognized by the sensor 105 is associated with “behavior” and registered in the behavior dictionary as “behavior definition”, whereby “behavior” is recognized and recognized in the behavior estimation process.
  • the estimated result may be transmitted to the server 202 via the cloud 201 as necessary.
  • the behavior dictionary uses the results of sensing processing and behavior estimation processing, etc., to move the relationship between “action / situation” and “behavior” using artificial intelligence techniques such as deep neural network. You may be made to learn. Examples of the operation include “user operation measurement”.
  • situations include “high acceleration” and “low acceleration”.
  • the action “user's running” is associated with the action “user's action measurement” and the situation “high acceleration”
  • the action “user walks” with the action “user's action measurement” and the situation “low acceleration”.
  • the OS is task management that controls the operation of each task, a flash file manager that manages the file system on the flash memory 104, a virtual memory manager that controls the MMU 102 to configure a virtual address space, and a virtual memory that is allocated to the configured virtual memory A memory block manager for managing the physical memory.
  • the OS also includes device drivers that control devices such as the connected sensor 105, communication module 106, and flash memory 104.
  • the virtual memory manager mainly manages the page table of each region set in the MMU 102.
  • the virtual memory manager allocates physical memory to a page in a certain region, it calls the memory block manager to obtain the physical memory.
  • the virtual memory manager allocates a file on the flash memory 104 to a page in a certain region, the flash file manager is used to store information on which block on the flash memory the corresponding file is located.
  • the block of the corresponding file is placed on the corresponding virtual address by acquiring it from the file system management data in the system and setting the physical address where the block exists in the page table of the region to be placed.
  • a memory management API Application Programming Interface
  • the OS When the OS starts up, it initializes itself for application execution after completing its initialization.
  • the application is stored in advance as file data on the flash memory 104, the file is placed in a virtual address space by calling a memory management API, and a task for executing from the execution start address is generated, thereby executing the application. Begins.
  • FIG. 15 shows the relationship between the virtual address space provided by the virtual memory manager and each task executed on the virtual address space.
  • the virtual memory manager allocates a block on the physical memory 305 or the flash memory 104 as needed to a region corresponding to the request in accordance with a memory allocation and memory release request by a memory management API called by each task.
  • the sensing task, behavior estimation task, and communication task managed by the OS are operating.
  • the virtual address space is shared among a plurality of tasks operating simultaneously.
  • the instruction code of each application such as sensing processing, behavior estimation processing, and communication processing stored in the flash memory 104 and read-only data to be referred to when executing the program are used as a text area in the virtual address space. Maps to Region # 0. The behavior estimation dictionary used for the behavior estimation process is also mapped to Region # 0.
  • the sensing task operating on the sensing device 100 uses a sensing processing application mapped to Region # 0.
  • the sensing task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically allocated and released in the area during execution.
  • the sensing task places a function called during execution of the program in Region # 3 used as a stack area.
  • a behavior estimation task operating on the sensing device 100 uses a behavior estimation processing application and a behavior estimation dictionary mapped to Region # 0.
  • the behavior estimation task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically secured and released in the area during execution. Further, the behavior estimation task places a function called during execution of the program in Region # 3 used as a stack area.
  • a communication task operating on the sensing device 100 uses a communication processing application mapped to Region # 0. Further, the communication task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically allocated and released in the area during execution. Further, the communication task places a function called during execution of the program in Region # 3 used as a stack area.
  • FIG. 16 shows a mechanism for using Region # 0 as a text area among the regions provided by the virtual memory manager.
  • the blocks are not necessarily arranged as continuous blocks in the flash memory 104.
  • the virtual address space is obtained by address conversion using the page table.
  • a file can be pasted as a continuous virtual address in the text area (Region # 0).
  • the page size in Region # 0 is matched with the block size (typically 64 KB) of the flash memory 104. Therefore, for example, for a file (192 KB) that occupies three blocks on the flash memory 104, this file can be mapped to a text area if there are three entries on the page table.
  • FIG. 17 shows a processing procedure for mapping the file in the flash memory 104 to the memory space (text area of the virtual address space) by the virtual memory manager in the form of a flowchart.
  • the virtual memory manager first tries to acquire a free address space of the mapping destination region (Region # 0) (step S1701).
  • step S1702 if an empty address space cannot be obtained from the mapping destination region (No in step S1702), the file mapping is given up as an address space shortage error, and this processing is terminated.
  • step S1702 If a free address space can be acquired from the mapping destination region (Yes in step S1702), the virtual memory manager attempts to acquire arrangement information in the flash memory 104 of the file mapped to the region (step S1702). S1703).
  • the processing in step S1703 corresponds to the processing indicated by reference numeral 1402 in FIG.
  • step S1704 if the placement information of the file to be mapped to the region cannot be obtained, that is, there is no file to be mapped (No in step S1704), the file mapping is given as a file nonexistence error, and this processing is performed. finish.
  • step S1705 When the placement information of the file to be mapped to the region can be acquired, that is, when there is a file to be mapped (Yes in step S1704), the virtual memory manager displays the page of the region on the physical memory 305.
  • the in-memory arrangement information of the file is written in the table (step S1705), and the file mapping process is terminated.
  • the processing in step S1705 corresponds to the processing indicated by reference numeral 1403 in FIG.
  • FIG. 18 shows a processing procedure for releasing a file mapped to the memory space (text area of the virtual address space) by the virtual memory manager in the form of a flowchart.
  • the virtual memory manager checks whether the address designated to be released is a file mapping destination (step S1801).
  • step S1802 corresponds to the process indicated by reference numeral 1403 in FIG.
  • step S1801 if the address designated to be released is not the mapping destination of the file (No in step S1801), the mapping is released as an address designation error, and this processing is terminated.
  • FIG. 19 shows a mechanism for using Region # 1 and Region # 2 among the regions provided by the virtual memory manager as heap areas.
  • the unit of memory allocation from the heap area largely depends on the processing contents and how to write the program.
  • the memory to be secured may be several bytes or several hundred KB.
  • the heap allocator uses two regions, Region # 1 and Region # 2, depending on whether the memory to be secured is 4 KB or more. Yes.
  • “Malloc” is a function that dynamically secures memory
  • “free” is a function that dynamically releases the secured memory.
  • the heap allocator selects a heap area to be used according to the memory size to be secured.
  • the heap allocator allocates physical memory to Region # 2 with the page size set to 1 KB. However, for a memory request exceeding the page size of 1 KB, a plurality of pages are allocated and used. In response to a memory allocation request of 4 KB or more, the heap allocator allocates physical memory to Region # 1 in which the page size is set to 4 KB.
  • the number of memory requests for the heap area to be classified and the size set as the threshold when classifying vary depending on the memory request pattern of the application, but at least by classifying according to the secured size, the memory It becomes possible to suppress fragmentation.
  • FIG. 20 shows a processing procedure for securing memory from the heap area in the form of a flowchart.
  • step S2001 dynamic allocation of memory is required using a malloc function.
  • the process of securing the memory is executed from Region # 1 where the page size is defined as 4 KB (step S2002). Details of the process of securing the memory from Region # 1 will be described later.
  • step S2001 if the memory size of the heap area to be secured is less than 4 KB (No in step S2001), a process of securing the memory is executed from Region # 2 where the page size is defined as 1 KB (step S2003). Details of the process of allocating memory from Region # 2 will be described later.
  • FIG. 21 shows a processing procedure for releasing the memory secured in the heap area in the form of a flowchart.
  • step S2101 For example, dynamic release of memory is requested using the free function. If the address of the memory requested to be released is Region # 1 defined with a page size of 4 KB (Yes in step S2101), the memory of Region # 1 (or an area with a page size of 4 KB) is released. The process is executed (step S2102). Details of the processing for releasing the memory secured in Region # 1 will be described later.
  • step S2103 processing for releasing the memory in Region # 2 (or an area having a page size of 1 KB) is executed (step S2103). ). Details of the processing for releasing the memory secured in Region # 2 will be described later.
  • FIG. 22 shows, in the form of a flowchart, a processing procedure for securing a memory from Region # 1 defined with a page size of 4 KB, which is executed in step S2002 of the flowchart shown in FIG.
  • the virtual memory manager tries to acquire a free address space having a size specified in Region # 1 (step S2201).
  • step S2202 If a free address space having a size specified in Region # 1 can be acquired (Yes in step S2202), the virtual memory manager acquires a free memory block from the memory block manager (step S2203). Details of the process of acquiring an empty memory block from the memory manager will be described later.
  • step S2204 If a free memory block can be acquired from the memory block manager (Yes in step S2204), the virtual memory manager stores the memory block acquired in step S2201 in the page table of the region on the physical memory 305. Is written (step S2205), and this process is terminated.
  • the process in step S2205 corresponds to the process indicated by reference numeral 1403 in FIG.
  • step S2204 If a free memory block cannot be obtained from the memory block manager (No in step S2204), the memory is given up as a memory shortage error, and this process is terminated.
  • FIG. 23 shows, in the form of a flowchart, the processing procedure for releasing the memory secured in Region # 1 defined in the page size of 4 KB, which is executed in step S2102 of the flowchart shown in FIG. .
  • the virtual memory manager checks whether or not the address designated to be released corresponds to Region # 1 (step S2301).
  • the virtual memory manager executes processing for returning the memory block to the memory block manager (step S2302). Details of the process of returning the memory block to the memory block manager will be described later.
  • step S2303 corresponds to the process indicated by reference numeral 1403 in FIG.
  • FIG. 24 shows, in the form of a flowchart, a processing procedure for securing a memory from Region # 2 in which the page size is defined as 1 KB, which is executed in step S2003 of the flowchart shown in FIG.
  • the virtual memory manager tries to acquire a free address space having a size specified in Region # 2 (step S2401).
  • step S2403 the virtual memory manager acquires a free memory block from the memory block manager. Details of the process of acquiring an empty memory block from the memory manager will be described later.
  • step S2404 If an empty memory block can be acquired from the memory block manager (Yes in step S2404), the virtual memory manager stores the memory block acquired in step S2401 in the page table of the region on the physical memory 305. Is written (step S2405), and the process is terminated.
  • the processing in step S2405 corresponds to the processing indicated by reference numeral 1403 in FIG.
  • step S2404 If a free memory block cannot be obtained from the memory block manager (No in step S2404), the memory is given up as a memory shortage error, and this process is terminated.
  • FIG. 25 shows, in the form of a flowchart, the processing procedure for releasing the memory secured in Region # 2 defined with the page size of 1 KB, which is executed in step S2103 of the flowchart shown in FIG. .
  • the virtual memory manager checks whether the address designated to be released corresponds to Region # 2 (step S2501).
  • step S2501 If the address designated to be released corresponds to Region # 2 (Yes in step S2501), the virtual memory manager executes a process for returning the memory block to the memory block manager (step S2502). Details of the process of returning the memory block to the memory block manager will be described later.
  • step S2303 corresponds to the process indicated by reference numeral 1403 in FIG.
  • FIG. 26 shows a processing procedure for acquiring an empty memory block from the memory block manager executed in step S2203 of the flowchart shown in FIG. 22 and step S2403 of the flowchart shown in FIG. 24 in the form of a flowchart. ing.
  • the memory block manager checks whether there is a free physical memory block (step S2601).
  • step S2601 If there is a free physical memory block (Yes in step S2601), the memory block manager changes the state of the free memory block to used (step S2602), and ends this process.
  • step S2601 if there is no free space in the physical memory block (No in step S2601), it gives up the acquisition of the free memory block as a memory shortage error, and ends this processing.
  • FIG. 27 shows a processing procedure for returning a memory block to the memory block manager executed in step S2302 of the flowchart shown in FIG. 23 and step S2503 of the flowchart shown in FIG. 25 in the form of a flowchart. .
  • the memory block manager changes the state of the memory block returned from the virtual memory manager to empty (step S2701), and ends this process.
  • FIG. 28 shows a mechanism for using Region # 3 as a stack area among the regions provided by the virtual memory manager.
  • the stack area is an area in which the usage amount increases dynamically due to the progress of function calls during program execution.
  • the page size of Region # 3 used as the stack area is set to 1 KB.
  • the physical memory for one page is first allocated to the virtual address space as the stack area of the task.
  • the physical memory is dynamically added one page at a time. Are allocated to the virtual address space.
  • the OS dynamically extends the stack area by allocating the physical memory secured from the memory block manager to the virtual address where the bus fault has occurred in the handler of the bus fault.
  • FIG. 29 shows a processing procedure for dynamically allocating a stack area as a task bus fault process in the form of a flowchart.
  • the bus fault handler checks whether the fault occurrence address is Region # 3 used as a stack area (step S2901).
  • step S2901 If the fault occurrence address is not Region # 3 (No in step S2901), the task is stopped due to a bus error, and this process is terminated.
  • the bus fault handler acquires an empty memory block from the memory block manager (step S2902).
  • the process of acquiring an empty memory block from the memory manager is executed according to the processing procedure (described above) shown in FIG.
  • step S2903 If a free memory block can be acquired from the memory block manager (Yes in step S2903), the bus fault handler stores the memory block acquired in step S2902 in the page table of the region on the physical memory 305. Is written (step S2904), and the processing by the bus fault handler is terminated.
  • the processing in step S2904 corresponds to the processing indicated by reference numeral 1403 in FIG.
  • step S2903 If a free memory block cannot be obtained from the memory block manager (No in step S2903), the memory is given up as a memory shortage error, and this processing is terminated.
  • FIG. 30 shows a processing procedure for releasing the stack at the end of the task in the form of a flowchart.
  • the virtual memory manager executes a process for returning the memory block to the memory block manager (step S3001).
  • the process of returning the memory block to the memory block manager is executed according to the processing procedure (described above) shown in FIG.
  • step S3002 the virtual memory manager returns the page table of the region to unused (step S3002), and ends this process.
  • the process in step S3002 corresponds to the process indicated by reference numeral 1403 in FIG.
  • the setting of the page size of each region is merely an example.
  • the appropriate page size in each region varies depending on conditions such as the scale and nature of the application task to be executed and the memory capacity installed in the device (sensing device 100). The important point is that the requirements for the text, heap, and stack areas are different, and according to the technique disclosed herein, an appropriate page size can be used with less memory for such requests. .
  • a sensing task In the present embodiment, it is assumed that a sensing task, a behavior estimation task, and a communication task are operating on the sensing device 100 (see, for example, FIG. 15). In this embodiment, it is assumed that these tasks have the following properties and memory requirements.
  • Sensing task The sensing task periodically acquires information from the various sensors 105 at a constant cycle, and passes the sensor value to the behavior estimation task.
  • the instruction code of the sensing task is only about one block (64 KB) of the flash memory 104, and several memory areas of about 1 KB are used from the heap area.
  • the consumption of the stack area is about 1 KB.
  • Behavior estimation task executes an algorithm that periodically performs behavior estimation using the sensor value passed from the sensing task and the behavior estimation dictionary on the flash memory 104, and uses the estimated result as a communication task. hand over.
  • the instruction code of the action estimation task and the action estimation dictionary are only enough to fit in one block (64 KB) of the flash memory, and the memory area of about 16 KB and several memory areas of about 1 KB are used from the heap area.
  • the consumption of the stack area is about 4 KB.
  • the communication task transmits the estimation result of the behavior estimation task to the server 202 on the cloud 202. Although the transmission data is periodically received from the behavior estimation task, exception processing such as error processing may be required irregularly such as connection disconnection during communication with the server 202 or subsequent retry.
  • the instruction code of the communication task is about 256 KB (4 blocks) on the flash memory 104. From the heap area, several memory areas of about 4 KB and ten memory areas of about 1 KB are used. The consumption amount of the stack area is about 2 KB in the normal state, but may increase to about 4 KB by exception processing or the like.
  • each region can be realized in the virtual address space as follows.
  • Text Area Region # 0 that provides a text area has a page size of 64 KB, which is the block size of the flash memory 104.
  • the number of pages required for each task is 1 page, 2 pages, and 4 pages, respectively. If there is a page table for a total of 7 pages, the text area for all tasks can be provided.
  • Heap area Region # 1 and Region # 2 providing the heap area use two page sizes of 4 KB page and 1 KB page in order to satisfy various memory securing requests as described above.
  • memory requests can be broadly classified into two types, those having a size of about 1 KB and those exceeding 4 KB. Therefore, it is effective in preventing memory fragmentation by using different regions.
  • Stack area Region # 3 providing the stack area uses 1 KB, which is the minimum value of the stack consumption required in the task, as the page size.
  • Each task allocates a maximum of one page, four pages, and four pages of physical memory as a stack. For example, when the page size is specified as 4 KB, only 1 KB is used for the sensing task, and 3 KB is wasted. However, such waste can be suppressed.
  • the number of TLB entries required for address translation in the MMU 102 is also suppressed.
  • the address translation by the MMU 102 it is finally necessary that the translation source virtual address (base virtual address TB) and the translation destination physical address (base physical address TT) are placed in the TLB 301.
  • the number of entries in the TLB 301 is limited, and when the base virtual address comparison in the TLB 301 does not match (that is, when a TLB miss occurs), an additional process called page walk processing using the region descriptor 302 is performed.
  • the memory management technology disclosed in this specification is applied to, for example, an embedded device having only a small amount of memory, and defines a plurality of regions to be subjected to address conversion, and also defines a page size for each region. Thus, it is possible to suppress unnecessary memory consumption and to efficiently perform address conversion in units of pages.
  • the memory management technique disclosed in this specification can be similarly applied to an information processing apparatus equipped with a normal or large-capacity memory.
  • a memory management device that performs address conversion from a virtual address to a physical address in page units, Region address translation information defined in the virtual address space, a region information holding unit for holding a unique page size of the region, A search unit that searches for information of a physical address corresponding to the virtual address using the address conversion information of the region including the virtual address;
  • a memory management device comprising: (2) The region information holding unit includes a base virtual address of each region defined on the virtual address space, a page table address for each region placed on the physical memory, a page size defined for the region, And information about the region size in the entry for each region, The search unit searches for information on the physical address corresponding to the virtual address from the corresponding page table on the physical memory based on the page table address corresponding to the region including the virtual address.
  • the memory management device according to (1) above.
  • (3) The search unit From the entry containing the virtual address in the base virtual address and the address range obtained by adding the page size of the region to the base virtual address in the region information holding unit, specify the page table address of the region including the virtual address,
  • the physical address information is obtained from the page specified by dividing the difference between the virtual address and the base virtual address by the page size on the page table specified by the page table address.
  • the memory management device according to any one of (1) to (5) above. (7) Assign different regions in the virtual address space to the text area, heap area, and stack area. The memory management device according to any one of (1) to (6) above. (8) Assign a region in which the page size is defined based on a predetermined block size to the text area. The memory management device according to any one of (1) to (7). (9) Allocate two or more regions with different page sizes to the heap area. The memory management device according to any one of (1) to (8). (10) When allocating a memory area from the heap area, assign a region in which a page size that does not exceed the memory size to be allocated is defined, The memory management device according to (9) above.
  • a memory management method for performing address conversion from a virtual address to a physical address in page units Using the address translation information of the region defined in the virtual address space and the address translation information held in the region information holding unit holding the unique page size of the region, information on the physical address corresponding to the virtual address is obtained.
  • a search step for searching It is obtained from the entry that hits the virtual address in the address translation buffer that holds the information indicating the correspondence between the base virtual address and the base physical address in page units and the page size information defined in the region that includes the virtual address.
  • An information processing apparatus comprising:
  • SYMBOLS 100 ... Sensing device 101 ... CPU, 102 ... MMU, 103 ... SRAM 104 ... Flash memory, 105 ... Sensor 106 ... Communication module, 107 ... Battery, 110 ... Bus 200 ... Base station, 201 ... Cloud, 202 ... Server

Abstract

Provided is a memory management device which performs an address conversion by a page unit. The memory management device is provided with: a region information holding unit which holds, in an entry for each region, a basic virtual address for each region defined on a virtual address space, an address of a page table for each region put on a physical memory, and information on the page size defined in the region and the region size; and a search unit which searches, on the basis of the page table address corresponding to the region including the virtual address, for information on the physical address corresponding to the virtual address from a corresponding page table on the physical memory.

Description

メモリ管理装置及びメモリ管理方法、並びに情報処理装置Memory management device, memory management method, and information processing device
 本明細書で開示する技術は、ページ単位でアドレス変換を行うメモリ管理装置及びメモリ管理方法、並びに情報処理装置に関する。 The technology disclosed in this specification relates to a memory management device, a memory management method, and an information processing device that perform address conversion in units of pages.
 メモリ管理ユニット(Memory Management Unit:MMU)は、ページテーブルを用いて仮想アドレスから物理アドレスへのアドレス変換を行うハードウェアである。通常、MMUは、仮想アドレス空間全体に対してこのようなアドレス変換を行うことで、プロセス毎の仮想アドレス空間を実現するとともに、実メモリ容量以上の仮想メモリを提供する。 A memory management unit (MMU) is hardware that performs address conversion from a virtual address to a physical address using a page table. Normally, the MMU performs such an address conversion on the entire virtual address space, thereby realizing a virtual address space for each process and providing a virtual memory larger than the real memory capacity.
 ところが、組み込み向け機器のような小容量のメモリしか持たない機器に対して仮想アドレス空間全体にわたりページ単位でアドレス変換を行う仕組みを適用すると、仮想アドレス空間の中で実際に使われる領域が小さいため、ページテーブルの中でまったく使用されない箇所が多くなり、無駄なメモリ消費が発生する。 However, when a mechanism that performs address translation in units of pages over the entire virtual address space is applied to devices that have only a small amount of memory, such as embedded devices, the area actually used in the virtual address space is small. In the page table, there are many places that are not used at all, resulting in unnecessary memory consumption.
 また、既存のMMUでは、アドレス変換の単位となるページサイズが固定されている(典型的には、1ページは4KB程度である)。小容量のヒープメモリ管理などで発生するフラグメンテーションを抑えるためには、ページサイズは小さいことが望ましい。一方、ページサイズが小さいと、同じアドレス範囲のアドレス変換を行うのに必要なページテーブルが大きくなり、ここでも無駄なメモリ消費が発生する。 Also, in the existing MMU, the page size as a unit of address translation is fixed (typically, one page is about 4 KB). In order to suppress fragmentation that occurs in small-capacity heap memory management, it is desirable that the page size be small. On the other hand, if the page size is small, a page table necessary for performing address conversion in the same address range becomes large, and wasteful memory consumption occurs here.
 例えば、複数のページテーブルを用いて異なるアドレス変換を行うシーケンサーアドレス管理について提案がなされている(例えば、特許文献1を参照のこと)。このシーケンサーアドレス管理によれば、実行する各スレッドがそれぞれ個別のページテーブルを持つため、小規模メモリのシステムで多数のスレッドを持っているような場合には必要なページテーブルの分量が大きくなってしまうことが懸念される。 For example, a sequencer address management that performs different address conversion using a plurality of page tables has been proposed (see, for example, Patent Document 1). According to this sequencer address management, each thread to be executed has its own page table. Therefore, when a small memory system has a large number of threads, the amount of necessary page table becomes large. There is a concern that
 また、基本となるページサイズの整数倍のメモリを1つのページとして扱って、可変のページサイズを実現するメモリ管理方式について提案がなされている(例えば、特許文献2を参照のこと)。このメモリ管理方式によれば、アドレス変換のためにページテーブル上でも複数のページテーブルエントリが必要であるため、ページ変換のためのページテーブルサイズが大きくなってしまうことが懸念される。 Also, a memory management method has been proposed that realizes a variable page size by treating a memory that is an integral multiple of the basic page size as one page (see, for example, Patent Document 2). According to this memory management method, since a plurality of page table entries are necessary even on the page table for address conversion, there is a concern that the page table size for page conversion becomes large.
特表2008-536224号公報Special table 2008-536224 特開平9-319658号公報JP-A-9-319658
 本明細書で開示する技術の目的は、小容量メモリシステム上でもページ単位で効率的にアドレス変換を行うメモリ管理装置及びメモリ管理方法、並びに情報処理装置を提供することにある。 An object of the technology disclosed in the present specification is to provide a memory management device, a memory management method, and an information processing device that efficiently perform address conversion in units of pages even on a small-capacity memory system.
 本明細書で開示する技術は、上記課題を参酌してなされたものであり、その第1の側面は、ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理装置であって、
 前記仮想アドレス空間に定義されたリージョンのアドレス変換情報と、リージョンが持つ固有のページサイズを保持するリージョン情報保持部と、
 仮想アドレスを含むリージョンの前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索部と、
を具備するメモリ管理装置である。
The technology disclosed in the present specification has been made in consideration of the above problems, and the first aspect thereof is a memory management device that performs address conversion from a virtual address to a physical address in units of pages,
Region address translation information defined in the virtual address space, a region information holding unit for holding a unique page size of the region,
A search unit that searches for information of a physical address corresponding to the virtual address using the address conversion information of the region including the virtual address;
Is a memory management device.
 前記リージョン情報保持部は、仮想アドレス空間上に定義された各リージョンのベース仮想アドレスと、物理メモリ上に置かれたリージョン毎のページテーブルのアドレスと、リージョンに定義されたページサイズ、及びリージョンサイズに関する情報をリージョン毎のエントリに保持している。したがって、前記探索部は、前記リージョン情報保持部内の、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリから、仮想アドレスを含むリージョンのページテーブルアドレスを特定し、そのページテーブルアドレスで指定されるページテーブル上の、仮想アドレスとベース仮想アドレスの差分をページサイズで割算して特定されるページから物理アドレス情報を取得することができる。 The region information holding unit includes a base virtual address of each region defined on the virtual address space, an address of a page table for each region placed on the physical memory, a page size defined in the region, and a region size Is stored in the entry for each region. Therefore, the search unit includes a page table address of a region including the virtual address from the base virtual address in the region information holding unit and an entry including the virtual address in an address range obtained by adding the page size of the region to the base virtual address. And the physical address information can be acquired from the page specified by dividing the difference between the virtual address and the base virtual address by the page size on the page table specified by the page table address.
 また、第1の側面に係るメモリ管理装置は、ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファと、前記アドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換部をさらに備えている。そして、前記アドレス変換部は、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリを、前記アドレス変換バッファ内で検索することができる。 In addition, the memory management device according to the first aspect includes an address conversion that holds information indicating a correspondence relationship between a base virtual address and a base physical address in page units and information on a page size defined in a region including the virtual address. A buffer and an address conversion unit that converts a base physical address and a virtual address acquired from an entry that hits a virtual address in the address conversion buffer into a physical address corresponding to the virtual address are further provided. The address conversion unit can search the address conversion buffer for a base virtual address and an entry including the virtual address in the address range obtained by adding the region page size to the base virtual address.
 また、第1の側面に係るメモリ管理装置は、用途が異なるデータを格納する複数のメモリ領域に対して、仮想アドレス空間上で異なるリージョンを割り当てる。具体的には、メモリ管理装置は、テキスト領域、ヒープ領域、及びスタック領域に対して、仮想アドレス空間上で、それぞれ固有のページサイズが定義された異なるリージョンを割り当てる。 Also, the memory management device according to the first aspect assigns different regions on the virtual address space to a plurality of memory areas storing data having different uses. Specifically, the memory management device allocates different regions each having a unique page size in the virtual address space to the text area, the heap area, and the stack area.
 また、本明細書で開示する技術の第2の側面は、ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理方法であって、
 前記仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部に保持された前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索ステップと、
 ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換ステップと、
を有するメモリ管理方法である。
The second aspect of the technology disclosed in the present specification is a memory management method for performing address conversion from a virtual address to a physical address in units of pages,
Using the address translation information of the region defined in the virtual address space and the address translation information held in the region information holding unit holding the unique page size of the region, information on the physical address corresponding to the virtual address is obtained. A search step for searching;
It is obtained from the entry that hits the virtual address in the address translation buffer that holds the information indicating the correspondence between the base virtual address and the base physical address in page units and the page size information defined in the region that includes the virtual address. An address conversion step of converting a base physical address and a virtual address into a physical address corresponding to the virtual address;
Is a memory management method.
 また、本明細書で開示する技術の第3の側面は、
 物理メモリと、
 仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部と、仮想アドレスを含むリージョンの前記アドレス変換情報を用いて仮想アドレスに対応する物理アドレスの情報を探索する探索部を備えて、ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理ユニットと、
を具備する情報処理装置である。
In addition, the third aspect of the technology disclosed in this specification is:
Physical memory,
A region information holding unit that holds the address translation information of the region defined in the virtual address space and a unique page size of the region, and a physical address corresponding to the virtual address using the address translation information of the region including the virtual address. A memory management unit having a search unit for searching for information, and performing address conversion from a virtual address to a physical address in units of pages;
Is an information processing apparatus.
 本明細書で開示する技術によれば、アドレス変換の対象となる複数のリージョンを定義するとともに、リージョン毎のページサイズを定義することによって、小容量メモリシステム上でもページ単位で効率的にアドレス変換を行うメモリ管理装置及びメモリ管理方法、並びに情報処理装置を提供することができる。 According to the technology disclosed in this specification, by defining a plurality of regions that are subject to address translation and defining a page size for each region, address translation can be efficiently performed on a page basis even on a small-capacity memory system. A memory management device, a memory management method, and an information processing device can be provided.
 なお、本明細書に記載された効果は、あくまでも例示であり、本発明の効果はこれに限定されるものではない。また、本発明が、上記の効果以外に、さらに付加的な効果を奏する場合もある。 In addition, the effect described in this specification is an illustration to the last, and the effect of this invention is not limited to this. In addition to the above effects, the present invention may have additional effects.
 本明細書で開示する技術のさらに他の目的、特徴や利点は、後述する実施形態や添付する図面に基づくより詳細な説明によって明らかになるであろう。 Other objects, features, and advantages of the technology disclosed in the present specification will become apparent from a more detailed description based on embodiments to be described later and the accompanying drawings.
図1は、本明細書で開示する技術を適用可能な組み込み機器を含むシステム1の構成例を模式的に示した図である。FIG. 1 is a diagram schematically illustrating a configuration example of a system 1 including an embedded device to which the technology disclosed in this specification can be applied. 図2は、センシングデバイス100のハードウェア構成例を示した図である。FIG. 2 is a diagram illustrating a hardware configuration example of the sensing device 100. 図3は、MMU102の構成例をアドレス変換の仕組みとともに示した図である。FIG. 3 is a diagram illustrating a configuration example of the MMU 102 together with an address translation mechanism. 図4は、MMU102を初期化する処理手順を示したフローチャートである。FIG. 4 is a flowchart showing a processing procedure for initializing the MMU 102. 図5は、初期化した後のMMU102において仮想アドレスから物理アドレスに変換するための処理手順を示したフローチャートである。FIG. 5 is a flowchart showing a processing procedure for converting a virtual address to a physical address in the MMU 102 after initialization. 図6は、アドレス変換機構303が仮想アドレスを物理アドレスに変換するための処理手順を示したフローチャートである。FIG. 6 is a flowchart showing a processing procedure for the address translation mechanism 303 to translate a virtual address into a physical address. 図7は、ページウォーク機構304が物理メモリ305上のページテーブルを参照するための処理手順を示したフローチャートである。FIG. 7 is a flowchart showing a processing procedure for the page walk mechanism 304 to refer to the page table on the physical memory 305. 図8は、MMU102を用いてアドレス変換を行う具体例を示した図である。FIG. 8 is a diagram illustrating a specific example in which address translation is performed using the MMU 102. 図9は、MMU102を用いてアドレス変換を行う具体例を示した図である。FIG. 9 is a diagram illustrating a specific example in which address translation is performed using the MMU 102. 図10は、MMU102を用いてアドレス変換を行う具体例を示した図である。FIG. 10 is a diagram illustrating a specific example in which address translation is performed using the MMU 102. 図11は、MMU102を用いてアドレス変換を行う具体例を示した図である。FIG. 11 is a diagram illustrating a specific example in which address translation is performed using the MMU 102. 図12は、MMU102を用いて実現される、仮想アドレス空間におけるリージョンの構成例を示した図である。FIG. 12 is a diagram showing a configuration example of a region in the virtual address space realized by using the MMU 102. 図13は、図1及び図2に示した組込み機器を実現するハードウェアで動作するソフトウェアの構成例を示した図である。FIG. 13 is a diagram illustrating a configuration example of software that operates on hardware that implements the embedded device illustrated in FIGS. 1 and 2. 図14は、オペレーティングシステムを用いたメモリ管理方法を説明するための図である。FIG. 14 is a diagram for explaining a memory management method using an operating system. 図15は、仮想メモリマネージャによって提供される仮想アドレス空間と、その上で実行される各タスクの関係を示した図である。FIG. 15 is a diagram showing the relationship between the virtual address space provided by the virtual memory manager and each task executed on the virtual address space. 図16は、仮想メモリマネージャによって提供されるリージョンのうち、Region#0をテキスト領域として使用するための仕組みを説明するための図である。FIG. 16 is a diagram for explaining a mechanism for using Region # 0 as a text area among the regions provided by the virtual memory manager. 図17は、フラッシュメモリ104内のファイルをメモリ空間へマッピングするための処理手順を示したフローチャートである。FIG. 17 is a flowchart showing a processing procedure for mapping a file in the flash memory 104 to a memory space. 図18は、メモリ空間へマッピングしたファイルを解放するための処理手順を示したフローチャートである。FIG. 18 is a flowchart showing a processing procedure for releasing a file mapped to the memory space. 図19は、Region#1及びRegion#2をヒープ領域として使用するための仕組みを説明するための図である。FIG. 19 is a diagram for explaining a mechanism for using Region # 1 and Region # 2 as heap areas. 図20は、ヒープ領域からメモリを確保するための処理手順を示したフローチャートである。FIG. 20 is a flowchart showing a processing procedure for securing memory from the heap area. 図21は、ヒープ領域に確保したメモリを解放するための処理手順を示したフローチャートである。FIG. 21 is a flowchart showing a processing procedure for releasing the memory secured in the heap area. 図22は、ページサイズが4KBに定義されているRegion#1からメモリを確保する処理を示したフローチャートである。FIG. 22 is a flowchart showing a process of allocating a memory from Region # 1 in which the page size is defined as 4 KB. 図23は、ページサイズが4KBに定義されているRegion#1に確保したメモリを解放する処理を示したフローチャートである。FIG. 23 is a flowchart showing a process of releasing the memory secured in Region # 1 where the page size is defined as 4 KB. 図24は、ページサイズが1KBに定義されているRegion#2からメモリを確保する処理を示したフローチャートである。FIG. 24 is a flowchart showing a process of allocating memory from Region # 2 in which the page size is defined as 1 KB. 図25は、ページサイズが1KBに定義されているRegion#2に確保したメモリを解放する処理を示したフローチャートである。FIG. 25 is a flowchart showing a process of releasing the memory secured in Region # 2 where the page size is defined as 1 KB. 図26は、メモリブロックマネージャから空きメモリブロックを取得するための処理手順を示したフローチャートである。FIG. 26 is a flowchart showing a processing procedure for acquiring an empty memory block from the memory block manager. 図27は、メモリブロックマネージャへメモリブロックを返すための処理手順を示したフローチャートである。FIG. 27 is a flowchart showing a processing procedure for returning a memory block to the memory block manager. 図28は、仮想メモリマネージャによって提供されるリージョンのうち、Region#3をスタック領域として使用するための仕組みを説明するための図である。FIG. 28 is a diagram for explaining a mechanism for using Region # 3 as a stack area among the regions provided by the virtual memory manager. 図29は、スタック領域を動的に割り当てるための処理手順を示した図である。FIG. 29 is a diagram showing a processing procedure for dynamically allocating the stack area. 図30は、タスク終了時にスタックを解放するための処理手順を示したフローチャートである。FIG. 30 is a flowchart showing a processing procedure for releasing the stack at the end of the task.
 以下、図面を参照しながら本明細書で開示する技術の実施形態について詳細に説明する。 Hereinafter, embodiments of the technology disclosed in this specification will be described in detail with reference to the drawings.
 本明細書では、仮想アドレス空間全体に対してアドレス変換を行うメモリ管理方式を小容量のメモリしか持たない機器に適用した場合に、仮想アドレス空間の中で実際に使われる領域が小さいために無駄なメモリ消費が発生することや、フラグメンテーション抑止のために小さいページサイズに固定するとページテーブルが大きくなり無駄なメモリ消費が発生することに鑑みて、新規のメモリ管理方式を提案する。 In this specification, when the memory management method for performing address translation for the entire virtual address space is applied to a device having only a small amount of memory, the area actually used in the virtual address space is small, which is wasteful. A new memory management method is proposed in view of the fact that unnecessary memory consumption occurs and that the page table becomes large and wasteful memory consumption occurs when the page size is fixed to prevent fragmentation.
 本明細書で開示する技術によれば、仮想アドレス空間の中で、アドレス変換の対象となる複数の領域(リージョン)を定義して、各リージョンにおいてページ単位でアドレス変換を行うが、リージョン毎に固有のページサイズを定義することが可能であり、したがって、小容量メモリシステム上でも効率的にMMUを用いたアドレス変換を実現することができる。また、本明細書で開示する技術によれば、リージョン毎に固定のページサイズを持ち、各リージョンのアドレス変換を行うページテーブル上では、ページサイズに拘わらず1ページは1エントリを使用するので、アドレス変換を効率的に行うことができる。 According to the technology disclosed in this specification, a plurality of regions (regions) that are subject to address translation are defined in the virtual address space, and address translation is performed in units of pages in each region. A unique page size can be defined, and therefore, address translation using the MMU can be efficiently realized even in a small-capacity memory system. Further, according to the technique disclosed in this specification, each page has a fixed page size, and one page uses one entry regardless of the page size on the page table that performs address conversion of each region. Address translation can be performed efficiently.
 一般に、プログラムが動作する際にはテキスト領域、ヒープ領域、スタック領域といった複数の種類の領域を使用するが、これらの領域はそれぞれ異なる特徴を持つ。 Generally, when a program operates, a plurality of types of areas such as a text area, a heap area, and a stack area are used, but these areas have different characteristics.
 テキスト領域は、命令コードやプログラムの実行時に参照する読み込み専用のデータなどが含まれる。組み込み機器の場合にはフラッシュメモリなどの不揮発メモリに置かれたデータがこれに使用されることが多い。フラッシュメモリへの書き込みは特定のブロックサイズ(典型的には64KB程度)を単位として行われることを考慮すると、テキスト領域はこうしたブロックサイズを単位として扱うことが効率的である。 The text area includes instruction codes and read-only data that is referenced during program execution. In the case of an embedded device, data stored in a nonvolatile memory such as a flash memory is often used for this. Considering that writing to the flash memory is performed in units of a specific block size (typically about 64 KB), it is efficient to treat the text area in units of such block sizes.
 ヒープ領域は、プログラムの実行中に保持する必要のあるデータを置くために、実行中に動的に確保と解放が行われる領域である。ヒープ領域からどのような単位でメモリを確保するかは、処理内容やプログラムの書き方に大きく依存し、数バイトのこともあれば数100KBを超えることもある。異なるサイズのメモリの確保と解放が繰り返されると、メモリの断片化が発生し、全体としては空きがあるにも関わらず要求を満たす連続したメモリを確保することができなくなることがある。メモリの断片化の状況を避けるためには、ヒープ領域をいくつかの領域に分類し、確保するメモリのサイズによってそれらを使い分けるといった方法が考えられる。 The heap area is an area that is dynamically secured and released during execution in order to place data that needs to be retained during program execution. The unit in which the memory is secured from the heap area largely depends on the processing contents and the way of writing the program, and may be several bytes or may exceed several hundred KB. If securing and releasing of memories of different sizes are repeated, memory fragmentation may occur, and it may not be possible to secure a continuous memory that satisfies the request even though there is a free space as a whole. In order to avoid the situation of memory fragmentation, a method of classifying the heap area into several areas and using them properly depending on the size of the memory to be secured can be considered.
 スタック領域は、プログラムの実行における関数呼び出しの進行などにより、動的に使用量が増えていく領域であるが、プログラムの書き方や処理内容によって使用量が大きく変化するため、事前に容量を決めておくことが難しい。そのため、使用状況に応じてページサイズ毎にメモリを動的に割り当てていくことが考えられるが、システムで動作するタスクの平均的なスタック消費量が小さい場合は、それに合わせて割り当て単位となるページサイズも小さいことが望ましい。 The stack area is an area where the amount of usage increases dynamically due to the progress of function calls during program execution, etc., but the amount of usage varies greatly depending on how the program is written and the contents of processing. It is difficult to leave. Therefore, it is possible to dynamically allocate memory for each page size depending on the usage status, but if the average stack consumption of tasks running on the system is small, the page that is the allocation unit accordingly It is desirable that the size is small.
 このように異なる特徴をもった複数のメモリ領域に対しても、本明細書で開示する技術を適用したMMUによって、それぞれに適切なページサイズを持ったリージョンを割り当てることができ、各メモリ領域それぞれの特徴に合致した、効率的なメモリ管理が行えるようになる。 Thus, even for a plurality of memory areas having different characteristics, a region having an appropriate page size can be allocated to each of the memory areas by the MMU to which the technology disclosed in this specification is applied. Efficient memory management that matches the characteristics of
 図1には、本明細書で開示する技術を適用可能な組み込み機器を含むシステム1の構成例を模式的に示している。図示のシステム1は、組み込み機器に相当するセンシングデバイス100と、基地局200と、クラウド201上に設置されたサーバ202で構成される。センシングデバイス100は、基地局200に無線接続して、クラウド201経由でサーバ202にアクセスすることができる。 FIG. 1 schematically shows a configuration example of a system 1 including an embedded device to which the technology disclosed in this specification can be applied. The illustrated system 1 includes a sensing device 100 corresponding to an embedded device, a base station 200, and a server 202 installed on a cloud 201. The sensing device 100 can wirelessly connect to the base station 200 and access the server 202 via the cloud 201.
 センシングデバイス100は、CPU(Central Processing Unit)101、MMU102、SRAM(Static RAM(Random Access Memory))103やフラッシュメモリ104などのメモリ、センサ105、通信モジュール106を備え、電池107で駆動する機器である。 The sensing device 100 includes a CPU (Central Processing Unit) 101, an MMU 102, an SRAM (Static RAM (Random Access Memory)) 103, a memory such as a flash memory 104, a sensor 105, and a communication module 106, and is a device driven by a battery 107. is there.
 センシングデバイス100は、例えば装着者に装着して用いられる。CPU101は、センサ105の検出信号に基づいて装着者の行動(止まっている、歩いている、走っているなど)を解析する。そして、解析結果を通信モジュール106から基地局200へ無線送信し、クラウド201経由でサーバ202に記録される。サーバ202は、センシングデバイス100から受け取ったデータを、装着者の見守りなどに使用する。 The sensing device 100 is used by being worn by a wearer, for example. The CPU 101 analyzes the wearer's behavior (stopped, walking, running, etc.) based on the detection signal of the sensor 105. Then, the analysis result is wirelessly transmitted from the communication module 106 to the base station 200 and recorded in the server 202 via the cloud 201. The server 202 uses the data received from the sensing device 100 for monitoring the wearer.
 図2には、組み込み機器の一例としてのセンシングデバイス100のハードウェア構成例を示している。 FIG. 2 shows a hardware configuration example of the sensing device 100 as an example of an embedded device.
 CPU101は、MMU102経由でシステムバス110に接続されている。また、システムバス110上には、SRAM103、フラッシュメモリ104、センサ105、通信モジュール106といったデバイスが接続されている。 The CPU 101 is connected to the system bus 110 via the MMU 102. On the system bus 110, devices such as an SRAM 103, a flash memory 104, a sensor 105, and a communication module 106 are connected.
 フラッシュメモリ104は、例えば、センサ105の信号に基づいて装着者の行動を推定するアプリケーションや、アプリケーションを実行する際に使用するライブラリ、装着者の行動を推定するための行動推定辞書などのデータを格納している。また、センサ105は、加速度センサ、気圧センサ、ジャイロ、GPS(Global Positioning System)、TOF(Time Of Flight)画像距離センサ、LIDAR(Light Detection and Ranging)センサなど、1以上のセンサデバイスで構成される。 The flash memory 104 stores, for example, data such as an application that estimates the wearer's behavior based on a signal from the sensor 105, a library used when executing the application, and a behavior estimation dictionary for estimating the wearer's behavior. Storing. The sensor 105 includes one or more sensor devices such as an acceleration sensor, an atmospheric pressure sensor, a gyro, a GPS (Global Positioning System), a TOF (Time Of Flight) image distance sensor, and a LIDAR (Light Detection and Ranging) sensor. .
 システムバス110に接続されたこれらデバイスが配置される物理アドレス空間が、MMU102によるアドレス変換の対象となる。この物理アドレス空間には、SRAM103が配置される他、フラッシュメモリ104がその内容がCPU101若しくはMMU102から直接見える形で配置されていたり、通信モジュール106や、センサ105に含まれる各種センサデバイスのI/Oポートが配置されていたりする。 The physical address space in which these devices connected to the system bus 110 are arranged is a target of address conversion by the MMU 102. In this physical address space, the SRAM 103 is arranged, and the flash memory 104 is arranged so that the contents can be directly seen from the CPU 101 or the MMU 102, or the I / O of various sensor devices included in the communication module 106 or the sensor 105. O port is arranged.
 図3には、本実施形態に係るMMU102の構成例を示している。同図では、MMU102によって、仮想アドレス(Virtual Address:VA)から物理アドレス(Physical Address:PA)へ変換される流れを併せて示している。 FIG. 3 shows a configuration example of the MMU 102 according to the present embodiment. In the figure, the flow of conversion from a virtual address (Virtual Address: VA) to a physical address (Physical Address: PA) by the MMU 102 is also shown.
 図示のMMU102は、トランスレーションルックアサイドバッファ(TLB)301と、リージョンデスクリプタ302の2つのブロックを備えている。 The illustrated MMU 102 includes two blocks, a translation lookaside buffer (TLB) 301 and a region descriptor 302.
 TLB301は、一般的なMMUと同様に、ページ単位で仮想アドレスから物理アドレスへ変換するための情報を持つために用いられる。TLB301のエントリ数は任意である。例えば、アドレス変換の効率とMMUを実現する回路規模のトレードオフから、MMUの設計者がTLBのエントリ数を決定する。 The TLB 301 is used to hold information for converting a virtual address to a physical address in units of pages, like a general MMU. The number of entries in the TLB 301 is arbitrary. For example, the MMU designer determines the number of TLB entries based on the tradeoff between the efficiency of address translation and the circuit scale for realizing the MMU.
 TLB301の各エントリT0~Tnは、ベース仮想アドレスTB0~TBn、ベース物理アドレスTT0~TTn、ページサイズTP0~TPn、エントリ有効フラグTV0~TVnをそれぞれ持つ。ベース仮想アドレスTB0~TBnには、各々のTLBエントリT0~Tnによってアドレス変換が行われるページの仮想アドレスが格納される。ベース物理アドレスTT0~TTnには、各々のTLBエントリT0~Tnのベース仮想アドレスTB0~TBnに対応する変換後の物理アドレスが格納される。ページサイズTP0~TPnには、各々のTLBエントリT0~Tnが示すページのサイズ(すなわち、仮想アドレスTB0~TBnが属するリージョンに定義されているページのサイズ)が格納される。エントリ有効フラグTV0~TVnには、各々のTLBエントリT0~Tn自体の有効性(有効又は無効)を示すフラグが格納される。 Each entry T 0 to T n of the TLB 301 has a base virtual address TB 0 to TB n , a base physical address TT 0 to TT n , a page size TP 0 to TP n , and entry valid flags TV 0 to TV n , respectively. In the base virtual addresses TB 0 to TB n , virtual addresses of pages whose addresses are converted by the respective TLB entries T 0 to T n are stored. In the base physical addresses TT 0 to TT n , converted physical addresses corresponding to the base virtual addresses TB 0 to TB n of the respective TLB entries T 0 to T n are stored. The page sizes TP 0 to TP n store the size of the page indicated by each TLB entry T 0 to T n (that is, the size of the page defined in the region to which the virtual addresses TB 0 to TB n belong). . The entry valid flags TV 0 to TV n store flags indicating the validity (valid or invalid) of the respective TLB entries T 0 to T n themselves.
 リージョンデスクリプタ302は、MMU102によるアドレス変換の対象となる領域(リージョン)を設定するために用いられる。そのため、このMMU102が提供することのできるリージョンの個数だけのエントリをリージョンデスクリプタ302が持つ。図3に示す例では、リージョンデスクリプタ302は、R0~R3の4つのエントリを持っている。 The region descriptor 302 is used to set a region (region) that is a target of address conversion by the MMU 102. Therefore, the region descriptor 302 has as many entries as the number of regions that the MMU 102 can provide. In the example shown in FIG. 3, the region descriptor 302 has four entries R 0 to R 3 .
 リージョンデスクリプタ302の各エントリR0~R3は、ベース仮想アドレスRB0~RB3、ページテーブルアドレスRT0~RT3、ページサイズRP0~RP3、リージョンサイズRS0~RS3を持つ。ベース仮想アドレスRB0~RB3には、各々のリージョンR0~R3が配置される仮想アドレス空間上の先頭アドレスが格納される。ページテーブルアドレスRT0~RT3には、各々のリージョンR0~R3について仮想アドレスから物理アドレスへの変換に使用されるページテーブルP0~P3が置かれている物理アドレスが格納される。ページサイズRP0~RP3には、各々のリージョンR0~R3を構成するページのページサイズのサイズが格納される。リージョンサイズRS0~RS3には、各々のリージョンR0~R3自体のサイズが格納される。 Each entry R 0 to R 3 of the region descriptor 302 has a base virtual address RB 0 to RB 3 , a page table address RT 0 to RT 3 , a page size RP 0 to RP 3 , and a region size RS 0 to RS 3 . The base virtual addresses RB 0 to RB 3 store the head addresses in the virtual address space where the regions R 0 to R 3 are arranged. The page table addresses RT 0 to RT 3 store the physical addresses where the page tables P 0 to P 3 used for the conversion from the virtual address to the physical address are stored for each region R 0 to R 3. . The page sizes RP 0 to RP 3 store the size of the page size of each page constituting each region R 0 to R 3 . The region sizes RS 0 to RS 3 store the sizes of the regions R 0 to R 3 themselves.
 物理メモリ305上には、リージョンの数と同数のページテーブルP0~P3が存在する。リージョン毎のページテーブルP0~P3はそれぞれ、対応するリージョンのページ数と同じエントリ数を持ち、各エントリには対応するリージョンにおけるページの変換先の物理アドレスが格納されている。リージョンサイズをそのリージョンのページサイズで割った値が、そのリージョンのページ数となる(リージョンRxの場合、RSx/RPxがそのリージョンのページ数となる)。 On the physical memory 305, there are as many page tables P 0 to P 3 as there are regions. The page tables P 0 to P 3 for each region have the same number of entries as the number of pages in the corresponding region, and each entry stores the physical address of the page conversion destination in the corresponding region. A value obtained by dividing the region size by the page size of the region is the number of pages in the region (in the case of region R x , RS x / RP x is the number of pages in the region).
 図示のMMU102における仮想アドレスから物理アドレスへのアドレス変換は、仮想アドレスとTLB301及びリージョンデスクリプタ302それぞれの各エントリのベースアドレスを比較し、一致するエントリが存在するかどうかに応じて行われる。仮想アドレスから物理アドレスへ変換する流れについて説明しておく。 The address translation from the virtual address to the physical address in the illustrated MMU 102 is performed by comparing the virtual address with the base address of each entry of the TLB 301 and the region descriptor 302, and whether or not a matching entry exists. A flow for converting a virtual address to a physical address will be described.
 CPU101は、仮想アドレスを用いてメモリ空間にアクセスする。MMU102は、アクセス要求された仮想アドレスのベースアドレス部分と、TLB301の各エントリT0~Tnのベース仮想アドレスTB0~TBnを比較する。ここで、対応するエントリが見つかった、すなわちTLBヒットした場合には、アドレス変換機構303はそのエントリを用いてベース仮想アドレスをベース物理アドレスに変換する。そして、そのベース物理アドレスと、アクセス要求された仮想アドレスのオフセットアドレスとを組み合わせて、物理アドレスを得ることができる。 The CPU 101 accesses the memory space using a virtual address. The MMU 102 compares the base address portion of the virtual address requested to be accessed with the base virtual addresses TB 0 to TB n of the entries T 0 to T n of the TLB 301. Here, when a corresponding entry is found, that is, when a TLB hit occurs, the address translation mechanism 303 translates the base virtual address into a base physical address using the entry. Then, the physical address can be obtained by combining the base physical address and the offset address of the virtual address requested to be accessed.
 一方、TLB301の中からアクセス要求された仮想アドレスのベースアドレス部分に対応するエントリが見つからなかった、すなわちTLBミスした場合には、MMU102は、アクセス要求された仮想アドレスのベースアドレス部分と、リージョンデスクリプタ302の各エントリR0~R3のベース仮想アドレスRB0~RB3と比較して、対応するエントリ内のページテーブルアドレスRTXを参照する。ページウォーク機構304は、そのページテーブルアドレスRTXを用いて物理メモリ305上の該当するページテーブルPXを参照して、アクセス要求された仮想アドレスに該当するページテーブルエントリを見つけ出すと、得られた内容に基づいてTLB301内の任意のエントリを更新する。このようにして、アクセス要求された仮想アドレスと物理アドレスをマッピングする新たなエントリがTLB301に格納される。 On the other hand, if an entry corresponding to the base address portion of the virtual address requested to be accessed is not found in the TLB 301, that is, if a TLB miss is found, the MMU 102 determines the base address portion of the virtual address requested to be accessed and the region descriptor. compared to the base virtual address RB 0 ~ RB 3 in each entry R 0 ~ R 3 302, referring to the page table address RT X in the corresponding entry. When the page walk mechanism 304 finds a page table entry corresponding to the requested virtual address by referring to the corresponding page table P X on the physical memory 305 using the page table address RT X , it is obtained. An arbitrary entry in the TLB 301 is updated based on the content. In this way, a new entry for mapping the virtual address and physical address requested for access is stored in the TLB 301.
 図4~図7には、アドレス変換に関連する処理手順を、それぞれフローチャートの形式で示している。 4 to 7 show processing procedures related to address conversion in the form of flowcharts.
 図4には、MMU102を初期化するための処理手順をフローチャートの形式で示している。MMU102の初期化は、基本的には、オペレーティングシステム(OS)の起動時に実施される。 FIG. 4 shows a processing procedure for initializing the MMU 102 in the form of a flowchart. The initialization of the MMU 102 is basically performed when the operating system (OS) is started.
 まず、TLB301内のすべてのエントリを無効に設定する(ステップS401)。具体的には、すべてのエントリのエントリ有効フラグTV0~TVnにFalseを代入する。 First, all entries in the TLB 301 are set to be invalid (step S401). Specifically, False is assigned to the entry valid flags TV 0 to TV n of all entries.
 そして、リージョンデスクリプタ302内の各エントリR0~R3に対して、各リージョンを定義するためにベース仮想アドレスRB0~RB3、ページテーブルアドレスRT0~RT3、ページサイズRP0~RP3、リージョンサイズRS0~RS3を設定する(ステップS402)。 For each entry R 0 to R 3 in the region descriptor 302, base virtual addresses RB 0 to RB 3 , page table addresses RT 0 to RT 3 , page sizes RP 0 to RP 3 for defining each region. Region sizes RS 0 to RS 3 are set (step S402).
 なお、詳細な説明を省略するが、OSの起動時には、物理メモリ305上のリージョン毎の各ページテーブルP0~P3の初期化も実施される。 Although detailed explanation is omitted, when the OS is started, the page tables P 0 to P 3 for each region on the physical memory 305 are also initialized.
 図5には、初期化した後のMMU102において仮想アドレスから物理アドレスに変換するための処理手順をフローチャートの形式で示している。 FIG. 5 shows a processing procedure for converting a virtual address to a physical address in the MMU 102 after initialization in the form of a flowchart.
 まず、要求された仮想アドレスとTLB301内の各エントリT0~Tnを比較して(ステップS501)、いずれかのエントリと合致するかどうかをチェックする(ステップS502)。ここで、x番目のエントリTxに関して、ベース仮想アドレスTBxと、ベース仮想アドレスTBxにページサイズTPxを加算した範囲内に仮想アドレスVAが含まれていれば(すなわち、TBx≦VA<TBx+TPx、且つ、TVx=True)、仮想アドレスVAはそのエントリTxと合致することになる。 First, the requested virtual address is compared with each entry T 0 to T n in the TLB 301 (step S501), and it is checked whether any entry matches (step S502). Here, the x-th entry T x, the base virtual address TB x, if it contains the virtual address VA is in the range obtained by adding the page size TP x to the base virtual address TB x (i.e., TB x ≦ VA <TB x + TP x and TV x = True), the virtual address VA matches the entry T x .
 そして、要求された仮想アドレスに合致するエントリがTLB301内で見つかった場合には(ステップS502のYes)、アドレス変換機構303による仮想アドレスから物理アドレスへの変換処理を実行する(ステップS503)。アドレス変換機構303による仮想アドレスから物理アドレスへの変換処理の詳細については、図6を参照されたい。 If an entry that matches the requested virtual address is found in the TLB 301 (Yes in step S502), the address conversion mechanism 303 performs a conversion process from the virtual address to the physical address (step S503). Refer to FIG. 6 for details of the conversion process from the virtual address to the physical address by the address translation mechanism 303.
 一方、要求された仮想アドレスに合致するエントリがTLB301内で見つからなかった場合(ステップS502のNo)、すなわちTLBミスした場合には、続いて、要求された仮想アドレスとリージョンデスクリプタ302内の各エントリR0~Rnを比較して(ステップS504)、いずれかのエントリと合致するかどうかをチェックする(ステップS505)。ここで、x番目のエントリRxに関して、ベース仮想アドレスRBxと、ベース仮想アドレスRBxにページサイズRSxを加算した範囲内に仮想アドレスVAが含まれていれば(すなわち、RBx≦VA<RBx+RSx)、仮想アドレスVAはそのエントリRxと合致することになる。 On the other hand, if an entry that matches the requested virtual address is not found in the TLB 301 (No in step S502), that is, if a TLB miss occurs, the requested virtual address and each entry in the region descriptor 302 are subsequently continued. R 0 to R n are compared (step S504), and it is checked whether any entry matches (step S505). Here, the x-th entry R x, base and virtual address RB x, if it contains the virtual address VA is in the range obtained by adding the page size RS x to the base virtual address RB x (i.e., RB x ≦ VA <RB x + RS x ), the virtual address VA matches the entry R x .
 そして、要求された仮想アドレスに合致するエントリがリージョンデスクリプタ302内で見つかった場合には(ステップS505のYes)、ページウォーク機構304による物理メモリ305上のページテーブル参照処理を実行して(ステップS506)、アクセス要求された仮想アドレスと物理アドレスをマッピングする新たなエントリをTLB301に作成する。その後、ステップS501に戻り、アドレス変換機構303による仮想アドレスから物理アドレスへの変換処理を改めて実行する。ページウォーク機構304による物理メモリ305上のページテーブル参照処理の詳細については、図7を参照されたい。 If an entry matching the requested virtual address is found in the region descriptor 302 (Yes in step S505), a page table reference process on the physical memory 305 by the page walk mechanism 304 is executed (step S506). ), A new entry is created in the TLB 301 for mapping the requested virtual address and physical address. Thereafter, the process returns to step S501, and the conversion process from the virtual address to the physical address by the address conversion mechanism 303 is executed again. Refer to FIG. 7 for details of the page table reference processing on the physical memory 305 by the page walk mechanism 304.
 なお、リージョンデスクリプタ302内でも、要求された仮想アドレスに合致するエントリが見つからなかった場合には(ステップS505のNo)、アドレス変換が不能なので、バスフォルトエラーを発生して、仮想アドレスから物理アドレスへの変換処理を中止する。 If no entry matching the requested virtual address is found in the region descriptor 302 (No in step S505), a bus fault error occurs and the physical address is changed from the virtual address to the physical address. Cancel the conversion process.
 図6には、図5に示したフローチャート中のステップS506で実行される、アドレス変換機構303が仮想アドレスを物理アドレスに変換するための処理手順をフローチャートの形式で示している。 FIG. 6 shows a processing procedure for converting the virtual address to the physical address by the address translation mechanism 303 executed in step S506 in the flowchart shown in FIG. 5 in the form of a flowchart.
 アドレス変換機構303は、TLB301内の、要求された仮想アドレスと合致するエントリTxからベース物理アドレスTTxを取得すると(ステップS601)、そのベース物理アドレスと、アクセス要求された仮想アドレスのオフセットアドレスとを組み合わせて、物理アドレスを計算する(ステップS602)。 When the address translation mechanism 303 obtains the base physical address TT x from the entry T x that matches the requested virtual address in the TLB 301 (step S601), the base physical address and the offset address of the requested virtual address are accessed. Are combined to calculate the physical address (step S602).
 ステップS602では、具体的には、TLB301内のエントリTxから取得した物理アドレスTTxに、要求された仮想アドレスVAとベース仮想アドレスTBxの差分を加算して、物理アドレスPAを求めることができる(すなわち、PA←TTx+(VA-TBx))。 In step S602, specifically, the physical address TT x acquired from the entry T x in TLB301, by adding the difference between the requested virtual address VA and the base virtual address TB x, be determined physical address PA (Ie, PA ← TT x + (VA−TB x )).
 図7には、図5に示したフローチャート中のステップS506で実行される、ページウォーク機構304が物理メモリ305上のページテーブルを参照して、仮想アドレスと物理アドレスをマッピングする新たなエントリをTLB301に作成するための処理手順をフローチャートの形式で示している。 In FIG. 7, the page walk mechanism 304 executed in step S506 in the flowchart shown in FIG. 5 refers to the page table on the physical memory 305, and a new entry for mapping the virtual address and the physical address is displayed in the TLB 301. The processing procedure for creating the data is shown in the form of a flowchart.
 ページウォーク機構304は、まず、リージョンデスクリプタ302の対応するエントリRxに格納されている情報と、要求された仮想アドレスVAに基づいて、物理メモリ305上の該当するページテーブルの何ページ目のエントリを取得すべきかを決定する(ステップS701)。具体的には、仮想アドレスVAとベース仮想アドレスRBxの差分をそのリージョンのページサイズRPxで割って、整数に切り捨てた値nが、ページテーブルのエントリとなる(すなわち、n←int((VA-RBx)/RPx))。 The page walk mechanism 304 first determines the page number of the corresponding page table in the physical memory 305 based on the information stored in the corresponding entry Rx of the region descriptor 302 and the requested virtual address VA. Is to be acquired (step S701). Specifically, a value n obtained by dividing the difference between the virtual address VA and the base virtual address RB x by the page size RP x of the region and rounding it to an integer becomes an entry in the page table (that is, n ← int (( VA-RB x ) / RP x )).
 次いで、ページウォーク機構304は、リージョンデスクリプタ302の対応するエントリRxに格納されているページテーブルアドレスRTxの物理アドレスに置かれているページテーブルから、n番目のエントリの値PP、すなわち要求された仮想アドレスVAに対応するベース物理アドレスを取得する(すなわち、PP←Pxn)(ステップS702)。 Next, the page walk mechanism 304 requests the value PP of the nth entry from the page table located at the physical address of the page table address RT x stored in the corresponding entry R x of the region descriptor 302, that is, requested. The base physical address corresponding to the virtual address VA is acquired (that is, PP ← P xn ) (step S702).
 次いで、ページウォーク機構304は、TLB301内に無効のエントリTVyが存在するかどうかをチェックする(すなわち、TVy=False)(ステップS703)。 Next, the page walk mechanism 304 checks whether there is an invalid entry TV y in the TLB 301 (ie, TV y = False) (step S703).
 ここで、TLB301内に無効のエントリTVyが存在しない場合には(ステップS703のNo)、ページウォーク機構304は、TLB301内の任意のy番目のエントリを選択して、無効エントリに設定する(すなわち、TVy←False)(ステップS704)。 If there is no invalid entry TV y in the TLB 301 (No in step S703), the page walk mechanism 304 selects an arbitrary y-th entry in the TLB 301 and sets it as an invalid entry ( That is, TV y ← False) (step S704).
 そして、ページウォーク機構304は、TLB301内で見つけた無効のエントリy(若しくは、無効に設定したエントリy)を有効化して、当該エントリに新たなアドレス変換情報を設定する(ステップS705)。具体的には、エントリ有効フラグTVyを有効とし、新たなベース仮想アドレスTBy、ベース物理アドレスTTy、ページサイズTPyを設定する(すなわち、TBy←RBx+(RPx×n)、TTy←PP、TPy←RPx、TVy←True)。 Then, the page walk mechanism 304 validates the invalid entry y found in the TLB 301 (or the invalid entry y) and sets new address translation information for the entry (step S705). Specifically, the entry valid flag TV y is validated, and a new base virtual address TB y , base physical address TT y , and page size TP y are set (ie, TB y ← RB x + (RP x × n)). TT y ← PP, TP y ← RP x , TV y ← True).
 このようにして、アクセス要求された仮想アドレスと物理アドレスをマッピングする新たなエントリがTLB301に格納される。 In this way, a new entry mapping the virtual address and physical address requested to be accessed is stored in the TLB 301.
 図8~図11には、MMU102を用いてアドレス変換を行う具体例を示している。ここでは、例として仮想アドレス空間上に以下の表1に示すような4つのリージョンが定義されているものする(但し、0xはその値が16進数であることを示す)。 8 to 11 show specific examples of performing address conversion using the MMU 102. FIG. Here, as an example, four regions as shown in Table 1 below are defined in the virtual address space (however, 0x indicates that the value is a hexadecimal number).
Figure JPOXMLDOC01-appb-T000001
Figure JPOXMLDOC01-appb-T000001
 各リージョンは、ページテーブルアドレスに設定された物理アドレス(RT0~RT3)にそれぞれページテーブル(P0~P3)を持つ。各ページテーブル(P0~P3)には、ページ単位で仮想アドレスを変換した後の物理アドレス(P00~P3n)が格納されている。上記の表1に示す例では、リージョンR0の場合、リージョンサイズがRS0=16MB、ページサイズがRP0=64KBなので、RS0/RP0=256 が、このページテーブルのエントリ数となる。 Each region has a page table (P 0 to P 3 ) at a physical address (RT 0 to RT 3 ) set as the page table address. Each page table (P 0 to P 3 ) stores a physical address (P 00 to P 3n ) after the virtual address is converted in page units. In the example shown in Table 1 above, in the case of region R 0 , the region size is RS 0 = 16 MB and the page size is RP 0 = 64 KB, so RS 0 / RP 0 = 256 is the number of entries in this page table.
 したがって、リージョンデスクリプタ302のエントリR0には、ベース仮想アドレスRB0=0x10000000、ページテーブルアドレスRT0=0x00010000、ページサイズRP0=64KB、リージョンサイズRS0=16MBが格納される。また、エントリR1には、ベース仮想アドレスRB1=0x20000000、ページテーブルアドレスRT1=0x00020000、ページサイズRP0=4KB、リージョンサイズRS1=1MBが格納される。また、エントリR2には、ベース仮想アドレスRB2=0x30000000、ページテーブルアドレスRT2=0x00030000、ページサイズRP2=1KB、リージョンサイズRS2=256KBが格納される。また、エントリR3には、ベース仮想アドレスRB2=0x40000000、ページテーブルアドレスRT3=0x00040000、ページサイズRP3=1KB、リージョンサイズRS3=256KBが格納される。 Therefore, the entry R 0 of the region descriptor 302 stores the base virtual address RB 0 = 0x10000000, the page table address RT 0 = 0x00010000, the page size RP 0 = 64 KB, and the region size RS 0 = 16 MB. In addition, the base virtual address RB 1 = 0x20000000, page table address RT 1 = 0x0020000, page size RP 0 = 4 KB, and region size RS 1 = 1 MB are stored in the entry R 1 . In addition, the base virtual address RB 2 = 0x30000000, page table address RT 2 = 0x0030000, page size RP 2 = 1 KB, and region size RS 2 = 256 KB are stored in the entry R 2 . In addition, the base virtual address RB 2 = 0x40000000, page table address RT 3 = 0x20040000, page size RP 3 = 1 KB, and region size RS 3 = 256 KB are stored in the entry R 3 .
 また、図8に示すMMU102は、図4に示した処理手順に従って初期化した直後の状態であることを想定している。したがって、TLB301内のすべてのエントリ0~nのエントリ有効フラグTV0~TVnには、エントリが無効であることを示すFalseが代入されている。 Further, it is assumed that the MMU 102 illustrated in FIG. 8 is in a state immediately after being initialized according to the processing procedure illustrated in FIG. Therefore, False indicating that the entry is invalid is substituted for the entry valid flags TV 0 to TV n of all entries 0 to n in the TLB 301.
 図9には、初期化直後のMMU102(図8を参照のこと)に対して変換前の仮想アドレスとしてVA=0x10020010が与えられた場合に、アドレス変換を行う具体例を示している。仮想アドレスから物理アドレスへの変換は、図6に示した処理手順に従って実行される。 FIG. 9 shows a specific example in which address conversion is performed when VA = 0x1002002010 is given as a virtual address before conversion to the MMU 102 immediately after initialization (see FIG. 8). The conversion from the virtual address to the physical address is executed according to the processing procedure shown in FIG.
 初期状態では、TLB301のすべてのエントリは無効なので(TV0~TVn=False)、要求された仮想アドレスに合致するエントリは存在しない。すなわちTLBミスするので、リージョンデスクリプタ302の中に、要求された仮想アドレスに合致するものがあるかが調べられる。ここでは、リージョンデスクリプタ302のエントリR0について、RB0≦VA<RB0+RS0を満たすので(0x10000000≦0x10020010<0x10000000+0x01000000)、この仮想アドレスはエントリR0と合致することになる。 In the initial state, since all entries of the TLB 301 are invalid (TV 0 to TV n = False), there is no entry that matches the requested virtual address. That is, since a TLB miss occurs, it is checked whether there is a region descriptor 302 that matches the requested virtual address. Here, the entry R 0 of the region descriptor 302 satisfies RB 0 ≦ VA <RB 0 + RS 0 (0x10000000 ≦ 0x10020010 <0x10000000 + 0x01000000), so this virtual address matches the entry R 0 .
 次いで、ページウォーク機構304は、図7に示した処理手順に従って、ページウォーク機構304がページウォークを実行する。 Next, the page walk mechanism 304 executes the page walk according to the processing procedure shown in FIG.
 ページウォーク機構304は、まず、リージョンデスクリプタ302のエントリR0から取得される情報に基づいて、物理メモリ305上のページテーブル参照処理を実行して、アクセス要求された仮想アドレスと物理アドレスをマッピングする新たなエントリをTLB301に作成する。具体的には、仮想アドレス0x10020010とベース仮想アドレスRB0(=0x10000000)の差分をそのリージョンのページサイズRP0=64KB(0x00010000)で割って、整数に切り捨てた値n=2(すなわち、n←int((VA-RBx)/RPx))が、物理メモリ305上の該当するページテーブルから取得すべきページとなる。 The page walk mechanism 304 first performs page table reference processing on the physical memory 305 based on information acquired from the entry R 0 of the region descriptor 302, and maps the virtual address and physical address requested to be accessed. A new entry is created in the TLB 301. Specifically, the difference between the virtual address 0x10020010 and the base virtual address RB 0 (= 0x10000000) is divided by the page size RP 0 = 64 KB (0x00010000) of the region, and rounded down to an integer n = 2 (ie, n ← int ((VA-RB x ) / RP x )) is the page to be acquired from the corresponding page table on the physical memory 305.
 したがって、ページウォーク機構304は、物理メモリ305上の該当するページテーブルアドレスRT0の2番目のエントリの値P02(=0x00080000)を、要求された仮想アドレスVAに対応するベース物理アドレスTT0として取得する。 Therefore, the page walk mechanism 304 sets the value P 02 (= 0x0800000) of the second entry of the corresponding page table address RT 0 on the physical memory 305 as the base physical address TT 0 corresponding to the requested virtual address VA. get.
 そして、ページウォーク機構304は、TLB301内に無効のエントリの中からエントリT0を選択して、以下のように新たなベース仮想アドレスTB0、ベース物理アドレスTT0、ページサイズTP0を設定して、当該エントリT0を有効化する。図10には、ページウォークによってエントリT0が設定される様子を示している。 Then, the page walk mechanism 304 selects the entry T 0 from the invalid entries in the TLB 301 and sets a new base virtual address TB 0 , base physical address TT 0 , and page size TP 0 as follows. Thus, the entry T 0 is validated. FIG. 10 shows a state where the entry T 0 is set by the page walk.
TB0(ベース仮想アドレス)←RB0+(RP0×n)=0x10000000+(0x00010000×2)=0x10020000
TT0(ベース物理アドレス)←P02=0x00080000
TP0(ページサイズ)←RP0=64KB
TV0(エントリ有効フラグ)←True
TB 0 (base virtual address) ← RB 0 + (RP 0 × n) = 0x10000000 + (0x00010000 × 2) = 0x10020000
TT 0 (Base physical address) ← P 02 = 0x0800000
TP 0 (Page size) ← RP 0 = 64KB
TV 0 (entry valid flag) ← True
 上記のようにページウォークによって、要求された仮想アドレスと物理アドレスをマッピングする新たなエントリがTLB301に作成されると、アドレス変換機構303による仮想アドレスから物理アドレスへの変換処理を改めて実行する。 When a new entry for mapping the requested virtual address and physical address is created in the TLB 301 by the page walk as described above, the conversion process from the virtual address to the physical address by the address translation mechanism 303 is executed again.
 図11には、要求された仮想アドレスVA(=0x10020010)に対して、仮想アドレスから物理アドレスへの変換処理を再実行する様子を示している。今度は、リージョンデスクリプタ302に加えて、TLB301内にも、要求された仮想アドレスに合致するエントリT0が見つかる(すなわち、TB0≦VA<TB0+TP0、且つ、TV0=True)。要求された仮想アドレスVAがTLB301及びリージョンデスクリプタ302の両方で合致する場合には、TLB301のエントリT0が優先される。何故ならば、TLBヒットした場合には、アドレス変換機構303はそのエントリを用いてベース仮想アドレスをベース物理アドレスに直接変換することができ、ページウォークのためのアドレス計算が不要だからである。 FIG. 11 shows a state where the virtual address to physical address conversion process is re-executed for the requested virtual address VA (= 0x1002002010). This time, in addition to the region descriptor 302, an entry T 0 matching the requested virtual address is found in the TLB 301 (ie, TB 0 ≦ VA <TB 0 + TP 0 and TV 0 = True). If the requested virtual address VA matches at both TLB301 and Region descriptor 302, entries T 0 of TLB301 takes precedence. This is because when the TLB hits, the address translation mechanism 303 can directly translate the base virtual address into the base physical address using the entry, and address calculation for page walk is not necessary.
 アドレス変換機構303は、図6に示した処理手順に従って、TLB301のエントリT0とから取得されるベース物理アドレスTT0と、要求された仮想アドレスVAから、物理アドレスPAを計算する(すなわち、PA←TT0+(VA-TB0))。この例では、0x00080000+(0x10020010-0x10020000)=0x00080010が、TLB301を用いたアドレス変換によって得られる物理アドレスPAである。 The address translation mechanism 303 calculates the physical address PA from the base physical address TT 0 acquired from the entry T 0 of the TLB 301 and the requested virtual address VA according to the processing procedure shown in FIG. ← TT 0 + (VA−TB 0 )). In this example, 0x0080000 + (0x10020010-0x10020000) = 0x00080010 is the physical address PA obtained by address translation using the TLB 301.
 要するに、本実施形態に係るMMU102は、仮想アドレスから物理アドレスへ変換するための情報を保持するTLB301の他に、アドレス変換の対象として定義された複数のリージョンの各々についてアドレス変換するための情報及びリージョン毎に定義されたページサイズの情報を保持するリージョンデスクリプタ302を備えている。ここまでの説明で、本実施形態に係るMMU102によれば、TLBミスした場合には、リージョン毎に異なるページサイズが定義されていても、リージョンデスクリプタ302を利用してページ単位で効率的にアドレス変換を行うことができる、という点を十分理解されたい。 In short, the MMU 102 according to the present embodiment includes, in addition to the TLB 301 that holds information for converting a virtual address to a physical address, information for address conversion for each of a plurality of regions defined as address conversion targets, and A region descriptor 302 that holds page size information defined for each region is provided. In the above description, according to the MMU 102 according to the present embodiment, in the case of a TLB miss, even if a different page size is defined for each region, the address is efficiently addressed in units of pages using the region descriptor 302. It should be fully understood that conversion can be performed.
 図12には、本実施形態に係るMMU102を用いて実現される、仮想アドレス空間におけるリージョンの構成例を示している。 FIG. 12 shows a configuration example of a region in the virtual address space realized by using the MMU 102 according to the present embodiment.
 図示の仮想アドレス空間には、Region#0~#3の4つのリージョンが定義されている。各リージョンは、それぞれ64KB、4KB、1KB、1KBのページサイズを持つ。Region#0はテキスト領域、Region#1とRegion#2はヒープ領域、Region#3はスタック領域として使われる。但し、Region#1とRegion#2は、確保するメモリブロックのサイズによって、これら2つのリージョンを使い分ける。 In the illustrated virtual address space, four regions of Region # 0 to # 3 are defined. Each region has a page size of 64 KB, 4 KB, 1 KB, and 1 KB, respectively. Region # 0 is used as a text area, Region # 1 and Region # 2 are used as a heap area, and Region # 3 is used as a stack area. However, Region # 1 and Region # 2 use these two regions properly depending on the size of the memory block to be secured.
 図13には、図1及び図2に示した組込み機器(センシングデバイス100)を実現するハードウェアで動作するソフトウェアの構成例を示している。 FIG. 13 shows a configuration example of software that operates on hardware that implements the embedded device (sensing device 100) shown in FIGS.
 センシングデバイス100は、例えば、スマートフォン、スマートウオッチ、スマートグラス、スマートヘッドフォンなど、ユーザが保持あるいは装着するような装置であってもよいし、電気自動車など移動交通手段に装備されてもよい。 The sensing device 100 may be a device that a user holds or wears, such as a smart phone, a smart watch, a smart glass, or a smart headphone, or may be equipped in a mobile transportation means such as an electric vehicle.
 センシングデバイス100のようなハードウェア上で動作するアプリケーションは、例えば、装着者の動きをセンシングするためのセンシング処理、センシング結果に基づいて装着者の行動を推定する行動推定処理、推定した結果をクラウド201経由でサーバ202に送信するための通信処理の3つに大別される。また、行動推定処理に使用される行動辞書がアプリケーションに含まれている。これらのアプリケーションは、図1又は図2に示した機器ハードウェアをサポートするとともに、図3に示したMMU102によって実現されるアドレス空間(図12を参照のこと)を各タスクに提供するOSの上で動作する。 An application that operates on hardware such as the sensing device 100 includes, for example, a sensing process for sensing a wearer's movement, a behavior estimation process that estimates a wearer's action based on the sensing result, and the estimated result in the cloud It is roughly divided into three communication processes for transmitting to the server 202 via 201. Moreover, the action dictionary used for the action estimation process is included in the application. These applications support the equipment hardware shown in FIG. 1 or FIG. 2, and are provided on the OS that provides the address space (see FIG. 12) realized by the MMU 102 shown in FIG. 3 to each task. Works with.
 センシングデバイス100は、センサ105からの入力に基づいてセンシング処理を行う。センサ105で認識可能なセンシングデバイス100の「動作/状況」を「行動」と関連付けて、「行動定義」として行動辞書に登録することで、行動推定処理において「行動」を認識し、認識された行動に基づいてデバイス自体の制御処理を行うとともに、必要に応じて推定した結果をクラウド201経由でサーバ202に送信するようにしてもよい。また、行動辞書は、センシング処理の結果や行動推定処理結果などを用いて、ディープニューラルネットワーク(Deep Neural Network)など人工知能の手法を利用して「動作/状況」と「行動」の関係を動的に学習するようになされていてもよい。動作の例としては、「ユーザの動作測定」などがある。状況の例としては、「加速度大」や「加速度小」などがある。例えば、動作「ユーザの動作測定」と状況「加速度大」に対して行動「ユーザが走っている」を関連付け、動作「ユーザの動作測定」と状況「加速度小」に対して行動「ユーザが歩行している」を関連付けて、行動辞書に定義することで、センサ105からの入力にしたがって行動認識処理を行うことにより、行動を認識することができる。 The sensing device 100 performs a sensing process based on the input from the sensor 105. The “behavior” of the sensing device 100 that can be recognized by the sensor 105 is associated with “behavior” and registered in the behavior dictionary as “behavior definition”, whereby “behavior” is recognized and recognized in the behavior estimation process. While performing the control process of the device itself based on the behavior, the estimated result may be transmitted to the server 202 via the cloud 201 as necessary. The behavior dictionary uses the results of sensing processing and behavior estimation processing, etc., to move the relationship between “action / situation” and “behavior” using artificial intelligence techniques such as deep neural network. You may be made to learn. Examples of the operation include “user operation measurement”. Examples of situations include “high acceleration” and “low acceleration”. For example, the action “user's running” is associated with the action “user's action measurement” and the situation “high acceleration”, and the action “user walks” with the action “user's action measurement” and the situation “low acceleration”. By performing the action recognition process in accordance with the input from the sensor 105, the action can be recognized.
 OSは、各タスクの動作を制御するタスク管理、フラッシュメモリ104上のファイルシステムを管理するフラッシュファイルマネージャ、MMU102を制御して仮想アドレス空間を構成する仮想メモリマネージャ、構成された仮想メモリに割り当てるための物理メモリの管理を行うメモリブロックマネージャ、などで構成される。また、OSには、接続されているセンサ105や通信モジュール106、フラッシュメモリ104などのデバイスを制御するデバイスドライバも含まれる。 The OS is task management that controls the operation of each task, a flash file manager that manages the file system on the flash memory 104, a virtual memory manager that controls the MMU 102 to configure a virtual address space, and a virtual memory that is allocated to the configured virtual memory A memory block manager for managing the physical memory. The OS also includes device drivers that control devices such as the connected sensor 105, communication module 106, and flash memory 104.
 このOSを用いたメモリ管理方法について、図14を参照しながら説明する。 A memory management method using this OS will be described with reference to FIG.
 仮想メモリマネージャは主に、MMU102に設定する各リージョンのページテーブルを管理する。仮想メモリマネージャは、あるリージョンのページに物理メモリを割り当てる場合には、その物理メモリを得るためにメモリブロックマネージャを呼び出す。また、仮想メモリマネージャは、あるリージョンのページにフラッシュメモリ104上のファイルを割り当てる場合には、フラッシュファイルマネージャを用いて、該当するファイルがフラッシュメモリ上のどのブロックに配置されているかの情報をファイルシステム内のファイルシステム管理データから取得し、そのブロックの存在する物理アドレスを配置したいリージョンのページテーブルに設定することで、対応する仮想アドレス上に該当ファイルのそのブロックが配置されるようになる。これらのメモリ管理を行うためのメモリ管理API(Application Programming Interface)は、OS自身又はOS上で動くアプリケーションから使用される。 The virtual memory manager mainly manages the page table of each region set in the MMU 102. When the virtual memory manager allocates physical memory to a page in a certain region, it calls the memory block manager to obtain the physical memory. Further, when the virtual memory manager allocates a file on the flash memory 104 to a page in a certain region, the flash file manager is used to store information on which block on the flash memory the corresponding file is located. The block of the corresponding file is placed on the corresponding virtual address by acquiring it from the file system management data in the system and setting the physical address where the block exists in the page table of the region to be placed. A memory management API (Application Programming Interface) for performing such memory management is used from the OS itself or an application running on the OS.
 OSは、起動すると自身の初期化が完了した後に、アプリケーション実行のための初期化を行う。アプリケーションはフラッシュメモリ104上にあらかじめファイルデータとして格納してあり、そのファイルをメモリ管理APIの呼び出しによって仮想アドレス空間に配置し、実行開始アドレスからの実行を行うタスクを生成することで、アプリケーションの実行が始まる。 When the OS starts up, it initializes itself for application execution after completing its initialization. The application is stored in advance as file data on the flash memory 104, the file is placed in a virtual address space by calling a memory management API, and a task for executing from the execution start address is generated, thereby executing the application. Begins.
 図15には、仮想メモリマネージャによって提供される仮想アドレス空間と、その上で実行される各タスクの関係を表している。仮想メモリマネージャは、各タスクが呼び出すメモリ管理APIによるメモリ確保並びにメモリ解放要求に従って、その要求に対応するリージョンに対して物理メモリ305、あるいはフラッシュメモリ104上のブロックを随時割り当てていく。 FIG. 15 shows the relationship between the virtual address space provided by the virtual memory manager and each task executed on the virtual address space. The virtual memory manager allocates a block on the physical memory 305 or the flash memory 104 as needed to a region corresponding to the request in accordance with a memory allocation and memory release request by a memory management API called by each task.
 図15に示す例では、センシングデバイス100上でアプリケーションの処理の実行に応じてOSが管理するセンシングタスク、行動推定タスク、及び通信タスクが動作していることを想定している。同時に動作する複数のタスク間で、仮想アドレス空間は共有される。 In the example shown in FIG. 15, it is assumed that the sensing task, behavior estimation task, and communication task managed by the OS according to the execution of the application process on the sensing device 100 are operating. The virtual address space is shared among a plurality of tasks operating simultaneously.
 フラッシュメモリ104に格納されているセンシング処理、行動推定処理、通信処理などの各アプリケーションの命令コードやプログラムの実行時に参照する読み込み専用のデータなどは、仮想アドレス空間のうち、テキスト領域として使用されるRegion#0にマップされる。また、行動推定処理に使用する行動推定辞書も、同じくRegion#0にマップされる。 The instruction code of each application such as sensing processing, behavior estimation processing, and communication processing stored in the flash memory 104 and read-only data to be referred to when executing the program are used as a text area in the virtual address space. Maps to Region # 0. The behavior estimation dictionary used for the behavior estimation process is also mapped to Region # 0.
 センシングデバイス100上で動作中のセンシングタスクは、Region#0にマップされるセンシング処理アプリケーションを利用する。また、センシングタスクは、プログラムの実行中に保持する必要のあるデータをヒープ領域として使用されるRegion#1に置き、実行中に当該領域内でメモリの確保と解放が動的に行われる。また、センシングタスクは、プログラムの実行中に呼び出される関数を、スタック領域として使用されるRegion#3に置く。 The sensing task operating on the sensing device 100 uses a sensing processing application mapped to Region # 0. In addition, the sensing task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically allocated and released in the area during execution. In addition, the sensing task places a function called during execution of the program in Region # 3 used as a stack area.
 同様に、センシングデバイス100上で動作中の行動推定タスクは、Region#0にマップされる行動推定処理アプリケーション並びに行動推定辞書を利用する。また、行動推定タスクは、プログラムの実行中に保持する必要のあるデータをヒープ領域として使用されるRegion#1に置き、実行中に当該領域内でメモリの確保と解放が動的に行われる。また、行動推定タスクは、プログラムの実行中に呼び出される関数を、スタック領域として使用されるRegion#3に置く。 Similarly, a behavior estimation task operating on the sensing device 100 uses a behavior estimation processing application and a behavior estimation dictionary mapped to Region # 0. In addition, the behavior estimation task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically secured and released in the area during execution. Further, the behavior estimation task places a function called during execution of the program in Region # 3 used as a stack area.
 同様に、センシングデバイス100上で動作中の通信タスクは、Region#0にマップされる通信処理アプリケーションを利用する。また、通信タスクは、プログラムの実行中に保持する必要のあるデータをヒープ領域として使用されるRegion#1に置き、実行中に当該領域内でメモリの確保と解放が動的に行われる。また、通信タスクは、プログラムの実行中に呼び出される関数を、スタック領域として使用されるRegion#3に置く。 Similarly, a communication task operating on the sensing device 100 uses a communication processing application mapped to Region # 0. Further, the communication task places data that needs to be held during execution of the program in Region # 1 used as a heap area, and memory is dynamically allocated and released in the area during execution. Further, the communication task places a function called during execution of the program in Region # 3 used as a stack area.
 図16には、仮想メモリマネージャによって提供されるリージョンのうち、Region#0をテキスト領域として使用するための仕組みを示している。 FIG. 16 shows a mechanism for using Region # 0 as a text area among the regions provided by the virtual memory manager.
 物理メモリ305上のRegion#0用のページテーブルには、テキスト領域に貼り付けるフラッシュメモリ104上の特定のファイルについて、そのファイルのフラッシュメモリ104上のブロックの物理アドレスが設定される。 In the page table for Region # 0 on the physical memory 305, for a specific file on the flash memory 104 to be pasted in the text area, the physical address of the block on the flash memory 104 of the file is set.
 フラッシュメモリ104上にファイルシステムが構成されている場合、ブロックはフラッシュメモリ104の中で必ずしも連続したブロックとして並べられているとは限らないが、そうした場合でもページテーブルによるアドレス変換によって、仮想アドレス空間のテキスト領域(Region#0)上では連続した仮想アドレスとしてファイルを貼り付けることができる。 When the file system is configured on the flash memory 104, the blocks are not necessarily arranged as continuous blocks in the flash memory 104. However, even in such a case, the virtual address space is obtained by address conversion using the page table. A file can be pasted as a continuous virtual address in the text area (Region # 0).
 また、このRegion#0におけるページサイズはフラッシュメモリ104のブロックサイズ(典型的には64KB)と合致させてある。したがって、例えばフラッシュメモリ104上で3ブロックを占めているファイル(192KB)については、ページテーブル上でも3つのエントリがあればこのファイルをテキスト領域にマッピングことができる。 In addition, the page size in Region # 0 is matched with the block size (typically 64 KB) of the flash memory 104. Therefore, for example, for a file (192 KB) that occupies three blocks on the flash memory 104, this file can be mapped to a text area if there are three entries on the page table.
 図17には、仮想メモリマネージャによって、フラッシュメモリ104内のファイルをメモリ空間(仮想アドレス空間のテキスト領域)へマッピングするための処理手順をフローチャートの形式で示している。 FIG. 17 shows a processing procedure for mapping the file in the flash memory 104 to the memory space (text area of the virtual address space) by the virtual memory manager in the form of a flowchart.
 仮想メモリマネージャは、まず、マッピング先のリージョン(Region#0)の空きアドレス空間の取得を試みる(ステップS1701)。 The virtual memory manager first tries to acquire a free address space of the mapping destination region (Region # 0) (step S1701).
 ここで、マッピング先のリージョンから空きアドレス空間を取得できなかった場合には(ステップS1702のNo)、アドレス空間不足エラーとして、ファイルのマッピングを諦め、本処理を終了する。 Here, if an empty address space cannot be obtained from the mapping destination region (No in step S1702), the file mapping is given up as an address space shortage error, and this processing is terminated.
 また、マッピング先のリージョンから空きアドレス空間を取得できた場合には(ステップS1702のYes)、仮想メモリマネージャは、当該リージョンにマップするファイルの、フラッシュメモリ104内の配置情報の取得を試みる(ステップS1703)。ステップS1703の処理は、図14中において参照番号1402で示す処理に相当する。 If a free address space can be acquired from the mapping destination region (Yes in step S1702), the virtual memory manager attempts to acquire arrangement information in the flash memory 104 of the file mapped to the region (step S1702). S1703). The processing in step S1703 corresponds to the processing indicated by reference numeral 1402 in FIG.
 ここで、当該リージョンにマップするファイルの配置情報を取得できない、すなわち、マッピングすべきファイルが存在しない場合には(ステップS1704のNo)、ファイル不存在エラーとして、ファイルのマッピングを諦め、本処理を終了する。 Here, if the placement information of the file to be mapped to the region cannot be obtained, that is, there is no file to be mapped (No in step S1704), the file mapping is given as a file nonexistence error, and this processing is performed. finish.
 また、当該リージョンにマップするファイルの配置情報を取得できたとき、すなわち、マッピングすべきファイルが存在する場合には(ステップS1704のYes)、仮想メモリマネージャは、物理メモリ305上における当該リージョンのページテーブルに、そのファイルのメモリ内配置情報を書き込んで(ステップS1705)、ファイルのマッピング処理を終了する。ステップS1705の処理は、図14中において参照番号1403で示す処理に相当する。 When the placement information of the file to be mapped to the region can be acquired, that is, when there is a file to be mapped (Yes in step S1704), the virtual memory manager displays the page of the region on the physical memory 305. The in-memory arrangement information of the file is written in the table (step S1705), and the file mapping process is terminated. The processing in step S1705 corresponds to the processing indicated by reference numeral 1403 in FIG.
 また、図18には、仮想メモリマネージャによって、メモリ空間(仮想アドレス空間のテキスト領域)へマッピングしたファイルを解放するための処理手順をフローチャートの形式で示している。 FIG. 18 shows a processing procedure for releasing a file mapped to the memory space (text area of the virtual address space) by the virtual memory manager in the form of a flowchart.
 仮想メモリマネージャは、解放を指定されたアドレスがファイルのマッピング先であるかどうかをチェックする(ステップS1801)。 The virtual memory manager checks whether the address designated to be released is a file mapping destination (step S1801).
 そして、解放を指定されたアドレスがファイルのマッピング先である場合には(ステップS1801のYes)、仮想メモリマネージャは、リージョンのページテーブルを未使用に戻して(ステップS1802)、本処理を終了する。ステップS1802の処理は、図14中において参照番号1403で示す処理に相当する。 If the address designated for release is the file mapping destination (Yes in step S1801), the virtual memory manager returns the page table of the region to unused (step S1802), and ends this processing. . The process in step S1802 corresponds to the process indicated by reference numeral 1403 in FIG.
 他方、解放を指定されたアドレスがファイルのマッピング先でない場合には(ステップS1801のNo)、アドレス指定エラーとして、マッピングの解放を諦めて、本処理を終了する。 On the other hand, if the address designated to be released is not the mapping destination of the file (No in step S1801), the mapping is released as an address designation error, and this processing is terminated.
 図19には、仮想メモリマネージャによって提供されるリージョンのうち、Region#1及びRegion#2をヒープ領域として使用するための仕組みを示している。 FIG. 19 shows a mechanism for using Region # 1 and Region # 2 among the regions provided by the virtual memory manager as heap areas.
 先述したように、ヒープ領域からどのような単位でメモリを確保するかは、処理内容やプログラムの書き方に大きく依存する。確保するメモリが数バイトのことも数100KBのこともある。こうしたサイズのメモリを混在させることによる断片化を防ぐため、本実施形態では、確保するメモリを4KB以上かそうでないかによって、ヒープアロケータが、Region♯1とRegion♯2の2つのリージョンを使い分けている。 As described above, the unit of memory allocation from the heap area largely depends on the processing contents and how to write the program. The memory to be secured may be several bytes or several hundred KB. In this embodiment, in order to prevent fragmentation due to mixing of memories of such sizes, in this embodiment, the heap allocator uses two regions, Region # 1 and Region # 2, depending on whether the memory to be secured is 4 KB or more. Yes.
 mallocは、動的にメモリを確保する関数であり、freeは、確保したメモリを動的に開放する関数である。図19に示す例では、ヒープアロケータが、確保するメモリサイズに応じて、使用するヒープ領域を選択する。 "Malloc" is a function that dynamically secures memory, and "free" is a function that dynamically releases the secured memory. In the example shown in FIG. 19, the heap allocator selects a heap area to be used according to the memory size to be secured.
 4KB未満の小さなメモリ確保要求に対しては、ヒープアロケータは、ページサイズを1KBに設定したRegion♯2に物理メモリを割り当てる。但し、ページサイズの1KBを超えるメモリ要求については、複数のページを割り当てて使用するようにする。また、4KB以上のメモリ確保要求に対しては、ヒープアロケータは、ページサイズを4KBに設定したRegion♯1に物理メモリを割り当てる。 For small memory allocation requests less than 4 KB, the heap allocator allocates physical memory to Region # 2 with the page size set to 1 KB. However, for a memory request exceeding the page size of 1 KB, a plurality of pages are allocated and used. In response to a memory allocation request of 4 KB or more, the heap allocator allocates physical memory to Region # 1 in which the page size is set to 4 KB.
 ヒープ領域に対するメモリ要求をいくつに分類するか、分類の際に閾値として設定するサイズは、アプリケーションのメモリ要求のパターンによって変わってくるが、少なくともこのように確保するサイズによる分類を行うことで、メモリの断片化を抑えることができるようになる。 The number of memory requests for the heap area to be classified and the size set as the threshold when classifying vary depending on the memory request pattern of the application, but at least by classifying according to the secured size, the memory It becomes possible to suppress fragmentation.
 図20には、ヒープ領域からメモリを確保するための処理手順をフローチャートの形式で示している。 FIG. 20 shows a processing procedure for securing memory from the heap area in the form of a flowchart.
 例えば、malloc関数を用いてメモリの動的確保が要求される。確保したいヒープ領域のメモリサイズが4KB以上の場合には(ステップS2001のYes)、ページサイズが4KBに定義されているRegion#1からメモリを確保する処理が実行される(ステップS2002)。Region#1からメモリを確保する処理の詳細については、後述に譲る。 For example, dynamic allocation of memory is required using a malloc function. When the memory size of the heap area to be secured is 4 KB or more (Yes in step S2001), the process of securing the memory is executed from Region # 1 where the page size is defined as 4 KB (step S2002). Details of the process of securing the memory from Region # 1 will be described later.
 一方、確保したいヒープ領域のメモリサイズが4KB未満の場合には(ステップS2001のNo)、ページサイズが1KBに定義されているRegion#2からメモリを確保する処理が実行される(ステップS2003)。Region#2からメモリを確保する処理の詳細については、後述に譲る。 On the other hand, if the memory size of the heap area to be secured is less than 4 KB (No in step S2001), a process of securing the memory is executed from Region # 2 where the page size is defined as 1 KB (step S2003). Details of the process of allocating memory from Region # 2 will be described later.
 また、図21には、ヒープ領域に確保したメモリを解放するための処理手順をフローチャートの形式で示している。 FIG. 21 shows a processing procedure for releasing the memory secured in the heap area in the form of a flowchart.
 例えば、free関数を用いてメモリの動的解放が要求される。解放要求されたメモリのアドレスが、ページサイズが4KBに定義されているRegion#1である場合には(ステップS2101のYes)、Region#1(若しくは、ページサイズが4KBの領域)のメモリを解放する処理が実行される(ステップS2102)。Region#1に確保されたメモリを解放する処理の詳細については、後述に譲る。 For example, dynamic release of memory is requested using the free function. If the address of the memory requested to be released is Region # 1 defined with a page size of 4 KB (Yes in step S2101), the memory of Region # 1 (or an area with a page size of 4 KB) is released. The process is executed (step S2102). Details of the processing for releasing the memory secured in Region # 1 will be described later.
 一方、解放要求されたメモリのアドレスがRegion#1でない場合には(ステップS2101のNo)、Region#2(若しくは、ページサイズが1KBの領域)のメモリを解放する処理が実行される(ステップS2103)。Region#2に確保されたメモリを解放する処理の詳細については、後述に譲る。 On the other hand, when the memory address requested to be released is not Region # 1 (No in step S2101), processing for releasing the memory in Region # 2 (or an area having a page size of 1 KB) is executed (step S2103). ). Details of the processing for releasing the memory secured in Region # 2 will be described later.
 図22には、図20に示したフローチャートのステップS2002で実行される、ページサイズが4KBに定義されているRegion#1からメモリを確保するための処理手順をフローチャートの形式で示している。 FIG. 22 shows, in the form of a flowchart, a processing procedure for securing a memory from Region # 1 defined with a page size of 4 KB, which is executed in step S2002 of the flowchart shown in FIG.
 まず、仮想メモリマネージャは、Region#1内で指定されたサイズの空きアドレス空間の取得を試みる(ステップS2201)。 First, the virtual memory manager tries to acquire a free address space having a size specified in Region # 1 (step S2201).
 ここで、Region#1内で指定されたサイズの空きアドレス空間を取得できなかった場合には(ステップS2202のNo)、アドレス空間不足エラーとして、ファイルのマッピングを諦め、本処理を終了する。 Here, when an empty address space having the size specified in Region # 1 cannot be acquired (No in step S2202), the file mapping is given up as an address space shortage error, and this processing is terminated.
 また、Region#1内で指定されたサイズの空きアドレス空間を取得できた場合には(ステップS2202のYes)、仮想メモリマネージャは、メモリブロックマネージャから、空きメモリブロックを取得する(ステップS2203)。メモリマネージャから空きメモリブロックを取得する処理の詳細については、後述に譲る。 If a free address space having a size specified in Region # 1 can be acquired (Yes in step S2202), the virtual memory manager acquires a free memory block from the memory block manager (step S2203). Details of the process of acquiring an empty memory block from the memory manager will be described later.
 そして、メモリブロックマネージャから空きメモリブロックを取得することができた場合には(ステップS2204のYes)、仮想メモリマネージャは、物理メモリ305上における当該リージョンのページテーブルに、ステップS2201で取得したメモリブロックのアドレスを書き込んで(ステップS2205)、本処理を終了する。ステップS2205の処理は、図14中において参照番号1403で示す処理に相当する。 If a free memory block can be acquired from the memory block manager (Yes in step S2204), the virtual memory manager stores the memory block acquired in step S2201 in the page table of the region on the physical memory 305. Is written (step S2205), and this process is terminated. The process in step S2205 corresponds to the process indicated by reference numeral 1403 in FIG.
 また、メモリブロックマネージャから空きメモリブロックを取得することができなかった場合には(ステップS2204のNo)、メモリ不足エラーとしてメモリの確保を諦め、本処理を終了する。 If a free memory block cannot be obtained from the memory block manager (No in step S2204), the memory is given up as a memory shortage error, and this process is terminated.
 図23には、図21に示したフローチャートのステップS2102で実行される、ページサイズが4KBに定義されているRegion#1に確保したメモリを解放するための処理手順をフローチャートの形式で示している。 FIG. 23 shows, in the form of a flowchart, the processing procedure for releasing the memory secured in Region # 1 defined in the page size of 4 KB, which is executed in step S2102 of the flowchart shown in FIG. .
 仮想メモリマネージャは、解放を指定されたアドレスがRegion#1に該当するかどうかをチェックする(ステップS2301)。 The virtual memory manager checks whether or not the address designated to be released corresponds to Region # 1 (step S2301).
 解放を指定されたアドレスがRegion#1に該当する場合には(ステップS2301のYes)、仮想メモリマネージャは、メモリブロックマネージャへメモリブロックを返すための処理を実行する(ステップS2302)。メモリブロックマネージャへメモリブロックを返す処理の詳細については、後述に譲る。 When the address designated to be released corresponds to Region # 1 (Yes in step S2301), the virtual memory manager executes processing for returning the memory block to the memory block manager (step S2302). Details of the process of returning the memory block to the memory block manager will be described later.
 そして、仮想メモリマネージャは、リージョンのページテーブルを未使用に戻して(ステップS2303)、本処理を終了する。ステップS2303の処理は、図14中において参照番号1403で示す処理に相当する。 Then, the virtual memory manager returns the page table of the region to unused (step S2303) and ends this process. The process of step S2303 corresponds to the process indicated by reference numeral 1403 in FIG.
 他方、解放を指定されたアドレスがRegion#1でない場合には(ステップS2301のNo)、アドレス指定エラーとして、メモリの解放を諦めて、本処理を終了する。 On the other hand, if the address designated to be released is not Region # 1 (No in step S2301), the memory release is given up as an address designation error, and this processing is terminated.
 図24には、図20に示したフローチャートのステップS2003で実行される、ページサイズが1KBに定義されているRegion#2からメモリを確保するための処理手順をフローチャートの形式で示している。 FIG. 24 shows, in the form of a flowchart, a processing procedure for securing a memory from Region # 2 in which the page size is defined as 1 KB, which is executed in step S2003 of the flowchart shown in FIG.
 まず、仮想メモリマネージャは、Region#2内で指定されたサイズの空きアドレス空間の取得を試みる(ステップS2401)。 First, the virtual memory manager tries to acquire a free address space having a size specified in Region # 2 (step S2401).
 ここで、Region#2内で指定されたサイズの空きアドレス空間を取得できなかった場合には(ステップS2402のNo)、アドレス空間不足エラーとして、ファイルのマッピングを諦め、本処理を終了する。 Here, when an empty address space having the size specified in Region # 2 cannot be acquired (No in step S2402), the file mapping is abandoned as an address space shortage error, and this processing is terminated.
 また、Region#2内で指定されたサイズの空きアドレス空間を取得できた場合には(ステップS2402のYes)、仮想メモリマネージャは、メモリブロックマネージャから、空きメモリブロックを取得する(ステップS2403)。メモリマネージャから空きメモリブロックを取得する処理の詳細については、後述に譲る。 If a free address space having a size specified in Region # 2 can be acquired (Yes in step S2402), the virtual memory manager acquires a free memory block from the memory block manager (step S2403). Details of the process of acquiring an empty memory block from the memory manager will be described later.
 そして、メモリブロックマネージャから空きメモリブロックを取得することができた場合には(ステップS2404のYes)、仮想メモリマネージャは、物理メモリ305上における当該リージョンのページテーブルに、ステップS2401で取得したメモリブロックのアドレスを書き込んで(ステップS2405)、本処理を終了する。ステップS2405の処理は、図14中において参照番号1403で示す処理に相当する。 If an empty memory block can be acquired from the memory block manager (Yes in step S2404), the virtual memory manager stores the memory block acquired in step S2401 in the page table of the region on the physical memory 305. Is written (step S2405), and the process is terminated. The processing in step S2405 corresponds to the processing indicated by reference numeral 1403 in FIG.
 また、メモリブロックマネージャから空きメモリブロックを取得することができなかった場合には(ステップS2404のNo)、メモリ不足エラーとしてメモリの確保を諦め、本処理を終了する。 If a free memory block cannot be obtained from the memory block manager (No in step S2404), the memory is given up as a memory shortage error, and this process is terminated.
 図25には、図21に示したフローチャートのステップS2103で実行される、ページサイズが1KBに定義されているRegion#2に確保したメモリを解放するための処理手順をフローチャートの形式で示している。 FIG. 25 shows, in the form of a flowchart, the processing procedure for releasing the memory secured in Region # 2 defined with the page size of 1 KB, which is executed in step S2103 of the flowchart shown in FIG. .
 仮想メモリマネージャは、解放を指定されたアドレスがRegion#2に該当するかどうかをチェックする(ステップS2501)。 The virtual memory manager checks whether the address designated to be released corresponds to Region # 2 (step S2501).
 解放を指定されたアドレスがRegion#2に該当する場合には(ステップS2501のYes)、仮想メモリマネージャは、メモリブロックマネージャへメモリブロックを返すための処理を実行する(ステップS2502)。メモリブロックマネージャへメモリブロックを返す処理の詳細については、後述に譲る。 If the address designated to be released corresponds to Region # 2 (Yes in step S2501), the virtual memory manager executes a process for returning the memory block to the memory block manager (step S2502). Details of the process of returning the memory block to the memory block manager will be described later.
 そして、仮想メモリマネージャは、リージョンのページテーブルを未使用に戻して(ステップS2503)、本処理を終了する。ステップS2303の処理は、図14中において参照番号1403で示す処理に相当する。 Then, the virtual memory manager returns the page table of the region to unused (step S2503), and ends this process. The process of step S2303 corresponds to the process indicated by reference numeral 1403 in FIG.
 他方、解放を指定されたアドレスがRegion#2でない場合には(ステップS2501のNo)、アドレス指定エラーとして、メモリの解放を諦めて、本処理を終了する。 On the other hand, if the address designated to be released is not Region # 2 (No in step S2501), the memory is given up as an address designation error, and this processing is terminated.
 図26には、図22に示したフローチャートのステップS2203、並びに図24に示したフローチャートのステップS2403で実行される、メモリブロックマネージャから空きメモリブロックを取得するための処理手順をフローチャートの形式で示している。 FIG. 26 shows a processing procedure for acquiring an empty memory block from the memory block manager executed in step S2203 of the flowchart shown in FIG. 22 and step S2403 of the flowchart shown in FIG. 24 in the form of a flowchart. ing.
 メモリブロックマネージャは、物理メモリブロックに空きがあるかどうかをチェックする(ステップS2601)。 The memory block manager checks whether there is a free physical memory block (step S2601).
 そして、物理メモリブロックに空きがある場合には(ステップS2601のYes)、メモリブロックマネージャは、空きメモリブロックの状態を使用済みに変更して(ステップS2602)、本処理を終了する。 If there is a free physical memory block (Yes in step S2601), the memory block manager changes the state of the free memory block to used (step S2602), and ends this process.
 他方、物理メモリブロックに空きがない場合には(ステップS2601のNo)、メモリ不足エラーとして、空きメモリブロックの取得を諦め、本処理を終了する。 On the other hand, if there is no free space in the physical memory block (No in step S2601), it gives up the acquisition of the free memory block as a memory shortage error, and ends this processing.
 図27には、図23に示したフローチャートのステップS2302、並びに図25に示したフローチャートのステップS2503で実行される、メモリブロックマネージャへメモリブロックを返すための処理手順をフローチャートの形式で示している。 FIG. 27 shows a processing procedure for returning a memory block to the memory block manager executed in step S2302 of the flowchart shown in FIG. 23 and step S2503 of the flowchart shown in FIG. 25 in the form of a flowchart. .
 メモリブロックマネージャは、仮想メモリマネージャから返されたメモリブロックの状態を空きに変更して(ステップS2701)、本処理を終了する。 The memory block manager changes the state of the memory block returned from the virtual memory manager to empty (step S2701), and ends this process.
 図28には、仮想メモリマネージャによって提供されるリージョンのうち、Region#3をスタック領域として使用するための仕組みを示している。 FIG. 28 shows a mechanism for using Region # 3 as a stack area among the regions provided by the virtual memory manager.
 スタック領域は、プログラムを実現する各タスクについてそれぞれ1つずつ存在する。スタック領域は、プログラムの実行における関数呼び出しの進行などにより、動的に使用量が増えていく領域である。本実施形態では、システムで動作するタスクの平均的なスタック消費量が小さい場合を考慮して、スタック領域として使用されるRegion#3のページサイズを1KBとする。 There is one stack area for each task that implements the program. The stack area is an area in which the usage amount increases dynamically due to the progress of function calls during program execution. In this embodiment, considering the case where the average stack consumption of tasks operating in the system is small, the page size of Region # 3 used as the stack area is set to 1 KB.
 タスクを初期化する際には、まず1ページ分の物理メモリがそのタスクのスタック領域として仮想アドレス空間に割り当てられ、タスクの動作中にそのページを使い切ると動的に1ページずつ追加の物理メモリが仮想アドレス空間に割り当てられていく。 When initializing a task, the physical memory for one page is first allocated to the virtual address space as the stack area of the task. When the page is used up during the operation of the task, the physical memory is dynamically added one page at a time. Are allocated to the virtual address space.
 タスクのスタック消費が進んで割り当てられた物理メモリを使い尽くすと、まだメモリが割り当てられていない仮想アドレスへのアクセスが発生するため、そのタスクがバスフォルトを起こす。OSは、そのバスフォルトのハンドラ内で、メモリブロックマネージャから確保した物理メモリをバスフォルトの起きた仮想アドレスに割り当てることによって、動的にスタック領域の伸長を実現している。 If the allocated physical memory is exhausted due to the progress of stack consumption of a task, access to a virtual address to which no memory has been allocated occurs, so that the task causes a bus fault. The OS dynamically extends the stack area by allocating the physical memory secured from the memory block manager to the virtual address where the bus fault has occurred in the handler of the bus fault.
 図29には、タスクのバスフォルト処理として、スタック領域を動的に割り当てるための処理手順をフローチャートの形式で示している。 FIG. 29 shows a processing procedure for dynamically allocating a stack area as a task bus fault process in the form of a flowchart.
 タスクのバスフォルトが発生すると、バスフォルトハンドラは、そのフォルト発生アドレスが、スタック領域として使用しているRegion#3かどうかをチェックする(ステップS2901)。 When a task bus fault occurs, the bus fault handler checks whether the fault occurrence address is Region # 3 used as a stack area (step S2901).
 フォルト発生アドレスがRegion#3でない場合には(ステップS2901のNo)、バスエラーによりタスクを停止して、本処理を終了する。 If the fault occurrence address is not Region # 3 (No in step S2901), the task is stopped due to a bus error, and this process is terminated.
 また、フォルト発生アドレスがRegion#3である場合には(ステップS2901のYes)、バスフォルトハンドラは、メモリブロックマネージャから、空きメモリブロックを取得する(ステップS2902)。メモリマネージャから空きメモリブロックを取得する処理は、図26に示した処理手順(前述)に従って実行される。 If the fault occurrence address is Region # 3 (Yes in step S2901), the bus fault handler acquires an empty memory block from the memory block manager (step S2902). The process of acquiring an empty memory block from the memory manager is executed according to the processing procedure (described above) shown in FIG.
 そして、メモリブロックマネージャから空きメモリブロックを取得することができた場合には(ステップS2903のYes)、バスフォルトハンドラは、物理メモリ305上における当該リージョンのページテーブルに、ステップS2902で取得したメモリブロックのアドレスを書き込んで(ステップS2904)、バスフォルトハンドラによる本処理を終了する。ステップS2904の処理は、図14中において参照番号1403で示す処理に相当する。 If a free memory block can be acquired from the memory block manager (Yes in step S2903), the bus fault handler stores the memory block acquired in step S2902 in the page table of the region on the physical memory 305. Is written (step S2904), and the processing by the bus fault handler is terminated. The processing in step S2904 corresponds to the processing indicated by reference numeral 1403 in FIG.
 また、メモリブロックマネージャから空きメモリブロックを取得することができなかった場合には(ステップS2903のNo)、メモリ不足エラーとしてメモリの確保を諦め、本処理を終了する。 If a free memory block cannot be obtained from the memory block manager (No in step S2903), the memory is given up as a memory shortage error, and this processing is terminated.
 また、タスクが終了すると、それまでに割り当てられたスタックを解放する処理を実施する。 Also, when the task is finished, a process to release the stack allocated so far is executed.
 図30には、タスク終了時にスタックを解放するための処理手順をフローチャートの形式で示している。 FIG. 30 shows a processing procedure for releasing the stack at the end of the task in the form of a flowchart.
 タスクの終了時に、仮想メモリマネージャは、メモリブロックマネージャへメモリブロックを返すための処理を実行する(ステップS3001)。メモリブロックマネージャへメモリブロックを返す処理は、図27に示した処理手順(前述)に従って実行される。 At the end of the task, the virtual memory manager executes a process for returning the memory block to the memory block manager (step S3001). The process of returning the memory block to the memory block manager is executed according to the processing procedure (described above) shown in FIG.
 そして、仮想メモリマネージャは、リージョンのページテーブルを未使用に戻して(ステップS3002)、本処理を終了する。ステップS3002の処理は、図14中において参照番号1403で示す処理に相当する。 Then, the virtual memory manager returns the page table of the region to unused (step S3002), and ends this process. The process in step S3002 corresponds to the process indicated by reference numeral 1403 in FIG.
 なお、本実施形態における各リージョンのページサイズの設定(テキスト領域:64KB、ヒープ領域:4KB又は1KB、スタック領域:1KB)は、一例に過ぎない。実行するアプリケーションタスクの規模や性質、機器(センシングデバイス100)が搭載するメモリ容量などの条件に応じて、各リージョンにおける適切なページサイズは変わってくる。重要な点は、テキスト、ヒープ、スタックの各領域に対する要求は異なっており、本明細書で開示する技術によれば、かかる要求に対して少ないメモリで適切なページサイズを用いることができることである。 The setting of the page size of each region (text area: 64 KB, heap area: 4 KB or 1 KB, stack area: 1 KB) in the present embodiment is merely an example. The appropriate page size in each region varies depending on conditions such as the scale and nature of the application task to be executed and the memory capacity installed in the device (sensing device 100). The important point is that the requirements for the text, heap, and stack areas are different, and according to the technique disclosed herein, an appropriate page size can be used with less memory for such requests. .
 本実施形態では、センシングデバイス100上でセンシングタスク、行動推定タスク、及び通信タスクが動作していることを想定している(例えば、図15を参照のこと)。また、本実施形態では、これらのタスクが以下のような性質とメモリへの要求を持っていることを想定している。 In the present embodiment, it is assumed that a sensing task, a behavior estimation task, and a communication task are operating on the sensing device 100 (see, for example, FIG. 15). In this embodiment, it is assumed that these tasks have the following properties and memory requirements.
(1)センシングタスク
 センシングタスクは、定期的に一定の周期で各種センサ105から情報を取得して、行動推定タスクにセンサ値を渡す。センシングタスクの命令コードは、フラッシュメモリ104の1ブロック(64KB)に収まる程度であり、ヒープ領域からは1KB程度のメモリ領域数個を使用する。スタック領域の消費量は1KB程度である。
(1) Sensing task The sensing task periodically acquires information from the various sensors 105 at a constant cycle, and passes the sensor value to the behavior estimation task. The instruction code of the sensing task is only about one block (64 KB) of the flash memory 104, and several memory areas of about 1 KB are used from the heap area. The consumption of the stack area is about 1 KB.
(2)行動推定タスク
 行動推定タスクは、センシングタスクから渡されたセンサ値と、フラッシュメモリ104上の行動推定辞書を用い定期的に行動推定を行うアルゴリズムを実行し、推定した結果を通信タスクに渡す。行動推定タスクの命令コード、並びに行動推定辞書はそれぞれフラッシュメモリの1ブロック(64KB)に収まる程度であり、ヒープ領域からは16KB程度のメモリ領域と、1KB程度のメモリ領域数個を使用する。スタック領域の消費量は4KB程度である。
(2) Behavior estimation task The behavior estimation task executes an algorithm that periodically performs behavior estimation using the sensor value passed from the sensing task and the behavior estimation dictionary on the flash memory 104, and uses the estimated result as a communication task. hand over. The instruction code of the action estimation task and the action estimation dictionary are only enough to fit in one block (64 KB) of the flash memory, and the memory area of about 16 KB and several memory areas of about 1 KB are used from the heap area. The consumption of the stack area is about 4 KB.
(3)通信タスク
 通信タスクは、行動推定タスクの推定結果をクラウド202上のサーバ202に送信する。行動推定タスクからは定期的に送信データを受け取るが、サーバ202との通信中の接続遮断やその後の再試行など、不定期にエラー処理などの例外処理が必要となる場合がある。通信タスクの命令コードはフラッシュメモリ104上の256KB程度(4ブロック)であり、ヒープ領域からは4KB程度のメモリ領域数個と、1KB程度のメモリ領域を10数個使用する。スタック領域の消費量は、通常状態では2KB程度だが、例外処理などで4KB程度に増加する場合がある。
(3) Communication task The communication task transmits the estimation result of the behavior estimation task to the server 202 on the cloud 202. Although the transmission data is periodically received from the behavior estimation task, exception processing such as error processing may be required irregularly such as connection disconnection during communication with the server 202 or subsequent retry. The instruction code of the communication task is about 256 KB (4 blocks) on the flash memory 104. From the heap area, several memory areas of about 4 KB and ten memory areas of about 1 KB are used. The consumption amount of the stack area is about 2 KB in the normal state, but may increase to about 4 KB by exception processing or the like.
 上記のような前提において、本明細書で開示する技術によれば、仮想アドレス空間で各リージョンを以下のように実現することができる。 Based on the premise as described above, according to the technique disclosed in this specification, each region can be realized in the virtual address space as follows.
(1)テキスト領域
 テキスト領域を提供するRegion♯0は、フラッシュメモリ104のブロックサイズである64KBをページサイズとする。各タスクの必要ページ数はそれぞれ1ページ、2ページ、4ページであり、合計7ページ分のページテーブルがあれば、全タスクのテキスト領域を提供することができる。
(1) Text Area Region # 0 that provides a text area has a page size of 64 KB, which is the block size of the flash memory 104. The number of pages required for each task is 1 page, 2 pages, and 4 pages, respectively. If there is a page table for a total of 7 pages, the text area for all tasks can be provided.
(2)ヒープ領域
 ヒープ領域を提供するRegion♯1及びRegion♯2は、前述した通り、各種のメモリ確保要求に応じるために、4KBページと1KBページの2つのページサイズを使用する。上述した実施形態ではメモリ要求は1KB程度のものと4KBを超えるものの2種類に大別できるため、それぞれでリージョンを使い分けることでメモリ断片化の防止に効果がある。
(2) Heap area Region # 1 and Region # 2 providing the heap area use two page sizes of 4 KB page and 1 KB page in order to satisfy various memory securing requests as described above. In the embodiment described above, memory requests can be broadly classified into two types, those having a size of about 1 KB and those exceeding 4 KB. Therefore, it is effective in preventing memory fragmentation by using different regions.
(3)スタック領域
 スタック領域を提供するRegion♯3は、タスクの中で必要とするスタック消費量の最低値である1KBをページサイズとして使用する。各タスクはそれぞれ最大1ページ、4ページ、4ページ分の物理メモリをスタックとして割り当てることになる。例えば、ページサイズを4KBに指定した際はセンシングタスクの場合、1KBしか使われないために3KB分が無駄になるが、そうした無駄を抑えることができる。
(3) Stack area Region # 3 providing the stack area uses 1 KB, which is the minimum value of the stack consumption required in the task, as the page size. Each task allocates a maximum of one page, four pages, and four pages of physical memory as a stack. For example, when the page size is specified as 4 KB, only 1 KB is used for the sensing task, and 3 KB is wasted. However, such waste can be suppressed.
 このように用途に応じた適切なページサイズを使用することは、メモリの無駄やページテーブルのサイズを抑えることにつながる。それに加えて、MMU102においてアドレス変換に必要とするTLBのエントリ数を抑えることにもなる。MMU102によるアドレス変換には、最終的には変換元の仮想アドレス(ベース仮想アドレスTB)と変換先の物理アドレス(ベース物理アドレスTT)がTLB301に載ることが必要になる。ところが、TLB301のエントリ数には限りがあり、TLB301でのベース仮想アドレス比較が合致しなかった場合(すなわち、TLBミスした場合)には、リージョンデスクリプタ302を用いたページウォーク処理という追加の処理が必要になる(TLB301を用いたアドレス変換や、TLBミス時のリージョンデスクリプタ302を用いたページウォーク処理については、図3~図7を参照しながら、既に説明した通りである)。ページテーブルのサイズを抑えることは、こうしたページウォーク処理の頻度を下げることにもつながる。 Using an appropriate page size according to the application in this way leads to reducing memory waste and page table size. In addition, the number of TLB entries required for address translation in the MMU 102 is also suppressed. In the address translation by the MMU 102, it is finally necessary that the translation source virtual address (base virtual address TB) and the translation destination physical address (base physical address TT) are placed in the TLB 301. However, the number of entries in the TLB 301 is limited, and when the base virtual address comparison in the TLB 301 does not match (that is, when a TLB miss occurs), an additional process called page walk processing using the region descriptor 302 is performed. (Address translation using the TLB 301 and page walk processing using the region descriptor 302 at the time of a TLB miss are as already described with reference to FIGS. 3 to 7). Reducing the size of the page table also reduces the frequency of such page walk processing.
 以上、特定の実施形態を参照しながら、本明細書で開示する技術について詳細に説明してきた。しかしながら、本明細書で開示する技術の要旨を逸脱しない範囲で当業者が該実施形態の修正や代用を成し得ることは自明である。 As described above, the technology disclosed in this specification has been described in detail with reference to specific embodiments. However, it is obvious that those skilled in the art can make modifications and substitutions of the embodiments without departing from the scope of the technology disclosed in this specification.
 本明細書で開示するメモリ管理技術は、例えば小容量のメモリしか持たない組み込み機器に適用して、アドレス変換の対象となる複数のリージョンを定義するとともに、リージョン毎のページサイズを定義することによって、無駄なメモリ消費を抑制して、ページ単位で効率的にアドレス変換を行うことができる。勿論、本明細書で開示するメモリ管理技術を、通常又は大容量のメモリを装備する情報処理装置にも同様に適用することができる。 The memory management technology disclosed in this specification is applied to, for example, an embedded device having only a small amount of memory, and defines a plurality of regions to be subjected to address conversion, and also defines a page size for each region. Thus, it is possible to suppress unnecessary memory consumption and to efficiently perform address conversion in units of pages. Of course, the memory management technique disclosed in this specification can be similarly applied to an information processing apparatus equipped with a normal or large-capacity memory.
 要するに、例示という形態により本明細書で開示する技術について説明してきたのであり、本明細書の記載内容を限定的に解釈するべきではない。本明細書で開示する技術の要旨を判断するためには、特許請求の範囲を参酌すべきである。 In short, the technology disclosed in the present specification has been described in the form of examples, and the description content of the present specification should not be interpreted in a limited manner. In order to determine the gist of the technology disclosed in this specification, the claims should be taken into consideration.
 なお、本明細書の開示の技術は、以下のような構成をとることも可能である。
(1)ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理装置であって、
 前記仮想アドレス空間に定義されたリージョンのアドレス変換情報と、リージョンが持つ固有のページサイズを保持するリージョン情報保持部と、
 仮想アドレスを含むリージョンの前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索部と、
を具備するメモリ管理装置。
(2)前記リージョン情報保持部は、仮想アドレス空間上に定義された各リージョンのベース仮想アドレスと、物理メモリ上に置かれたリージョン毎のページテーブルのアドレスと、リージョンに定義されたページサイズ、及びリージョンサイズに関する情報をリージョン毎のエントリに保持し、
 前記探索部は、仮想アドレスを含むリージョンに対応するページテーブルアドレスに基づいて、前記物理メモリ上の該当するページテーブルから仮想アドレスに対応する物理アドレスの情報を探索する、
上記(1)に記載のメモリ管理装置。
(3)前記探索部は、
 前記リージョン情報保持部内の、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリから、仮想アドレスを含むリージョンのページテーブルアドレスを特定して、
 そのページテーブルアドレスで指定されるページテーブル上の、仮想アドレスとベース仮想アドレスの差分をページサイズで割算して特定されるページから物理アドレス情報を取得する、
上記(2)に記載のメモリ管理装置。
(4)ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファと、
 前記アドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換部と、
をさらに備える上記(1)乃至(3)のいずれかに記載のメモリ管理装置。
(5)前記アドレス変換部は、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリを、前記アドレス変換バッファ内で検索する、
上記(4)に記載のメモリ管理装置。
(6)用途が異なるデータを格納する複数のメモリ領域に対して、仮想アドレス空間上で異なるリージョンを割り当てる、
上記(1)乃至(5)のいずれかに記載のメモリ管理装置。
(7)テキスト領域、ヒープ領域、及びスタック領域に対して、仮想アドレス空間上で異なるリージョンを割り当てる、
上記(1)乃至(6)のいずれかに記載のメモリ管理装置。
(8)テキスト領域に対して、所定のブロックサイズに基づいてページサイズが定義されたリージョンを割り当てる、
上記(1)乃至(7)のいずれかに記載のメモリ管理装置。
(9)ヒープ領域に対して、ページサイズが異なる2以上のリージョンを割り当てる、
上記(1)乃至(8)のいずれかに記載のメモリ管理装置。
(10)ヒープ領域からメモリ領域を確保する際に、確保したいメモリサイズを超えないページサイズが定義されたリージョンを割り当てる、
上記(9)に記載のメモリ管理装置。
(11)スタック領域に割り当てられたリージョンでバスフォルトが発生したことに応答して、ページサイズ単位で物理メモリを割り当てる、
上記(1)乃至(10)のいずれかに記載のメモリ管理装置。
(12)ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理方法であって、
 前記仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部に保持された前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索ステップと、
 ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換ステップと、
を有するメモリ管理方法。
(13)物理メモリと、
 仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部と、仮想アドレスを含むリージョンの前記アドレス変換情報を用いて仮想アドレスに対応する物理アドレスの情報を探索する探索部を備えて、ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理ユニットと、
を具備する情報処理装置。
Note that the technology disclosed in the present specification can also be configured as follows.
(1) A memory management device that performs address conversion from a virtual address to a physical address in page units,
Region address translation information defined in the virtual address space, a region information holding unit for holding a unique page size of the region,
A search unit that searches for information of a physical address corresponding to the virtual address using the address conversion information of the region including the virtual address;
A memory management device comprising:
(2) The region information holding unit includes a base virtual address of each region defined on the virtual address space, a page table address for each region placed on the physical memory, a page size defined for the region, And information about the region size in the entry for each region,
The search unit searches for information on the physical address corresponding to the virtual address from the corresponding page table on the physical memory based on the page table address corresponding to the region including the virtual address.
The memory management device according to (1) above.
(3) The search unit
From the entry containing the virtual address in the base virtual address and the address range obtained by adding the page size of the region to the base virtual address in the region information holding unit, specify the page table address of the region including the virtual address,
The physical address information is obtained from the page specified by dividing the difference between the virtual address and the base virtual address by the page size on the page table specified by the page table address.
The memory management device according to (2) above.
(4) Information indicating a correspondence relationship between the base virtual address and the base physical address in page units, and an address translation buffer that holds information on the page size defined in the region including the virtual address;
An address translation unit that combines a base physical address and a virtual address obtained from an entry that hits a virtual address in the address translation buffer, and translates the physical address corresponding to the virtual address;
The memory management device according to any one of (1) to (3), further including:
(5) The address translation unit searches the address translation buffer for an entry including a virtual address in a base virtual address and an address range obtained by adding the page size of the region to the base virtual address.
The memory management device according to (4) above.
(6) Assign different regions in the virtual address space to a plurality of memory areas storing data having different uses.
The memory management device according to any one of (1) to (5) above.
(7) Assign different regions in the virtual address space to the text area, heap area, and stack area.
The memory management device according to any one of (1) to (6) above.
(8) Assign a region in which the page size is defined based on a predetermined block size to the text area.
The memory management device according to any one of (1) to (7).
(9) Allocate two or more regions with different page sizes to the heap area.
The memory management device according to any one of (1) to (8).
(10) When allocating a memory area from the heap area, assign a region in which a page size that does not exceed the memory size to be allocated is defined,
The memory management device according to (9) above.
(11) In response to a bus fault occurring in the region allocated to the stack area, physical memory is allocated in page size units.
The memory management device according to any one of (1) to (10) above.
(12) A memory management method for performing address conversion from a virtual address to a physical address in page units,
Using the address translation information of the region defined in the virtual address space and the address translation information held in the region information holding unit holding the unique page size of the region, information on the physical address corresponding to the virtual address is obtained. A search step for searching;
It is obtained from the entry that hits the virtual address in the address translation buffer that holds the information indicating the correspondence between the base virtual address and the base physical address in page units and the page size information defined in the region that includes the virtual address. An address conversion step of converting a base physical address and a virtual address into a physical address corresponding to the virtual address;
A memory management method.
(13) physical memory;
A region information holding unit that holds the address translation information of the region defined in the virtual address space and a unique page size of the region, and a physical address corresponding to the virtual address using the address translation information of the region including the virtual address. A memory management unit having a search unit for searching for information, and performing address conversion from a virtual address to a physical address in units of pages;
An information processing apparatus comprising:
 100…センシングデバイス
 101…CPU、102…MMU、103…SRAM
 104…フラッシュメモリ、105…センサ
 106…通信モジュール、107…電池、110…バス
 200…基地局、201…クラウド、202…サーバ
DESCRIPTION OF SYMBOLS 100 ... Sensing device 101 ... CPU, 102 ... MMU, 103 ... SRAM
104 ... Flash memory, 105 ... Sensor 106 ... Communication module, 107 ... Battery, 110 ... Bus 200 ... Base station, 201 ... Cloud, 202 ... Server

Claims (13)

  1.  ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理装置であって、
     前記仮想アドレス空間に定義されたリージョンのアドレス変換情報と、リージョンが持つ固有のページサイズを保持するリージョン情報保持部と、
     仮想アドレスを含むリージョンの前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索部と、
    を具備するメモリ管理装置。
    A memory management device that performs address conversion from a virtual address to a physical address in page units,
    Region address translation information defined in the virtual address space, a region information holding unit for holding a unique page size of the region,
    A search unit that searches for information of a physical address corresponding to the virtual address using the address conversion information of the region including the virtual address;
    A memory management device comprising:
  2.  前記リージョン情報保持部は、仮想アドレス空間上に定義された各リージョンのベース仮想アドレスと、物理メモリ上に置かれたリージョン毎のページテーブルのアドレスと、リージョンに定義されたページサイズ、及びリージョンサイズに関する情報をリージョン毎のエントリに保持し、
     前記探索部は、仮想アドレスを含むリージョンに対応するページテーブルアドレスに基づいて、前記物理メモリ上の該当するページテーブルから仮想アドレスに対応する物理アドレスの情報を探索する、
    請求項1に記載のメモリ管理装置。
    The region information holding unit includes a base virtual address of each region defined on the virtual address space, an address of a page table for each region placed on the physical memory, a page size defined in the region, and a region size Information about the
    The search unit searches for information on the physical address corresponding to the virtual address from the corresponding page table on the physical memory based on the page table address corresponding to the region including the virtual address.
    The memory management device according to claim 1.
  3.  前記探索部は、
     前記リージョン情報保持部内の、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリから、仮想アドレスを含むリージョンのページテーブルアドレスを特定して、
     そのページテーブルアドレスで指定されるページテーブル上の、仮想アドレスとベース仮想アドレスの差分をページサイズで割算して特定されるページから物理アドレス情報を取得する、
    請求項2に記載のメモリ管理装置。
    The search unit
    From the entry containing the virtual address in the base virtual address and the address range obtained by adding the page size of the region to the base virtual address in the region information holding unit, specify the page table address of the region including the virtual address,
    The physical address information is obtained from the page specified by dividing the difference between the virtual address and the base virtual address by the page size on the page table specified by the page table address.
    The memory management device according to claim 2.
  4.  ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファと、
     前記アドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換部と、
    をさらに備える請求項1に記載のメモリ管理装置。
    Information indicating the correspondence between the base virtual address and the base physical address in page units, and an address translation buffer that holds information on the page size defined in the region including the virtual address;
    An address translation unit that combines a base physical address and a virtual address obtained from an entry that hits a virtual address in the address translation buffer, and translates the physical address corresponding to the virtual address;
    The memory management device according to claim 1, further comprising:
  5.  前記アドレス変換部は、ベース仮想アドレスと、ベース仮想アドレスにリージョンのページサイズを加算したアドレス範囲に仮想アドレスが含まれるエントリを、前記アドレス変換バッファ内で検索する、
    請求項4に記載のメモリ管理装置。
    The address translation unit searches the address translation buffer for an entry including a virtual address in a base virtual address and an address range obtained by adding a region page size to the base virtual address.
    The memory management device according to claim 4.
  6.  用途が異なるデータを格納する複数のメモリ領域に対して、仮想アドレス空間上で異なるリージョンを割り当てる、
    請求項1に記載のメモリ管理装置。
    Assign different regions in the virtual address space to multiple memory areas that store data for different purposes.
    The memory management device according to claim 1.
  7.  テキスト領域、ヒープ領域、及びスタック領域に対して、仮想アドレス空間上で異なるリージョンを割り当てる、
    請求項1に記載のメモリ管理装置。
    Assign different regions in the virtual address space to the text area, heap area, and stack area.
    The memory management device according to claim 1.
  8.  テキスト領域に対して、所定のブロックサイズに基づいてページサイズが定義されたリージョンを割り当てる、
    請求項1に記載のメモリ管理装置。
    Assign a region with a defined page size to the text area based on a given block size,
    The memory management device according to claim 1.
  9.  ヒープ領域に対して、ページサイズが異なる2以上のリージョンを割り当てる、
    請求項1に記載のメモリ管理装置。
    Allocate two or more regions with different page sizes to the heap area.
    The memory management device according to claim 1.
  10.  ヒープ領域からメモリ領域を確保する際に、確保したいメモリサイズを超えないページサイズが定義されたリージョンを割り当てる、
    請求項9に記載のメモリ管理装置。
    When allocating a memory area from the heap area, assign a region with a page size that does not exceed the memory size you want to allocate,
    The memory management device according to claim 9.
  11.  スタック領域に割り当てられたリージョンでバスフォルトが発生したことに応答して、ページサイズ単位で物理メモリを割り当てる、
    請求項1に記載のメモリ管理装置。
    In response to a bus fault occurring in the region allocated to the stack area, physical memory is allocated in page size units.
    The memory management device according to claim 1.
  12.  ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理方法であって、
     前記仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部に保持された前記アドレス変換情報を用いて、仮想アドレスに対応する物理アドレスの情報を探索する探索ステップと、
     ページ単位でベース仮想アドレスとベース物理アドレスの対応関係を示す情報と、その仮想アドレスを含むリージョンに定義されたページサイズの情報を保持するアドレス変換バッファ中の仮想アドレスにヒットするエントリから取得されるベース物理アドレスと仮想アドレスを組み合わせて、仮想アドレスに対応する物理アドレスに変換するアドレス変換ステップと、
    を有するメモリ管理方法。
    A memory management method for performing address conversion from a virtual address to a physical address in page units,
    Using the address translation information of the region defined in the virtual address space and the address translation information held in the region information holding unit holding the unique page size of the region, information on the physical address corresponding to the virtual address is obtained. A search step for searching;
    It is obtained from the entry that hits the virtual address in the address translation buffer that holds the information indicating the correspondence between the base virtual address and the base physical address in page units and the page size information defined in the region that includes the virtual address. An address conversion step of converting a base physical address and a virtual address into a physical address corresponding to the virtual address;
    A memory management method.
  13.  物理メモリと、
     仮想アドレス空間に定義されたリージョンのアドレス変換情報とリージョンが持つ固有のページサイズを保持するリージョン情報保持部と、仮想アドレスを含むリージョンの前記アドレス変換情報を用いて仮想アドレスに対応する物理アドレスの情報を探索する探索部を備えて、ページ単位で仮想アドレスから物理アドレスへのアドレス変換を行うメモリ管理ユニットと、
    を具備する情報処理装置。
    Physical memory,
    A region information holding unit that holds the address translation information of the region defined in the virtual address space and a unique page size of the region, and a physical address corresponding to the virtual address using the address translation information of the region including the virtual address. A memory management unit having a search unit for searching for information, and performing address conversion from a virtual address to a physical address in units of pages;
    An information processing apparatus comprising:
PCT/JP2018/043083 2018-02-15 2018-11-21 Memory management device, memory management method, and information processing device WO2019159472A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2020500283A JP7184074B2 (en) 2018-02-15 2018-11-21 Memory management device, memory management method, and information processing device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2018025495 2018-02-15
JP2018-025495 2018-02-15

Publications (1)

Publication Number Publication Date
WO2019159472A1 true WO2019159472A1 (en) 2019-08-22

Family

ID=67618557

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2018/043083 WO2019159472A1 (en) 2018-02-15 2018-11-21 Memory management device, memory management method, and information processing device

Country Status (2)

Country Link
JP (1) JP7184074B2 (en)
WO (1) WO2019159472A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021186142A1 (en) * 2020-03-20 2021-09-23 Arm Limited Memory accessor invalidation
CN114035980A (en) * 2021-11-08 2022-02-11 海飞科(南京)信息技术有限公司 Method and electronic device for sharing data based on scratch pad memory

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08329687A (en) * 1995-06-05 1996-12-13 Hitachi Ltd Semiconductor integrated circuit
JPH10301848A (en) * 1997-04-28 1998-11-13 Hitachi Ltd Virtual storage device provided with multiple page size

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08329687A (en) * 1995-06-05 1996-12-13 Hitachi Ltd Semiconductor integrated circuit
JPH10301848A (en) * 1997-04-28 1998-11-13 Hitachi Ltd Virtual storage device provided with multiple page size

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021186142A1 (en) * 2020-03-20 2021-09-23 Arm Limited Memory accessor invalidation
US11200175B2 (en) 2020-03-20 2021-12-14 Arm Limited Memory accessor invailidation
CN114035980A (en) * 2021-11-08 2022-02-11 海飞科(南京)信息技术有限公司 Method and electronic device for sharing data based on scratch pad memory
CN114035980B (en) * 2021-11-08 2023-11-14 海飞科(南京)信息技术有限公司 Method and electronic device for sharing data based on scratch pad

Also Published As

Publication number Publication date
JP7184074B2 (en) 2022-12-06
JPWO2019159472A1 (en) 2021-01-28

Similar Documents

Publication Publication Date Title
US20230315342A1 (en) Memory system and control method
US8095736B2 (en) Methods and systems for dynamic cache partitioning for distributed applications operating on multiprocessor architectures
CN107844267B (en) Buffer allocation and memory management
US10241909B2 (en) Non-volatile memory device
US10572171B2 (en) Storage system
CN1289419A (en) Compression store free-space management
CN102289409B (en) The memory allocator of layered scalable
CN107015923B (en) Coherent interconnect for managing snoop operations and data processing apparatus including the same
WO2017107015A1 (en) Storage space allocation method, and storage device
US10884959B2 (en) Way partitioning for a system-level cache
WO2019159472A1 (en) Memory management device, memory management method, and information processing device
US11853223B2 (en) Caching streams of memory requests
US20140281132A1 (en) Method and system for ram cache coalescing
CN113138851B (en) Data management method, related device and system
US11726681B2 (en) Method and system for converting electronic flash storage device to byte-addressable nonvolatile memory module
US11403213B2 (en) Reducing fragmentation of computer memory
ES2747962T3 (en) Automatic memory management using a memory management unit
CN107844265B (en) Method of operating a computing system and method of operating a memory controller in a computing system
US10303375B2 (en) Buffer allocation and memory management
CN113010453A (en) Memory management method, system, equipment and readable storage medium
CN110199265B (en) Storage device and storage area management method
CN107766262B (en) Method and device for adjusting number of concurrent write commands
US11726915B2 (en) Distributed coherence directory subsystem with exclusive data regions
US20220334973A1 (en) Entities, system and methods performed therein for handling memory operations of an application in a computer environment
CN116756060A (en) System and method for managing memory utilization

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18906298

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020500283

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18906298

Country of ref document: EP

Kind code of ref document: A1