Disclosure of Invention
In view of the foregoing, it is desirable to provide an efficient storage space configuration method, apparatus, computer device and storage medium for solving the above technical problems.
A method of memory space configuration, the method comprising:
acquiring a storage space configuration request;
configuring storage areas for all storage areas in the storage space respectively; the configuration of the storage area comprises: configuring attribute information of the storage area;
running the test function, and calculating the running time of the test function according to the current attribute configuration information;
reconfiguring the attribute information in all the storage areas in the storage space, repeatedly running the test function, and calculating the running time of the test function according to the current attribute configuration information;
and comparing the running time of the test functions corresponding to all the attribute configuration information, and storing the attribute configuration information corresponding to the shortest running time in the flash memory.
In one embodiment, after the step of saving the attribute configuration information corresponding to the shortest running time in the flash memory, the method further includes:
setting MPU flag bit information of the storage space to true;
resetting the CPU;
and reading the attribute configuration information stored in the flash memory, and configuring a corresponding register to complete the configuration of the storage space.
In one embodiment, the step of obtaining the storage space configuration request is followed by:
acquiring MPU zone bit information of the storage space;
judging whether the MPU zone bit information is true;
and if the MPU flag bit information is not true, executing the step of respectively configuring the storage areas of all the storage areas in the storage space.
In one embodiment, after the step of determining whether the MPU flag information is true, the method further includes:
if the MPU zone bit information is true, reading storage space configuration information from a flash memory;
and configuring the corresponding register to complete the configuration of the storage space.
In one embodiment, the configuring of the storage area further includes:
and configuring the base address and the size of the storage region.
In one embodiment, the step of configuring the storage areas for all the storage areas in the storage space respectively includes:
selecting a storage area from the storage space, and configuring the base address and the size of the storage area;
configuring the attribute information of the storage area in the configurable attribute range of the storage area;
repeatedly selecting a storage area from the storage space, and configuring the base address and the size of the storage area; and configuring the attribute information of the storage area in the configurable attribute range of the storage area until all the storage areas in the storage space are configured.
A storage space configuration apparatus, the storage space configuration comprising:
the acquisition module is used for acquiring a storage space configuration request;
the configuration module is used for respectively configuring the storage areas of all the storage areas in the storage space; the configuration of the storage area comprises: configuring attribute information of the storage area;
the test module is used for running the test function and calculating the running time of the test function according to the current attribute configuration information;
a repeating module, configured to reconfigure the attribute information in all the storage areas in the storage space, repeat the running of the test function, and calculate the running time of the test function according to the current attribute configuration information;
and the comparison module is used for comparing the running time of the test functions corresponding to all the attribute configuration information and storing the attribute configuration information corresponding to the shortest running time in the flash memory.
In one embodiment, the storage space configuration further includes:
the setting module is used for setting the MPU zone bit information of the storage space to be true;
the reset module is used for resetting the CPU;
and the reading module is used for reading the attribute configuration information stored in the flash memory and configuring a corresponding register so as to complete the configuration of the storage space.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the above methods when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of any of the methods described above.
The storage space configuration method, the storage space configuration device, the computer equipment and the storage medium acquire the storage space configuration request. Respectively configuring storage areas for all storage areas in the storage space, wherein the configuration of the storage areas comprises the following steps: configuring attribute information of the storage area. And running the test function, and calculating the running time of the test function according to the current attribute configuration information. Reconfiguring the attribute information in all the storage areas in the storage space, repeatedly running the test function, and calculating the running time of the test function according to the current attribute configuration information. And comparing the running time of the test functions corresponding to all the attribute configuration information, and storing the attribute configuration information corresponding to the shortest running time in the flash memory. The invention realizes that the optimal attribute configuration information is determined according to the time required by running the test function, so that the system runs in the most efficient state, the running time of the system is reduced, and the efficiency is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In order to more clearly illustrate the present invention, the overall inventive concept of the present invention is first described. After the CPU is powered on, MPU zone bit information is firstly read from the flash memory, whether the MPU zone bit is true or not is judged, if not, the MPU does not finish the self-learning configuration of the storage space, and then the process of the storage space configuration is entered. In the process, the system traverses each attribute of each area, determines the optimal attribute configuration information according to the time required by running the test function in each state, stores the attribute configuration information in the flash memory, sets the flag bit of the MPU to be true, and finally performs reset operation on the CPU, wherein the CPU restarts running codes from the 0 address at the moment, reads the configuration information of the storage space attribute from the flash memory, and configures the configuration information. At the moment, the system runs according to the most efficient storage space access rule, so that the running time of the system can be reduced, and the efficiency is improved.
In one embodiment, as shown in fig. 1, there is provided a storage space configuration method, including:
step 102, obtaining a storage space configuration request.
104, respectively configuring storage areas for all storage areas in the storage space; the configuration of the storage area includes: configuring attribute information of the storage area.
And 106, running the test function, and calculating the running time of the test function according to the current attribute configuration information.
And 108, reconfiguring the attribute information in all the storage areas in the storage space, repeatedly running the test function, and calculating the running time of the test function according to the current attribute configuration information.
Step 110, comparing the running times of the test functions corresponding to all the attribute configuration information, and storing the attribute configuration information corresponding to the shortest running time in the flash memory.
Specifically, first, a storage space configuration request is acquired. Then, configuring storage areas for all storage areas in the storage space respectively; the configuration of the storage area includes: configuring attribute information of the storage area. Since the storage space includes a plurality of storage areas, all the storage areas are configured accordingly. Including configuration of base address and size. Attribute configuration of attributes is carried out in each area, and the specific configuration process is as follows: an attribute is configured within the configurable attribute range of the segment of memory area. It can be understood that all the storage areas of the storage space need to be configured accordingly, and the configuration parameters need to be stored.
And then, running the test function, calculating the running time of the test function in the attribute state, and recording the attribute configuration information at the moment. Reconfiguring the attribute information in all the storage areas in the storage space, repeatedly operating the test function, and calculating the operation time of the test function according to the current attribute configuration information until all the configurable attribute states run the test function. Thus, a corresponding relation between a set of attribute configuration information and the running time of the test function is established.
Finally, comparing the running time of the test function corresponding to all the attribute configuration information, and storing the attribute configuration information corresponding to the shortest running time in the flash memory. Therefore, the optimal attribute configuration information is determined according to the time required by running the test function, and the attribute configuration information is stored in the flash memory.
In this embodiment, the request is configured by obtaining the storage space. Respectively configuring storage areas for all storage areas in the storage space, wherein the configuration of the storage areas comprises the following steps: configuring attribute information of the storage area. And running the test function, and calculating the running time of the test function according to the current attribute configuration information. Reconfiguring the attribute information in all the storage areas in the storage space, repeatedly running the test function, and calculating the running time of the test function according to the current attribute configuration information. And comparing the running time of the test functions corresponding to all the attribute configuration information, and storing the attribute configuration information corresponding to the shortest running time in the flash memory. According to the embodiment, the optimal attribute configuration information is determined according to the time required by running the test function, so that the system runs in the most efficient state, the running time of the system is reduced, and the efficiency is improved.
In one embodiment, a storage space configuration method is provided, as shown in fig. 2, and after the step of saving the attribute configuration information corresponding to the shortest runtime in the flash memory, the method further includes:
in step 202, MPU flag bit information for the memory space is set to true.
Step 204, resetting the CPU.
Step 206, reading the attribute configuration information stored in the flash memory, and configuring the corresponding register to complete the configuration of the storage space.
Specifically, after the step of saving the attribute configuration information corresponding to the shortest running time in the flash memory, the MPU flag bit, which is true, indicates that the process of self-learning configuration of the storage space has been performed, and the specific configuration file has been saved in the flash memory, is set to true. Then, a reset operation is performed on the CPU, and the CPU restarts to run the code from the 0 address. And finally, reading the configuration information of the storage space attribute from the flash memory and configuring.
In this embodiment, the configuration information of the storage space attribute is read from the flash memory by performing a reset operation on the CPU, and configured. At the moment, the system runs according to the most efficient storage space access rule, so that the running time of the system can be reduced, and the efficiency is improved.
In one embodiment, a storage space configuration method is provided, as shown in fig. 3, and after the step of obtaining the storage space configuration request, the method includes:
step 302, MPU flag bit information of the storage space is obtained.
Step 304, determine if the MPU flag information is true.
And step 306, if the MPU flag bit information is not true, executing the step of respectively configuring the storage areas in all the storage areas in the storage space.
Step 308, if the MPU flag bit information is true, reading the storage space configuration information from the flash memory; and configuring the corresponding register to complete the configuration of the storage space.
Specifically, after the step of acquiring the storage space configuration request, MPU flag bit information of the storage space is first acquired from the flash memory, and a determination is made according to whether the MPU flag bit information is true. If the MPU flag bit information is not true, that is, the MPU does not complete the self-learning configuration of the storage space, the step of configuring the storage areas for all the storage areas in the storage space in the above embodiment is started. If the MPU flag bit information is true, the MPU is indicated to finish the self-learning configuration of the storage space, and the specific configuration file is stored in the flash memory. Only the configuration information of the storage space is read from the flash memory; and configuring the corresponding register to complete the configuration of the storage space.
In the embodiment, whether the MPU completes the self-learning configuration of the storage space is judged by judging whether the flag bit information of the MPU is true, so that the efficiency of the configuration of the storage space is improved, and the time is saved.
In one embodiment, a storage space method is provided, as shown in fig. 4, in which the step of configuring storage areas for all storage areas in a storage space respectively includes:
step 402, selecting a storage area from the storage space, and configuring the base address and the size of the storage area.
Step 404, configuring the attribute information of the storage area within the configurable attribute range of the storage area.
Step 406, repeatedly selecting a storage area from the storage space, and configuring the base address and the size of the storage area; and configuring the attribute information of the storage area within the configurable attribute range of the storage area until all the storage areas in the storage space are configured.
Since the storage space includes a plurality of storage regions, each region needs to be configured with attributes individually, and in this embodiment, the base address, the size, and the attributes of each storage region are configured sequentially by a loop method. Specifically, first, a first storage area is selected from the storage space, and the base address and the size of the first storage area are configured. And then configuring the attribute information of the storage area in the configurable attribute range of the first storage area. Then, a second storage area is selected from the storage space, and the base address and the size of the second storage area are configured. And then configuring the attribute information of the storage area in the configurable attribute range of the second storage area. And sequentially circulating the configuration process until all the storage areas are configured.
In this embodiment, the base address, the size, and the attribute of each storage region are sequentially configured by a circular configuration method, so that the efficiency of configuring the storage space is improved, and the time is saved.
It should be understood that although the various steps in the flow charts of fig. 1-4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-4 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 5, there is provided a storage space configuration apparatus 500, the storage space configuration including:
an obtainingmodule 501, configured to obtain a storage space configuration request;
aconfiguration module 502, configured to configure storage areas for all storage areas in the storage space respectively; the configuration of the storage area comprises: configuring attribute information of the storage area;
thetest module 503 is configured to run a test function, and calculate a running time of the test function according to the current attribute configuration information;
a repeatingmodule 504, configured to reconfigure the attribute information in all the storage areas in the storage space, repeat the running of the test function, and calculate the running time of the test function according to the current attribute configuration information;
the comparingmodule 505 is configured to compare the running times of the test functions corresponding to all the attribute configuration information, and store the attribute configuration information corresponding to the shortest running time in the flash memory.
In one embodiment, as shown in fig. 6, the storage space configuration apparatus 500 further includes:
asetting module 506, configured to set MPU flag information of the storage space to true;
areset module 507, configured to reset the CPU;
thereading module 508 is configured to read the attribute configuration information stored in the flash memory, and configure a corresponding register to complete configuration of the storage space.
In one embodiment, the obtainingmodule 501 is further configured to: acquiring MPU zone bit information of the storage space; judging whether the MPU zone bit information is true; and if the MPU flag bit information is not true, executing the step of respectively configuring the storage areas of all the storage areas in the storage space.
In one embodiment, the obtainingmodule 501 is further configured to: if the MPU zone bit information is true, reading storage space configuration information from a flash memory; and configuring the corresponding register to complete the configuration of the storage space.
In one embodiment, theconfiguration module 502 is further configured to: configuring storage areas for all storage areas in the storage space respectively; the configuration of the storage area further comprises: and configuring the base address and the size of the storage region.
In one embodiment, theconfiguration module 502 is further configured to: selecting a storage area from the storage space, and configuring the base address and the size of the storage area; configuring the attribute information of the storage area in the configurable attribute range of the storage area; repeatedly selecting a storage area from the storage space, and configuring the base address and the size of the storage area; and configuring the attribute information of the storage area in the configurable attribute range of the storage area until all the storage areas in the storage space are configured.
For specific limitations of the storage space configuration apparatus, reference may be made to the above limitations of the storage space configuration method, which is not described herein again.
In one embodiment, a computer device is provided, the internal structure of which may be as shown in FIG. 7. The computer device includes a processor and a memory connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The computer program is executed by a processor to implement a memory space allocation method.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the above method embodiments when executing the computer program.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the above respective method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.