1. Technical Field
The disclosure relates to an electronic apparatus for data access and a data access method therefor, wherein a processing unit of the electronic apparatus has data compression functionality.
2. Description of the Related Art
Nowadays, electronic devices such as smart phones and tablet computers, equipped with versatile functionality, may have their memory not enough for usage because the users frequently download and update application programs from the software market, leading to rapid data access. In addition, since the smart phones and tablet computers are intended for providing good user experience, the manufacturers employ various approaches, such as utilizing processors with higher operating frequencies or multiple cores to speed up the execution of the application programs, so as to make the users experience the smoothness of use, enhancing the productivity of the electronic devices.
The manufacturers generally fulfill the demand of the users by providing the electronic devices equipped with memory of higher memory space and processor of a higher speed. However, such approach will relatively increase the price as well as the cost, which is not conducive to popularization. Besides, the problem still cannot be resolved for middle or low level products.
Embodiments are provided for an electronic apparatus for data access and a data access method therefor.
One embodiment of the disclosure provides an electronic apparatus for data access, including: a memory unit and a processing unit. The processing unit includes: a processor, a memory mapping unit, and a compression and decompression unit. The memory mapping unit, coupled between the processor and the memory unit, is for performing conversion of a virtual address and a physical address for a write or read operation in the memory unit by the processor. The compression and decompression unit, coupled between the processor and the memory unit, is for selectively performing data compression or data decompression for a write or read operation in the memory unit by the processor. When the processing unit determines that a compression criterion is satisfied, the processing unit enables the compression and decompression unit to compress data to be written and accordingly output corresponding compressed data to the memory unit, wherein the compression criterion includes: whether an idle rate for the processing unit is greater than a first threshold.
According to another embodiment, a data access method is provided for use in an electronic apparatus, including the following steps. A determination is made by a processing unit of the electronic apparatus as to whether a compression criterion is satisfied, wherein the compression criterion includes: whether an idle rate for the processing unit is greater than a first threshold. When the compression criterion is satisfied: enabling a compression and decompression unit of the processing unit to enter a compression mode is made; and compressing data to be written and accordingly outputting corresponding compressed data to the memory unit is performed by the compression and decompression unit.
In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the disclosed embodiments.
Referring to
In
The compression and decompression unit 15, coupled between the processor 11 and the memory unit 90, is for selectively performing data compression or data decompression for a write or read operation by in the memory unit 90 the processor 11. The compression and decompression unit 15 may be implemented, for example, using data compression and decompression computation circuitry based on one or more algorithms for data compression and decompression, or using a processing circuit performing data compression and decompression software (such as a gzip engine), wherein a lossless data compression algorithm, such as Sliding Window Algorithms, Dictionary Algorithms, Non-dictionary Algorithms, may be adopted. When the processing unit 10 performs data access operation such as write or read operation, e.g., in response to write or read instruction, the processing unit 10 determines whether to utilize the compression and decompression unit 10 to perform compression or decompression or not to perform compression operation, wherein the memory mapping unit 13 provides corresponding physical addresses for data access operation by the compression and decompression unit 15.
The compression and decompression unit 15 includes: a data compression and decompression (DCD) module 151, a switch circuit 153, a bypass data path 155, and a memory 157. The data compression and decompression module 151 is for selectively performing data compression or decompression. The bypass data path 155 is for outputting the data to be written to the memory unit 90 in a bypassing manner. The data compression and decompression module 151 and the bypass data path 155 are coupled in parallel between the switch circuit 153 and the processor 111. The memory 157 is used by the data compression and decompression module 151. In some embodiment, the memory 157 can be a memory embedded into the data compression and decompression module 151.
In an embodiment, as in step S110, it is determined by a processing unit of the electronic whether a compression criterion is satisfied device, wherein the compression criterion may include one or more sub-criteria, for example: whether an idle rate for the processing unit is greater than a first threshold, such as 50%, 60%. The determination as in step S110 is performed, for example, when the processing unit handles data to be written, or in response to a write instruction associated with data to be written. In step S120, when the compression criterion is satisfied, a compression and decompression unit of the processing unit is enabled to enter a compression mode. In step S130, data to be written is compressed and accordingly corresponding compressed data is outputted to a memory unit of the electronic apparatus, by the compression and decompression unit.
In step S140, when the compression criterion is not satisfied, the compression and decompression unit is enabled to output the data to be written to the memory unit.
In the above embodiment, when the compression criterion is satisfied, for example, when the idle rate for the processing unit satisfies the criterion, the data to be written can be compressed and then written into the memory unit. In this way, the situation in which the entire performance is affected by compression for data to be written at a low idle rate, i.e., a high usage rate, for the processing unit can be prevented.
Thus, a suitable compression criterion can be configured for the design requirement of an electronic apparatus, for example, further including: whether a write instruction associated with the data to be written has a priority not less than a second threshold. For instance, the priority of write instructions can be categorized into two or more levels by requirements: such as, one of high, middle, low priority, in this case, the second threshold can be set to high or middle priority. As an example, data to be written for some application programs are required to be first in, first out, and hence the priority of the write instruction can be set to the high priority. The compression criterion may further include: whether the data to be written is of a type of compressed data. For example, if the data to be written is of a type of compressed data, such as a files of format for APK, ARJ, ZIP, RAR, Z, gz and so on, then step S140 can be performed to avoid redundant compression. In some examples, if the data to be written is a file, the determination can be made according to its file name (such as extension) or its header or identification.
In addition, the determination of the step S110 and the enabling of the compression and decompression unit can be implemented by the memory mapping unit 13 or the control module 131 of the memory mapping unit 130 or the processor 11. The information for the determination of the compression criterion, such as the idle rate for the processing unit, can be obtained by the processor 11 from the operating system, such as Android, iOS, OSX, Windows or other, executed by the electronic apparatus 1. Besides, in step S110, the idle rate is used for a criterion for determination, and other equivalent or similar criterion for determination, such as whether a usage rate for the processing unit is less than a threshold, can also be implemented as the criterion; thus, the implementation is not limited thereto.
Further, for the processing unit 100 of
In an embodiment, the above method may further include step S150 to record the storage location of the memory unit in which the corresponding compressed data is stored by updating a compression record table or generating related record in other form. When the processing unit reads data, the compression record table of this embodiment can be used in determining whether the data to be read is compressed data. The compression record table may be stored in the memory mapping unit 13 or the memory 133 of the memory mapping unit 130. However, the related record is not limited thereto; for example, it can be stored in a memory device outside the memory mapping unit 13.
Referring to
The above embodiment shows that the memory mapping unit determines whether to decompress the data to be read according to the compression record table. For example, the compression record table can be implemented as storing locations, e.g., one or some blocks, pages, or sectors, of compressed data stored in physical memory space of the memory unit in terms of blocks, pages, or other data unit. As an example, the compression record table can be realized by a mapping table for recording actual storage locations of compressed data, such as ones as indicated in block, page, or sector. For example, a mapping table, as indicated in Table 1, records a physical page number, denoted by PPN1 (e.g., 1000), in memory corresponding to a logical sector number, denoted by LSN1 (e.g., 100), for a piece of data; and, for another piece of data, a logical sector number, denoted by LSN2 (e.g., 200) corresponding to a physical page number, denoted by PPN2 (e.g., 2000). In addition, a physical page number corresponding to a specific logical sector number may vary with the situation of the physical memory; for example, the data in LSN1 has been changed, the address of LSN1 does not change, but the data size and length, after compression, has been changed and the system then stores the compressed data in PPN3 so that the data in PPN1 is removed in order for the other user to use. The compression record table may further record related attributes for data compression, for example, the format of data compression.
Moreover, in one embodiment, after the writing of the compressed data, the processing unit may update the content of the compression record table with respect to the situation of the write operation. Nevertheless, the implementation of the compression record table is not limited to the above. In another embodiment, the processing unit may, during the writing of the compressed data, add related information into the compressed data, such as making amendments to or adding: file header, flag, or identification of the compressed data; and afterwards, during the compressed data being accessed (e.g., being read), update the content of the compression record table with respect to the compressed data. As such, the method for use in read or write operation by the processing unit as shown in
Further, for the data access method as shown in
The above embodiment shows that the processing unit can prevent the data to be written which may have poor compression result from being compressed. For example, the data to be written is a file. The portion of the data to be written as in step S310 can be the beginning portion, or one or a plurality of blocks of data of the file. A determination as to whether the compression criterion is satisfied, as indicated in step S320, can be realized in various approaches. For example, a determination is made as to whether a compression ratio, defined by the data amount of the portion of the data to be written dividing the data amount of the corresponding compressed data of the portion is less than a compression threshold, wherein the compression threshold is a number not greater than one, e.g., 1, 0.8, or 0.7. As another example, a determination is made as to whether the data amount of the corresponding compressed data of the portion is less than the data amount of the portion of the data to be written, or less than the latter times a compression threshold. Thus, the determination of step S320 can be implemented in any equivalent manner and not limited to the above examples.
In addition, steps S310-S340 of
In another embodiment, a control module 159 can be further implemented in the compression and decompression unit 150 of
The electronic apparatus and data access method are disclosed in the above embodiments. In some practical applications, the usage space of memory can be saved efficiently, reducing the required amount of memory since the processing unit has the capability to decompress by hardware. Besides, since application programs for installation is decompressed data, for example, ZIP files, such as APK files in Android system, decompression can be performed for this by using the above embodiment, in order to speed up the installation of software, bringing better user experiences for the users. Further, in other practical applications, faster installation of system software updates or firmware can be obtained.
It will be apparent to those skilled in the art that various modifications and variations can be made to the disclosed embodiments. It is intended that the specification and examples be considered as exemplary only, with a true scope of the disclosure being indicated by the following claims and their equivalents.