This application is based upon and claims the benefit of priority from the prior Japanese Patent Application No. 2009-125540, filed on May 25, 2009; the entire contents of which are incorporated herein by reference.
1. Field of the Invention
The present invention relates to a memory management device, a computer system, and a memory management method.
2. Description of the Related Art
Conventionally, a general-purpose multi-tasking operating system (OS) employs a “paging” in which a memory is divided into “pages” of a fixed size (for example, 4 KBytes) and an allocation/deallocation is performed for each page. With this method, for example, when a task requests allocation of a memory area of 400 KBytes, the OS performs a process of searching for 100 free pages and returning a position of each found page. At this time, when the pages in use present in a dispersed manner, the process of searching for a free space needs to be performed a large number of times (100 times in the worst case). In other words, the memory use efficiency is not high in the paging. This is because single rule (memory management policy) of allocating/deallocating a memory every 4 KBytes is applied for all tasks regardless of the processing content.
As a technology for dealing with the above problem, Japanese Patent Application Laid-open No. 2005-338985 discloses a technology of appropriately changing a physical storage area to be allocated to each computer in accordance with the states of computers in a storage system. However, with this technology, only the area to be allocated for each computer is changed and the rule of allocation/deallocation is not changed, so that the above problem is not solved.
A memory management device according to an embodiment of the present invention comprises:
a memory area;
an allocator generating unit that generates a plurality of allocators, which allocates a memory resource of the memory area to a task, for respective rules of allocation/deallocation of the memory resource; and
a task correlating unit that selects one of generated allocators based on an allocator specification that is different for each task by the task and sets such that the task is capable of using selected allocator.
A computer system according to an embodiment of the present invention comprises:
a memory area;
a task that operates by using the memory area;
an allocator generating unit that generates a plurality of allocators, which allocates a memory resource of the memory area to the task, for respective rules of allocation/deallocation of the memory resource; and
a task correlating unit that selects one of generated allocators based on an allocator specification that is different for each task by the task and sets such that the task is capable of using selected allocator.
A memory management method according to an embodiment of the present invention comprises:
generating a plurality of allocators, which allocates a memory resource of a memory area included in a computer system to a task, for respective rules of allocation/deallocation of the memory resource; and
setting including
Exemplary embodiments of a memory management device, a computer system, and a memory management method according to the present invention will be explained below in detail with reference to the accompanying drawings. The present invention is not limited to the following embodiments.
A memory management device in a first embodiment of the present invention is mounted on a computer that includes a processor and a nonvolatile memory such as a random access memory (RAM). Specifically, the function as the memory management device in the first embodiment is realized on the computer by the processor of the computer reading out a kernel program from a read only memory (ROM), an external storage device, or the like and executing it.
First, a paging is taken as a comparison example and the characteristics of the first embodiment are explained while comparing with the comparison example.
The processor 2 executes a kernel program as a memory management program that performs the memory management for the RAM 4. A kernel program 5 is stored in the ROM 3 and is loaded on the RAM 4 via the bus line. The processor 2 executes the kernel program 5 loaded on the RAM 4. Specifically, in the memory management device 1, the processor 2 reads out the kernel program 5 from the ROM 3 at the time of startup and loads the kernel program 5 on the program storing area in the RAM 4, and realizes the function of performing the memory management operation in the first embodiment by corporation of the kernel program 5 loaded on the RAM 4 and the processor 2. The function of performing the memory management operation in the first embodiment is explained later. The kernel program 5 can be stored in a storage device such as a disk. Alternatively, the kernel program 5 can be loaded on a storage device such as a disk.
The kernel program 5 executed in the memory management device 1 in the first embodiment can be provided in such a way that the kernel program 5 is stored in a computer connected to a network such as the Internet and is downloaded via the network. The kernel program 5 executed in the memory management device 1 in the first embodiment can also be provided or distributed via the network such as the Internet. Alternatively, the kernel program 5 in the first embodiment can be incorporated in a ROM or the like in advance and provided to the memory management device 1 in the first embodiment. In the following, the kernel program 5 is expressed simply as the kernel 5 in some cases.
Specifically, the allocator generating function unit 11 selects an allocation function and a deallocation function from the allocation/deallocation function group 12 and embeds pointers for referring to the selected functions in the allocator, thereby providing the memory management policy as a rule of the memory allocation/deallocation to the allocator. In the following, the memory management policy is simply expressed as a rule in some cases. The allocation/deallocation function group 12 is explained to be included in the kernel 5; however, the allocation/deallocation function group 12 can be provided from a user program instead of from the kernel 5.
Next, the operation of the memory management device 1 in the first embodiment is explained.
After the process at S1, the task correlating function unit 13 correlates the video decode task and the video frame output task with the allocator A and the allocator B, respectively (S2). Specifically, the kernel 5 generates data (task management data) for task management for performing scheduling of the tasks and the like. Moreover, the allocator ID is specified in advance in the code of each task. The task correlating function unit 13 selects the allocator (in this case, the allocator A or the allocator B) that each task uses based on the allocator ID specified in the code of each task and embeds a pointer to each selected allocator in the task management data of each task before starting each task.
Returning to
After finishing the tasks, the memory management device 1 calls the deinitialization function by using each pointer described in the data structures of the unnecessary allocators A and B and performs the deinitialization function to delete the allocator A and the allocator B (S4).
As described above, according to the first embodiment, a plurality of allocators each for allocating a memory resource of the memory area to the task is generated for memory management policies, respectively, one of the generated allocators is selected based on the allocator specification described in the code of the task, and the allocator that the task selects can be used, so that the task can use the allocator that uses the memory management policy according to the processing content, thus enabling to improve the memory use efficiency compared with the paging.
Moreover, the management target area is reserved for each allocator, so that each allocator allocates the memory area from the management target area managed by itself. Therefore, the free space to be allocated to the task is easily searched for.
Furthermore, because a unit size of the memory resource to be allocated/deallocated in one allocation/deallocating operation is specified in the memory management policy, the task can set to use the allocator that uses the memory management policy of allocating/deallocating in a unit size appropriate for the processing content of the task, thus enabling to improve the memory use efficiency.
For example, the video encode task reserves the memory as needed in units of relatively small data size similarly to the above video decode task and uses the memory. However, it is known that, in the case of the video decode task, the searching efficiency is good when using a method of searching the memory area of the management target area for a free space from the top in each time and reserving the first found free space of 64 Bytes, and, in the case of the video encode task, the searching efficiency is good when searching the area in which the allocation of 64 Bytes succeeded last time for the free space. Thus, in a second embodiment, the method of searching for the space area is further described in the allocation function.
The hardware configuration and the functional configuration for realizing the above operation are similar to those in the first embodiment and only the description of the allocation function is different, so that the detailed explanation of the hardware configuration and the functional configuration in the second embodiment is omitted. Moreover, the detailed explanation of the operation is approximately the same as that in the first embodiment except for the schematic explanation, so that it is also omitted.
As explained above, according to the second embodiment, the searching rule for the free space of the memory area for allocating to the task is specified in the memory management policy, so that the memory use efficiency can be improved.
In a third embodiment, each task can switch a plurality of allocators and use it. For example, the video codec task that is single task that performs decoding and encoding of the video is considered.
The configuration of the memory management device in the third embodiment is explained. The hardware configuration of the memory management device in the third embodiment is similar to that in the first embodiment, so that explanation thereof is omitted.
As shown in
Next, the operation of the memory management device 6 in the third embodiment is explained.
In
Next, the system control proceeds to the process of correlating the video codec task with the allocator A (S13). In this example, the video codec task inquires of the allocator managing function unit 14 about whether the allocator A presents by specifying the ID of the allocator A. Because the inquired allocator A is registered, the allocator managing function unit 14 instructs the task correlating function unit 13 to statistically correlate the video codec task with the allocator A before startup of the video codec task.
Subsequent to S13, the kernel 5 executes the video decode function of the video codec task (S14). At this time, the kernel 5 executes the memory area allocation/deallocation as needed by using the allocator A that is correlated with the task management data. In other words, the “policy of searching for the free space of 64 Bytes from the top” is applied to the memory area allocation/deallocation that the video codec task uses.
Next, after finishing the execution of the video decode function, the memory management device 6 calls the deinitialization function of the allocator A and performs the deinitialization function to delete the allocator A (S15). At this time, the allocator managing function unit 14 deletes the stored ID of the allocator A.
Next, the video codec task inquires of the allocator managing function unit 14 about whether the allocator B presents by specifying the ID of the allocator B. Because the inquired allocator B is registered, the allocator managing function unit 14 instructs the task correlating function unit 13 to correlate the video codec task with the allocator B (S16).
Next, the kernel 5 executes the video encode function of the video codec task (S17). At this time, the kernel 5 executes the memory area allocation/deallocation as needed by using the allocator B that is correlated with the task management data. In other words, the “policy of reserving the free space of 64 Bytes from the area in which the allocation succeeded last time” is applied to the memory area allocation/deallocation that the video codec task uses.
Then, after finishing the execution of the video encode function, the memory management device 6 calls the deinitialization function of the allocator B and performs the deinitialization function to delete the allocator B (S18), and the operation ends. At this time, the allocator managing function unit 14 deletes the stored ID of the allocator B.
As described above, according to the third embodiment, the allocator set to the task is switched based on the specification (request) of the allocator issued from the task before and during the task, so that the allocators can be selectively used even when single task for performing a plurality of processing content is operated, thus enabling to improve the memory use efficiency.
Additional advantages and modifications will readily occur to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details and representative embodiments shown and described herein. Accordingly, various modifications may be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2009-125540 | May 2009 | JP | national |