Data processing method and device in flashing, readable storage medium, and terminal
By adopting data processing methods in flashing technology, using memory data index table to query and write shared memory, the problem of low flashing efficiency is solved, and more efficient memory utilization and system scheduling is achieved.
Patent Information
- Application Number
- CN202211202524.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-09-29
AI Technical Summary
The existing flashing technology is low in efficiency, resulting in excessive memory resources occupied by the computer operating system and reduced system scheduling efficiency.
A data processing method in a flashing machine is adopted to query data in shared memory by receiving packet requests from download threads. If the data exists, return it directly; if the data does not exist, write the file data to be downloaded to the shared memory based on the actual data amount read at one time, and update the memory data index table.
It realizes that multiple download threads share data to be downloaded, reduces frequent read and write operations, improves memory utilization and system scheduling efficiency, and thus improves flashing efficiency.
Smart Images

Figure CN115390864B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of flashing, and in particular, to a data processing method and device, a readable storage medium, and a terminal during flashing. Background Art
[0002] When manufacturing terminal devices, the system is usually installed on the terminal devices by flashing. To improve production efficiency, flashing is usually performed in a one-to-many manner, and then operations such as calibration and comprehensive testing are carried out. Flashing refers to using a download tool to connect to the terminal device through USB / WIFI or other means, and downloading the Image and Bin files to the random access memory (RAM) of the terminal device chip. After the terminal device finishes flashing, it can obtain the functions of a certain software version.
[0003] The one-to-many flashing tool performs parallel flashing of multiple terminal devices through multiple download threads. Among them, one-to-many means that one computer (PC) is connected to multiple terminal devices for flashing operations at the same time. Each download thread has independent memory resources, reads the file data into the memory in the order of downloading files (such as Image and / or Bin files), and then downloads the data packets to the terminal device according to the transmission capacity. In the case of a large number of terminal devices, it is easy to cause the operating system memory resources of the computer to be occupied more or even full, and the system scheduling efficiency is reduced. If the memory allocation size of each download thread is reduced, or no memory is allocated, it will result in frequent reading of the Image and Bin files and then sub-packet downloading to the terminal device side, which will cause the download rate to become low. In summary, the flashing efficiency of the existing flashing method is low. Summary of the Invention
[0004] The technical problem solved by the embodiments of the present invention is the low flashing efficiency.
[0005] To solve the above technical problems, an embodiment of the present invention provides a data processing method during flashing, including: receiving a data packet request from a download thread, where the data packet request includes: a download thread identifier and data information of the data to be downloaded, and the data information of the data to be downloaded includes: the file to which the data to be downloaded belongs, the data offset of the file to which it belongs, and the data packet size, where the data offset of the file to which it belongs is used to indicate the position of the data to be downloaded in the file to which it belongs; querying data according to the data information of the data to be downloaded and a preset memory data index table, where the memory data index table is used to record the indexes of the existing data in the shared memory; if the data to be downloaded is queried from the shared memory, returning the data to be downloaded to the corresponding download thread according to the download thread identifier; if the data to be downloaded is not queried from the shared memory, writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time, updating the memory data index table, and returning the data to be downloaded to the corresponding download thread according to the download thread identifier, where the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the data offset of the file to which it belongs, and the actually read data volume at one time.
[0006] Optionally, the actually read data volume at one time is calculated in the following manner, including: calculating the estimated capacity of a memory block according to the maximum memory usage threshold of the shared memory, the memory already used in the shared memory, the minimum data read threshold, and the maximum memory allocation threshold of the memory block; determining the remaining unread data volume of the file to which the data to be downloaded belongs according to the total data volume of the file to which the data to be downloaded belongs and the data offset of the file to which it belongs; taking the minimum value between the estimated capacity of the memory block and the remaining unread data volume of the file to which the data to be downloaded belongs as the actually read data volume at one time.
[0007] Optionally, writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time includes: judging whether a new memory block can be allocated according to the actually read data volume at one time and the memory already allocated in the shared memory; if a new memory block can be allocated, allocating a new memory block according to the actually read data volume at one time, where the capacity of the new memory block is equal to the actually read data volume at one time; writing the data of the file to be downloaded into the new memory block.
[0008] Optionally, writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time includes: if a new memory block cannot be allocated, determining whether there is a memory block in the shared memory that meets the reset condition, where the reset condition includes: the data of the memory block is not currently used by the download thread, and the capacity of the memory block is greater than or equal to the actually read data volume at one time; resetting the memory block that meets the reset condition, updating the memory data index table, and using the reset memory block as the free memory block; writing the data of the file to be downloaded into the free memory block.
[0009] Optionally, if there are multiple memory blocks that meet the reset condition, resetting the memory blocks that meet the reset condition includes: resetting all the memory blocks that meet the reset condition; or selecting one of the memory blocks that meet the reset condition for resetting.
[0010] Optionally, selecting one of the memory blocks that meet the reset condition for resetting includes: obtaining the data download progress of all download threads; estimating the expected usage time of the data in all the memory blocks that meet the reset condition according to the data download progress of all download threads; selecting the memory block with the latest expected usage time for resetting.
[0011] Optionally, writing the data of the file to be downloaded into the free memory block according to the actually read data volume at one time includes: if there is no memory block that meets the reset condition, selecting and releasing one or more memory blocks not used by the download thread, and updating the memory data index table, so that the free memory obtained after release is greater than or equal to the actually read data volume at one time; allocating a new memory block from the free memory as the free memory block according to the actually read data volume at one time, and writing the data of the file to be downloaded into the free memory block.
[0012] Optionally, selecting and releasing one or more memory blocks not used by the download thread includes: obtaining the data download progress of all download threads; estimating the expected usage time of the data in the memory blocks not used by the download thread according to the data download progress of all download threads; selecting and releasing memory blocks according to the actually read data volume at one time and the expected usage time, and updating the memory data index table.
[0013] Optionally, the memory data index table includes the following parameters: file identifier, total data volume of the file, file data offset, memory block index corresponding to the file, actually read data volume at one time, memory block start address pointer, and number of download threads used.
[0014] An embodiment of the present invention further provides a data processing device during flashing, including: a receiving unit, configured to receive a data packet request of a download thread, where the data packet request includes: a download thread identifier and data information of data to be downloaded, and the data information of the data to be downloaded includes: a file to which the data to be downloaded belongs, a data offset of the belonging file, and a data packet size, where the data offset of the belonging file is used to indicate the position of the data to be downloaded in the belonging file; a query unit, configured to perform data query according to the data information of the data to be downloaded and a preset memory data index table, where the memory data index table is used to record indexes of existing data in the shared memory; a data return unit, configured to, if the data to be downloaded is queried from the shared memory, return the data to be downloaded to the corresponding download thread according to the download thread identifier; an update unit, configured to, if the data to be downloaded is not queried from the shared memory, write the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time, update the memory data index table, and the data return unit is configured to return the data to be downloaded to the corresponding download thread according to the download thread identifier, where the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data volume read at one time.
[0015] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, the steps of any one of the above data processing methods during flashing are executed.
[0016] An embodiment of the present invention further provides a terminal, including a memory and a processor, where a computer program capable of running on the processor is stored on the memory, and when the processor runs the computer program, the steps of any one of the above data processing methods during flashing are executed.
[0017] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:
[0018] In an embodiment of the present invention, according to the data packet requests of the received download threads, data information of the data to be downloaded can be obtained from the data packet requests, such as the file to which the data to be downloaded belongs, the data offset of the file to which it belongs, and the data packet size. A preset memory data index table is used to record the indexes of the existing data in the shared memory. Data query is performed according to the data information of the data to be downloaded and the preset memory data index table. In the scenario of parallel flashing of multiple terminal devices, if the data to be downloaded is queried from the shared memory through the memory data index table, the data to be downloaded is directly returned to the corresponding download thread. Only when the data to be downloaded cannot be queried from the shared memory, the data of the file to be downloaded is written into the free memory of the shared memory according to the actually read data volume at one time. Since the memory data index table is updated after writing into the shared memory, when the data requested by the subsequent download threads belongs to the data of the file to be downloaded, it is expected to directly obtain the data from the shared memory without performing read and write operations on the data to be downloaded. It realizes the sharing of the data to be downloaded by multiple download threads, without the need to perform frequent read and write operations on the data to be downloaded for each download thread respectively, improves the utilization rate of memory and the scheduling efficiency of the system, and thus can improve the flashing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a flowchart of a data processing method in flashing in an embodiment of the present invention;
[0020] Figure 2 is a schematic diagram of the mapping mechanism between a memory data index table and memory blocks in an embodiment of the present invention;
[0021] Figure 3 is a flowchart of a calculation method for the actually read data volume at one time in an embodiment of the present invention;
[0022] Figure 4 is a flowchart of a data processing method in flashing in a typical scenario in an embodiment of the present invention;
[0023] Figure 5 is a schematic structural diagram of a data processing device in flashing in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0024] As described above, the one-to-many flashing tool performs parallel flashing of multiple terminal devices through multiple download threads. Among them, one-to-many means that one computer (PC) is connected to multiple terminal devices simultaneously for flashing operations. Each download thread has independent memory resources. The file data is read into the memory in the order of the downloaded files (Image and / or Bin files, etc.), and then the data packets are downloaded to the device according to the transmission capacity. For example, when 10 devices are flashed in parallel and 100M of memory is allocated for each thread, a total of 1G of memory will be occupied. In the case of a large number of terminal devices, that is, a large number of concurrent operations, it will cause the operating system memory resources of the computer to be occupied more or even fully occupied, resulting in a decrease in system scheduling efficiency. If the memory allocation size of each download thread is reduced or not allocated, it will lead to frequent reading and writing of Image and Bin files, and then the data is downloaded to the terminal device side in packets, resulting in a lower download rate. In summary, the flashing efficiency of the existing flashing method is relatively low.
[0025] To solve the above problems, in the embodiments of the present invention, according to the data packet request of the received download thread, the data information of the data to be downloaded can be obtained from the data packet request, such as the file to which the data to be downloaded belongs, the data offset of the file to which it belongs, and the data packet size. The preset memory data index table is used to record the indexes of the existing data in the shared memory. Data query is performed according to the data information of the data to be downloaded and the preset memory data index table. In the scenario of parallel flashing of multiple terminal devices, if the data to be downloaded is queried from the shared memory through the memory data index table, the data to be downloaded is directly returned to the corresponding download thread. Only when the data to be downloaded is not found in the shared memory, the data of the file to be downloaded is written into the free memory of the shared memory according to the actual amount of data read at one time. Since the memory data index table is updated after writing into the shared memory, when the data requested by the subsequent download thread belongs to the data of the file to be downloaded, it is expected to directly obtain the data from the shared memory without performing the reading and writing of the data to be downloaded. Multiple download threads share the data to be downloaded, without the need to perform frequent reading and writing of the data to be downloaded for each download thread separately, improving the utilization rate of memory and the system scheduling efficiency, and thus improving the flashing efficiency.
[0026] To make the above objects, features, and beneficial effects of the embodiments of the present invention more obvious and understandable, the following detailed description of the specific embodiments of the present invention will be given with reference to the accompanying drawings.
[0027] The embodiments of the present invention provide a data processing method in flashing. The data processing method in flashing can be executed by a terminal, or by a chip or chip module with the data processing function in the terminal, or by the baseband chip in the terminal.
[0028] Specifically, refer to Figure 1, a flowchart of a data processing method during flashing in an embodiment of the present invention is given, which may specifically include the following steps:
[0029] Step 11, receive a data packet request from a download thread, where the data packet request includes: a download thread identifier and data information of the data to be downloaded.
[0030] The data information of the data to be downloaded includes: the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data packet size, where the data offset of the belonging file is used to indicate the position of the data to be downloaded in the belonging file.
[0031] Step 12, perform data query according to the data information of the data to be downloaded and a preset memory data index table, where the memory data index table is used to record the indexes of the existing data in the shared memory.
[0032] Step 13, if the data to be downloaded is queried from the shared memory, return the data to be downloaded to the corresponding download thread according to the download thread identifier.
[0033] Step 14, if the data to be downloaded is not queried from the shared memory, write the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time, update the memory data index table, and return the data to be downloaded to the corresponding download thread according to the download thread identifier, where the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data volume read at one time.
[0034] In the specific implementation of step 11, when receiving data packet requests from multiple download threads, they can be processed in the order of reception according to the reception time of the data packet requests.
[0035] In the specific implementation of step 12, data query can be performed from the preset memory data index table according to the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data packet size in the data information of the data to be downloaded.
[0036] In some non-limiting embodiments, the memory data index table includes the following parameters: file identifier, total data volume of the file, memory block index corresponding to the file, file data offset, actual data volume read at one time, memory block start address pointer, and the number of download threads used.
[0037] The file identifier is used to identify different files.
[0038] The total data volume (totalSize) of the file can be used to represent the total size of the file.
[0039] The memory block index corresponding to a file can be used to indicate the memory block where the file is stored. A file can be stored in one memory block or multiple memory blocks. The number of memory blocks corresponding to a file is specifically determined according to the total data volume of the file and the actual data volume read at a time (i.e., the capacity of the memory block actually allocated each time). Each memory block can correspond to an index. When a file corresponds to one memory block, the index of the memory block corresponding to the file is one. When a file corresponds to multiple memory blocks, the indexes of the memory blocks corresponding to the file are multiple.
[0040] The file data offset (readOffset) can be used to indicate the offset position of the currently read data segment in a certain file. Its value is 0 when the file is read for the first time, and for subsequent reads, it is the previous file data offset (readOffset) plus the capacity of a memory block (readSize), where the capacity of the memory block is used to represent the size of the memory block and can also be referred to as the memory block size.
[0041] The memory block start address pointer (pointer) can be the memory address of a variable. A pointer variable is a variable used to store the address of a variable. The address of memory is the address of a memory unit. To facilitate memory management, each storage unit (a storage space that can store one byte) has a unique number starting from 0. The address of a variable: Depending on the type of the variable, the system will allocate a certain number of bytes of storage space for it. For a memory block, the address of the first storage unit of the allocated memory block is the address of the memory block.
[0042] The number of download threads used (threadCount) can refer to the number of download threads used for the data of each memory block. The number of download threads used for the data of each memory block is defaulted to 0. When a certain download thread first uses this memory block, the value of the thread usage count is incremented by 1. When a certain download thread no longer uses this data block, the value of the download thread usage count is decremented by 1. For example, for a certain memory block, when no download thread uses the data of this memory block, the number of download threads used for this memory block is 0. If five download threads use this memory block, the number of download threads used for the memory block is 5.
[0043] Refer to Figure 2 , which gives a schematic diagram of the mapping mechanism between a memory data index table and memory blocks in an embodiment of the present invention. Figure 2The in-memory data index table includes file identifiers, where file identifier file1 is used to identify File 1, and file identifier file2 is used to identify File 2. The total data volume of File 1 is totalSize. File 1 corresponds to memory block 1 and memory block 2, that is, the data of File 1 is stored in memory block 1 and memory block 2, where the memory block index of memory block 1 is key1_1, and the memory block index of memory block 2 is key1_2. File 2 corresponds to memory block 3, that is, the data of File 2 is stored in memory block 3, and the memory block index of memory block 3 is key2_1. In addition, for each memory block, there are the following parameters: file data offset ( Figure 2 represented by the field readOffset in Figure 2 ), the actual amount of data read at one time ( Figure 2 represented by the field readSize in Figure 2 ), the memory block start address pointer (
[0044] represented by the field pointer in Figure 3 ), and the number of download threads used (
[0045] represented by the field threadCount in
[0046] ). In some non-limiting embodiments, regarding the actual amount of data read at one time, it can be obtained in the following manner. The following will be described in conjunction with Figure 3 the flowchart of a calculation method for the actual amount of data read at one time in the embodiments of the present invention given below, which specifically may include the following steps:
[0045] Step 31, calculate the estimated capacity of the memory block according to the maximum memory usage threshold of the shared memory, the used memory of the shared memory, the minimum data read threshold, and the maximum memory allocation threshold of the memory block.
[0046] In specific implementation, the minimum data read threshold (minReadSizeThreshold) may refer to the minimum value of the data read from a certain file. The minimum data read threshold may affect the file read frequency. If the minimum data read threshold is small, it may increase the file read frequency and may also cause the data fragments to be stored too scattered, affecting the download rate.
[0047] In some non-limiting embodiments, the minimum data read threshold can be configured as the size of the data that can be transmitted in one read within the first duration. For example, the minimum data read threshold is the size of the data that can be transmitted in one read for 5s. Another example is that the minimum data read threshold is the size of the data that can be transmitted in one read for 7s. It can be understood that the first duration can also take other values, which are specifically set according to the maximum memory usage threshold of the actual shared memory, the number of devices to be flashed, etc., and are not limited here.
[0048] The maximum memory allocation threshold (maxMemBlockSize) of a memory block refers to the maximum allocation size of a memory block. The maximum memory allocation threshold of a memory block is less than the maximum memory usage threshold of the shared memory. The maximum memory allocation threshold of the memory block can be configured according to actual needs. When the concurrency of the download threads is relatively high, multiple memory blocks can be allocated. In this case, the capacity of the memory block can be smaller. When the concurrency is small, a small number of memory blocks can be allocated, and the capacity of the memory block can be larger to improve the utilization efficiency of the memory and flexibly adapt to the concurrent requirements of the download threads in different scenarios.
[0049] Among them, the maximum memory allocation threshold of the memory block is greater than or equal to the minimum data reading threshold.
[0050] As a non-limiting embodiment, the maximum memory allocation threshold of the large and small memory blocks is set to a multiple of the minimum data reading threshold (minReadSizeThreshold). In this way, while facilitating data storage, the utilization rate of the memory space can be improved.
[0051] The maximum memory usage threshold (maxMemUsedThreshold) of the shared memory is used to limit the maximum memory usage threshold and limit the total size of all memory blocks added together. By configuring the maximum memory usage threshold of the shared memory, it is possible to limit the occupation of too much memory and affect the operating system scheduling.
[0052] As a non-limiting embodiment, the size of the maximum memory usage threshold of the shared memory can be set to a multiple of the maximum memory allocation threshold of the memory block. Further, the multiple is an integer multiple.
[0053] As another non-limiting embodiment, the size of the maximum memory usage threshold of the shared memory can be set to a multiple of the minimum data reading threshold. Further, the multiple is an integer multiple.
[0054] In a specific implementation, the maximum floating capacity of the memory block can be calculated according to the maximum memory allocation threshold of the memory block and the minimum data reading threshold. The utilization rate of the shared memory can be calculated according to the used memory of the shared memory and the maximum memory usage threshold of the shared memory. The estimated floating capacity of the memory block can be calculated according to the maximum floating capacity of the memory block and the utilization rate of the shared memory. The estimated capacity of the memory block can be obtained according to the maximum memory allocation threshold of the memory block and the estimated floating capacity of the memory block.
[0055] In some non-limiting embodiments, the difference between the maximum memory allocation threshold of the memory block and the minimum data reading threshold is calculated, and the obtained difference value is used as the maximum floating capacity of the memory block.
[0056] In some non - restrictive embodiments, the ratio of the used memory of the shared memory to the maximum memory usage threshold of the shared memory is used as the utilization rate of the shared memory.
[0057] In some non - restrictive embodiments, the product of the maximum floating capacity of the memory block and the utilization rate of the shared memory is used as the estimated floating capacity of the memory block.
[0058] Furthermore, pre - process the estimated floating capacity of the memory block. The pre - processing can be any one of the following: rounding processing, rounding off processing, or taking the decimal places at the specified position, etc.
[0059] In some non - restrictive embodiments, the difference between the maximum memory allocation threshold of the memory block and the estimated floating capacity of the memory block is used as the estimated capacity of the memory block.
[0060] For example, the estimated capacity of the memory block can be calculated using the following formulas (1) and (2):
[0061] F(x)=maxMemblockSize - ROUND(ΔSize,y); (1)
[0062]
[0063] Wherein, F(x) is the estimated capacity of the memory block; maxMemblockSize is the maximum memory allocation threshold of the memory block; ROUND(ΔSize,y) is to round ΔSize according to the specified significant digit y; ΔSize is the estimated floating capacity of the memory block; minReadSizeThreshold is the minimum data read threshold; maxMemUsedThreshold is the maximum memory usage threshold of the shared memory; x is the used memory of the shared memory.
[0064] The value of y is set according to the specified significant digit. For example, when y = - 1, round and round off to the tens place, that is, dynamically adjust in multiples of 10M.
[0065] The estimated capacity of the memory block determined by the above method can dynamically adjust the actual amount of data read at one time, that is, dynamically adjust the capacity of the memory block allocated each time. Furthermore, it helps to increase the number of concurrent download threads by reading less data and writing it into the memory block. Although it will cause the file reading frequency to increase, due to the constraint of the minimum data read threshold, the overall impact on the download rate is small, and a relatively high download efficiency can still be maintained.
[0066] Step 32, determine the remaining unread data volume of the file to which the data to be downloaded belongs according to the total data volume of the file to which the data to be downloaded belongs and the data offset of the file to which the data belongs.
[0067] Specifically, the remaining unread data volume of the file to which the data to be downloaded belongs can be obtained by subtracting the data offset of the file to which it belongs from the total data volume of the file to which the data to be downloaded belongs.
[0068] For example, if the total data volume of the file to which the data to be downloaded belongs is 300 megabytes (M), and the data offset of the file to which it belongs is 200M, then the remaining unread data volume of the file to which it belongs is 100M.
[0069] Step 33: Take the minimum value between the estimated capacity of the memory block and the remaining unread data volume of the file to which it belongs as the actual amount of data read at one time.
[0070] The actual amount of data read at one time is determined using the following formula (3).
[0071] readSize = min((totalSize - readOffset), F(x)); (3)
[0072] Where readSize is the actual amount of data read at one time; min() is to take the minimum value; F(x) is the estimated capacity of the memory block; (totalSize - readOffset) is the remaining unread data volume of the file to which it belongs, totalSize is the total data volume of the file to which the data to be downloaded belongs, and readOffset is the data offset of the file to which it belongs.
[0073] Regarding writing the data of the file to be downloaded into the free memory of the shared memory according to the actual amount of data read at one time in step 14 above, there are various implementation manners, which may vary according to the memory usage situation in the current shared memory and the actual amount of data read at one time. The following is a detailed description.
[0074] In some embodiments, according to the actual amount of data read at one time and the memory already allocated in the shared memory, it is determined whether a new memory block can be allocated; if a new memory block can be allocated, a new memory block is allocated according to the actual amount of data read at one time, and the capacity of the new memory block is equal to the actual amount of data read at one time; the data of the file to be downloaded is written into the new memory block.
[0075] Among them, at least the following two methods can be used to determine whether a new memory block can be allocated:
[0076] Method 1: Determine whether the sum of the actually read data volume at one time and the memory already allocated in the shared memory is greater than the maximum memory usage threshold of the shared memory. If the sum of the actually read data volume at one time and the memory already allocated in the shared memory is not greater than the maximum memory usage threshold of the shared memory, it is determined that a new memory block can be allocated. Correspondingly, if the sum of the actually read data volume at one time and the memory already allocated in the shared memory is greater than the maximum memory usage threshold of the shared memory, it is determined that a new memory block cannot be allocated.
[0077] Method 2: Whether the actually read data volume at one time is less than or equal to the remaining memory of the shared memory. Wherein, the difference between the maximum memory usage threshold of the shared memory and the memory already allocated in the shared memory is the remaining memory of the shared memory. If the actually read data volume at one time is less than or equal to the remaining memory of the shared memory, it is determined that a new memory block can be allocated. Correspondingly, if the actually read data volume at one time is greater than the remaining memory of the shared memory, it is determined that a new memory block cannot be allocated.
[0078] Allocate a new memory block according to the actually read data volume at one time. The data of the file to be downloaded can be read from a local or remote server, and the read data of the file to be downloaded is written into the new memory block.
[0079] In some other embodiments, when writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time in the above step 14, if a new memory block cannot be allocated, determine whether there is a memory block in the shared memory that meets the reset condition.
[0080] Among them, the reset condition includes: the data of the memory block is not currently used by the download thread, and the capacity of the memory block is greater than or equal to the actually read data volume at one time; reset the memory block that meets the reset condition, update the memory data index table, and use the reset memory block as the free memory block; write the data of the file to be downloaded into the free memory block. Among them, after the memory block is reset, the data stored on the memory block is cleared.
[0081] When there is one memory block that meets the reset condition, reset this memory block that meets the reset condition.
[0082] When there are multiple memory blocks that meet the reset condition, all the memory blocks that meet the reset condition can be reset; or one can be selected from the multiple memory blocks that meet the reset condition for reset.
[0083] When selecting one of multiple memory blocks that meet the reset condition for reset, one can be randomly selected for reset. One can also select the memory block with the smallest capacity among the memory blocks that meet the reset condition, which can improve memory utilization. It is also possible to obtain the data download progress of all download threads; based on the data download progress of all the download threads, estimate the expected usage time of the data in all the memory blocks that meet the reset condition; select the memory block with the latest expected usage time for reset. The probability of the data in the memory block with an earlier time being downloaded is relatively high. By resetting the memory block with the latest usage time, the utilization rate of the memory block with an earlier time can be increased. To further improve memory utilization and data download efficiency.
[0084] Further, if the capacity of the reset memory block is greater than the actual amount of data read at one time, configure the memory data usage status information of the memory block. The memory data usage status information of the memory block is used to record the remaining capacity and the allocated capacity of the reset memory block.
[0085] In some other embodiments, if there are no memory blocks that meet the reset condition, select one or more memory blocks not used by the download threads and release them, and update the memory data index table. The free memory obtained after the release is greater than or equal to the actual amount of data read at one time; allocate a new memory block from the free memory as the free memory block according to the actual amount of data read at one time, and write the data of the file to be downloaded into the free memory block.
[0086] Determine the released memory block according to the actual amount of data read at one time and the capacity of the memory blocks not used by the download threads. For example, select one of the memory blocks not used by the download threads and with a capacity greater than the actual amount of data read at one time for release. Another example is to select two or more of the memory blocks not used by the download threads and with a capacity less than the actual amount of data read at one time for release to meet the requirement that the released memory is greater than or equal to the actual amount of data read at one time.
[0087] In some non-limiting embodiments, one or more memory blocks not used by the download threads can be selected and released in the following manner. Specifically, obtain the data download progress of all download threads; based on the data download progress of all the download threads, estimate the expected usage time of the data in the memory blocks not used by the download threads; select the memory blocks for release according to the actual amount of data read at one time and the expected usage time.
[0088] When flashing the machine, since the one - to - many mainly targets the same product device, the downloaded files and their order are the same. Even if there are differences in individual files, the above - mentioned data packet acquisition methods are the same. Therefore, whether there are fewer or more download threads starting and executing simultaneously, the number of allocated memory blocks is basically the same. Based on the above situation, it is possible to estimate the expected usage time of the data in the memory blocks not used by the undownloaded threads according to the data download progress of all download threads. Furthermore, according to the actual amount of data read at one time and the expected usage time, the memory blocks to be released can be selected, which can improve the rationality of the selection of the released memory blocks, thus helping to improve the memory utilization rate and download efficiency.
[0089] As a non - restrictive embodiment, the memory blocks with relatively later expected usage time are selected for release according to the actual amount of data read at one time.
[0090] Regarding the specific method of updating the memory data index table in step 14, it can be as follows: Write the data of the file to be downloaded into the free memory of the shared memory according to the actual amount of data read at one time. The free memory where the data is written is used as the newly allocated memory block. Configure an index for the new memory block in the memory data index table, and update the actual amount of data read at one time (i.e., capacity), file data offset, memory block index corresponding to the file, memory block start address pointer, and the number of download threads using the new memory block, etc.
[0091] For the sake of easy understanding, the update of the memory data index table is described below.
[0092] Example 1:
[0093] In Example 1, take the maximum memory allocation threshold of the memory block maxMemBlockSize = 100M, the minimum data read threshold minReadSizeThreshold = 100M, the maximum memory usage threshold of the shared memory maxMemUsedThreshold = 300M, the files to be downloaded during flashing are file 1 (file1) and file 2 (file2), where the total data volume of the file to which the data to be downloaded of file 1 belongs file1 totalSize = 310M, and the total data volume of the file to which the data to be downloaded of file 2 belongs file2 totalSize = 30M as an example for illustration.
[0094] 1) When the data packet request of the download thread is received for the first time, the allocated memory x in the shared memory is 0M at this time. Using the above formulas (1) and (2), the estimated capacity F(x) of the memory block is calculated to be 100M. The remaining unread data volume of File 1 is 310M, and the actually read data volume at one time is 100M. The size of Memory Block 1 is allocated as 100M. Memory Block 1 is used to store the data with a file data offset of 100M of File 1. The updated index table is shown in Table 1.
[0095] Table 1
[0096] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M
[0097] 2) After the data in Memory Block 1 is sent, when a new data packet is applied for, it needs to be read from the file again. At this time, x = 100M. Using the above formulas (1), (2), and (3), the estimated capacity F(x) of the memory block is calculated to be 100M. The remaining unread data volume of File 1 is 210M, and the actually read data volume at one time is 100M. Since the sum of the allocated memory in the shared memory and the actually read data volume at one time is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory, a new Memory Block 2 is allocated. The size of Memory Block 2 is 100M, and the data stored in Memory Block 2 is the data with a file data offset of 100M of File 1. The updated memory data index table is shown in Table 2.
[0098] Table 2
[0099] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M 2 file1 310M 100M 100M Points to memory block 2, with a memory block size of 100M
[0100] 3) After the data in Memory Block 2 is sent, when a new data packet is applied for, it needs to be read from the file again. At this time, x = 200M. Using the above formulas (1), (2), and (3), the estimated capacity F(x) of the memory block is calculated to be 100M. The remaining unread data volume of File 1 is 110M, and the actually read data volume at one time is 100M. Since the sum of the allocated memory in the shared memory and the actually read data volume at one time is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory, a new Memory Block 3 is allocated. The size of Memory Block 3 is 100M, and the data stored in Memory Block 3 is the data with a file data offset of 200M of File 1. The updated memory data index table is shown in Table 3.
[0101] Table 3
[0102] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M 2 file1 310M 100M 100M Points to memory block 2, with a memory block size of 100M 3 file1 310M 200M 100M Points to memory block 3, with a memory block size of 100M
[0103] 4) After the data transmission of memory block 3 is completed, when a new data packet is applied for, it is necessary to read from the file again. At this time, x = 300. Using the above formulas (1), (2), and (3), the estimated capacity F(x) of the memory block is calculated to be 100M. The remaining unread data volume of file 1 is 10M, and the actual one-time read data volume is 10M. Since the sum of the allocated memory in the shared memory and the actual one-time read data volume is greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory. It is necessary to reset / release the existing memory block first. Assume that memory block 1 is released. After releasing memory block 1, 100M of free memory is obtained. Allocate 10M of memory block from 100M as memory block 4, write 10M of data of the file to be downloaded into memory block 4, and update the memory data index table. The updated memory data index table is shown in Table 4.
[0104] Table 4
[0105] Serial number File data totalSize readOffset readSize Pointer 2 file1 310M 100M 100M Points to memory block 2, with a memory block size of 100M 3 file1 310M 200M 100M Points to memory block 3, with a memory block size of 100M 4 file1 310M 300M 10M Points to memory block 4, with a memory block size of 10M
[0106] 5) After the data transmission of memory block 4 is completed, when a new data packet is applied for, it is necessary to read from file 2 again. At this time, x = 210M. Using the above formulas (1), (2), and (3), the estimated capacity F(x) of the memory block is calculated to be 100M. The remaining unread data volume of file 2 is 30M, and the actual one-time read data volume is 30M. Since the sum of the allocated memory in the shared memory and the actual one-time read data volume is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory. Write 30M of data of the file to be downloaded into memory block 5, and update the memory data index table. The updated memory data index table is shown in Table 5.
[0107] Table 5
[0108] Serial number File data totalSize readOffset readSize Pointer 2 file1 310M 100M 100M Points to memory block 2, with a memory block size of 100M 3 file1 310M 200M 100M Points to memory block 3, with a memory block size of 100M 4 file1 310M 300M 10M Points to memory block 4, with a memory block size of 10M 5 file2 30M 0 30M Points to memory block 5, with a memory block size of 30M
[0109] Example 2:
[0110] In Example 2, taking the maximum memory allocation threshold maxMemBlockSize = 100M of the memory block, the minimum data read threshold minReadSizeThreshold = 50M, the maximum memory usage threshold maxMemUsedThreshold = 300M of the shared memory, the files to be downloaded during flashing are file 1 (file1) and file 2 (file2), where the total data volume file1 totalSize of the file to which the data to be downloaded in file 1 belongs is 310M, and the total data volume file2totalSize of the file to which the data to be downloaded in file 2 belongs is 30M as an example for illustration. The situation of the index table being updated in sequence:
[0111] 1) When the first data packet is applied for, the allocated memory x in the shared memory is 0M. Using formulas (1), (2), and (3), the actual amount of data read at one time is 100M. The size of memory block 1 is allocated as 100M. Memory block 1 is used to store the data with a file data offset of 100M of file 1. The updated index table is shown in Table VI.
[0112] Table VI
[0113] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M
[0114] 2) After the data in memory block 1 is sent, when a new data packet is applied for, it needs to be read from the file again. At this time, x = 100M. Using formulas (1), (2), and (3), the actual amount of data read at one time is calculated as 80M. Since the sum of the allocated memory in the shared memory and the actual amount of data read at one time is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory, a new memory block 2 is allocated. The size of memory block 2 is 80M. The data stored in memory block 2 is the data with a file data offset of 100M of file 1. The updated memory data index table is shown in Table VII.
[0115] Table VII
[0116] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M 2 file1 310M 100M 80M Points to memory block 2, with a memory block size of 80M
[0117] 3) After the data in memory block 2 is sent, when a new data packet is applied for, it needs to be read from the file again. At this time, x = 180M. Using the above formulas (1), (2), and (3), the actual amount of data read at one time is calculated as 70M. Since the sum of the allocated memory in the shared memory and the actual amount of data read at one time is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory, a new memory block 3 is allocated. The size of memory block 3 is 70M. The data stored in memory block 3 is the data with a file data offset of 180M of file 1. The updated memory data index table is shown in Table VIII.
[0118] Table VIII
[0119] Serial number File data totalSize readOffset readSize Pointer 1 file1 310M 0 100M Points to memory block 1, with a memory block size of 100M 2 file1 310M 100M 80M Points to memory block 2, with a memory block size of 80M 3 file1 310M 180M 70M Points to memory block 3, with a memory block size of 70M
[0120] 4) After the data transmission of memory block 3 is completed, when a new data packet is applied for, it is necessary to read from the file again. At this time, x = 250M. Using the above formulas (1), (2) and (3), the actually read data volume at one time is calculated to be 60M. Since the sum of the allocated memory in the shared memory and the actually read data volume at one time is greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory. It is necessary to reset / release the existing memory blocks first. Assume that memory block 1 is released. After releasing memory block 1, 100M of free memory is obtained. Allocate 60M of memory block from 100M as memory block 4, write 60M of data of the file to be downloaded into memory block 4, and update the memory data index table. The updated memory data index table is shown in Table IX.
[0121] Table IX
[0122] Serial number File data totalSize readOffset readSize Pointer 2 file1 310M 100M 80M Points to memory block 2, with a memory block size of 80M 3 file1 310M 180M 70M Points to memory block 3, with a memory block size of 70M 4 file1 310M 250M 60M Points to memory block 4, with a memory block size of 60M
[0123] 5) After the data transmission of memory block 4 is completed, when a new data packet is applied for, it is necessary to read from the file again. Here, the data of file 1 has been sent. It is necessary to send the data of file 2. File 2 is 30M. At this time, x = 210M. Using the above formulas (1), (2) and (3), the actually read data volume at one time is calculated to be 30M. Since the sum of the allocated memory in the shared memory and the actually read data volume at one time is not greater than the maximum memory usage threshold maxMemUsedThreshold of the shared memory. Allocate 60M of memory block as memory block 5, write 30M of data of the file to be downloaded into memory block 5, and update the memory data index table. The updated memory data index table is shown in Table X.
[0124] Table X
[0125] Serial number File data totalSize readOffset readSize Pointer 2 file1 310M 100M 80M Points to memory block 2, with a memory block size of 80M 3 file1 310M 180M 70M Points to memory block 3, with a memory block size of 70M 4 file1 310M 250M 60M Points to memory block 4, with a memory block size of 60M 5 file2 30M 0 30M Points to memory block 5, with a memory block size of 30M
[0126] Generally, each data packet request of the download thread requests one data packet. However, the data stored in the memory block is greater than one packet of data. The data stored in the memory block can be split into multiple data packets and can be used continuously for a period of time to avoid repeated reading and writing of the file. For example, 100M is read into the memory block at one time, and the maximum data packet sent by the download thread each time is 2M. The 100M data in the memory block can be split into 50 packets. If 5 packets of data can be sent per second, then the 100M data can be used continuously for 10s. It should be noted that the above examples of the size of the memory block, the size of the data packet, and the amount of data packets transmitted per second are only non-limiting examples for easy understanding. In practice, other values can exist, and the embodiments of the present invention do not make limitations in this regard.
[0127] As can be seen from the above solution, according to the data packet requests of the received download threads, the data information of the data to be downloaded can be obtained based on the data packet requests, such as the file to which the data to be downloaded belongs, the data offset of the file to which it belongs, and the data packet size. The preset memory data index table is used to record the indexes of the existing data in the shared memory. Data query is performed based on the data information of the data to be downloaded and the preset memory data index table. In the scenario of parallel flashing of multiple terminal devices, if the data to be downloaded is queried from the shared memory through the memory data index table, the data to be downloaded is directly returned to the corresponding download thread. Only when the data to be downloaded cannot be queried from the shared memory, the data of the file to be downloaded is written into the free memory of the shared memory according to the actual amount of data read at one time. Since the memory data index table is updated after writing into the shared memory, when the data requested by the subsequent download threads belongs to the data of the file to be downloaded, it is expected to directly obtain the data from the shared memory without performing the read and write of the data to be downloaded. It realizes that multiple download threads share the data to be downloaded, without the need to frequently read and write the data to be downloaded for each download thread respectively, improving the utilization rate of memory and the scheduling efficiency of the system, and thus can improve the flashing efficiency.
[0128] To enable those skilled in the art to better understand and implement the embodiments of the present invention, the following takes a typical application scenario as an example to illustrate the data processing method in flashing. Refer to Figure 4 and a flowchart of the data processing method in flashing in a typical scenario in the embodiments of the present invention is given, which specifically may include the following steps:
[0129] Step 401, receiving a data packet request of a download thread.
[0130] Step 402, determining whether the memory data index table successfully matches the data.
[0131] When performing data query based on the data information of the data to be downloaded and the preset memory data index table, if the data to be downloaded is queried from the shared memory, the judgment result is yes, that is, the memory data index table successfully matches the data, and step 403 is executed.
[0132] When performing data query based on the data information of the data to be downloaded and the preset memory data index table, if the data to be downloaded is not queried from the shared memory, the judgment result is no, that is, the memory data index table fails to match the data, and step 411 is executed.
[0133] Step 403, calculating the actual amount of data read at one time.
[0134] Regarding the specific implementation manner of step 403, reference can be made to Figures 1 to 3 and the description of the relevant parts in the above embodiments, which will not be elaborated here.
[0135] Step 404: Determine whether the sum of the actually read data volume at one time and the memory already allocated in the shared memory is greater than the maximum memory usage threshold of the shared memory.
[0136] If the judgment result is no, execute Step 405; if the judgment result is yes, execute Step 406.
[0137] Step 405: Allocate a new memory block.
[0138] Step 406: Determine whether there is a memory block that meets the reset condition.
[0139] If the judgment result is yes, execute Step 407; if the judgment result is no, execute Step 408.
[0140] Step 407: Reset the memory block that meets the reset condition.
[0141] In a specific implementation, the specific implementation manner of Step 407 can refer to the description of the memory block reset part in the above embodiment, and will not be elaborated here.
[0142] After Step 407 is executed, execute Step 409.
[0143] Step 408: Release the memory block.
[0144] In a specific implementation, the specific implementation manner of Step 408 can refer to the description of the memory block release part in the above embodiment, and will not be elaborated here.
[0145] After Step 408 is executed, execute Step 405.
[0146] Step 409: Write the data of the file to be downloaded into the idle memory block.
[0147] Step 410: Update the memory data index table.
[0148] Step 411: Return the data packet to the download thread.
[0149] The embodiment of the present invention also provides a data processing device during flashing. Refer to Figure 5 , and a structural schematic diagram of a data processing device during flashing in the embodiment of the present invention is given. The data processing device 50 during flashing may include:
[0150] A receiving unit 51, configured to receive a data packet request of a download thread, where the data packet request includes: a download thread identifier and data information of the data to be downloaded, and the data information of the data to be downloaded includes: the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data packet size, where the data offset of the belonging file is used to indicate the position of the data to be downloaded in the belonging file;
[0151] A query unit 52, configured to perform data query according to the data information of the data to be downloaded and a preset memory data index table, where the memory data index table is used to record the indexes of the existing data in the shared memory;
[0152] A data return unit 53, configured to return the data to be downloaded to the corresponding download thread according to the download thread identifier if the data to be downloaded is queried from the shared memory;
[0153] An update unit 54, configured to write the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time and update the memory data index table if the data to be downloaded is not queried from the shared memory. The data return unit 53 is configured to return the data to be downloaded to the corresponding download thread according to the download thread identifier, where the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data volume read at one time.
[0154] In a specific implementation, the specific working principle and working process of the data processing device 50 during flashing can be combined with Figures 1 to 4 the description in the data processing method during flashing provided in any of the above embodiments, and will not be elaborated here.
[0155] In a specific implementation, the above data processing device during flashing may correspond to a chip in the terminal with the data processing function during flashing, such as a SOC (System-On-a-Chip), a baseband chip, etc.; or correspond to a chip module in the terminal including a chip with the data processing function during flashing; or correspond to a chip module with a chip having a data processing function, or correspond to the terminal.
[0156] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the data processing method during flashing provided in any of the above embodiments of the present invention.
[0157] The computer-readable storage medium may include a non-volatile memory or a non-transitory memory, and may also include an optical disc, a mechanical hard disk, a solid-state drive, etc.
[0158] Specifically, in the embodiments of the present invention, the processor may be a central processing unit (CPU for short), and the processor may also be other general-purpose processors, digital signal processors (DSP for short), application specific integrated circuits (ASIC for short), field programmable gate arrays (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0159] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM for short), a programmable read-only memory (PROM for short), an erasable programmable read-only memory (EPROM for short), an electrically erasable programmable read-only memory (EEPROM for short), or a flash memory. The volatile memory may be a random access memory (RAM for short), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM for short) are available, such as static random access memory (SRAM for short), dynamic random access memory (DRAM), synchronous dynamic random access memory (Synchronous DRAM for short), double data rate synchronous dynamic random access memory (DDR SDRAM for short), enhanced synchronous dynamic random access memory (ESDRAM for short), synchlink dynamic random access memory (SLDRAM for short), and direct rambus random access memory (DR RAM for short).
[0160] The embodiments of the present invention also provide a terminal, including a memory and a processor. A computer program capable of running on the processor is stored on the memory. When the processor runs the computer program, it executes the steps of the data processing method in the flashing provided in any one of the above embodiments.
[0161] The memory and the processor are coupled. The memory can be located inside the terminal or outside the terminal. The memory and the processor can be connected through a communication bus.
[0162] The terminal can include, but is not limited to, terminal devices such as mobile phones, computers, and tablets, and can also be a server, a cloud platform, etc.
[0163] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer program can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer program can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner.
[0164] In several embodiments provided in the present application, it should be understood that the disclosed methods, devices, and systems can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for example, the division of the units is only a logical function division, and there can be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0165] In addition, in each embodiment of the present invention, each functional unit may be integrated into a processing unit, or each unit may be physically separate, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware, or in the form of a combination of hardware and software functional units. For example, for each device or product applied to or integrated into a chip, each module / unit included therein may be implemented in the form of hardware such as a circuit, or at least some of the modules / units may be implemented in the form of a software program that runs on a processor integrated inside the chip, and the remaining (if any) part of the modules / units may be implemented in the form of hardware such as a circuit; for each device or product applied to or integrated into a chip module, each module / unit included therein may be implemented in the form of hardware such as a circuit, and different modules / units may be located in the same component (such as a chip, a circuit module, etc.) or different components of the chip module, or at least some of the modules / units may be implemented in the form of a software program that runs on a processor integrated inside the chip module, and the remaining (if any) part of the modules / units may be implemented in the form of hardware such as a circuit; for each device or product applied to or integrated into a terminal, each module / unit included therein may be implemented in the form of hardware such as a circuit, and different modules / units may be located in the same component (such as a chip, a circuit module, etc.) or different components inside the terminal, or at least some of the modules / units may be implemented in the form of a software program that runs on a processor integrated inside the terminal, and the remaining (if any) part of the modules / units may be implemented in the form of hardware such as a circuit.
[0166] It should be understood that the term "and / or" in this article is merely a description of the association relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship.
[0167] The term "a plurality of" as used in the embodiments of this application refers to two or more.
[0168] The descriptions such as first, second, and third that appear in the embodiments of this application are only for schematic and differentiating the described objects, without an order, and do not represent a special limitation on the number of devices in the embodiments of this application, and cannot constitute any limitation on the embodiments of this application.
[0169] It should be noted that the serial numbers of the steps in this embodiment do not represent the limitation of the execution order of each step.
[0170] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A data processing method during flashing, characterized in that, Including: Receiving a data packet request of a download thread, the data packet request including: a download thread identifier and data information of data to be downloaded, the data information of the data to be downloaded including: the file to which the data to be downloaded belongs, the data offset of the belonging file, and the data packet size, wherein the data offset of the belonging file is used to indicate the position of the data to be downloaded in the belonging file; Performing data query according to the data information of the data to be downloaded and a preset memory data index table, the memory data index table being used to record indexes of existing data in the shared memory; If the data to be downloaded is queried from the shared memory, returning the data to be downloaded to the corresponding download thread according to the download thread identifier; If the data to be downloaded is not queried from the shared memory, writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data amount at one time, updating the memory data index table, and returning the data to be downloaded to the corresponding download thread according to the download thread identifier, wherein the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the data offset of the belonging file, and the actually read data amount at one time.
2. The data processing method in the flashing machine according to claim 1, characterized in that, The actually read data amount at one time is calculated in the following manner, including: Calculating the estimated capacity of a memory block according to the maximum memory usage threshold of the shared memory, the memory already used in the shared memory, the minimum data read threshold, and the maximum memory allocation threshold of the memory block; Determining the remaining unread data amount of the belonging file according to the total data amount of the file to which the data to be downloaded belongs and the data offset of the belonging file; Taking the minimum value between the estimated capacity of the memory block and the remaining unread data amount of the belonging file as the actually read data amount at one time.
3. The data processing method in flashing the machine according to claim 2, characterized in that, The writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data amount at one time includes: Judging whether a new memory block can be allocated according to the actually read data amount at one time and the memory already allocated in the shared memory; If a new memory block can be allocated, allocating a new memory block according to the actually read data amount at one time, the capacity of the new memory block being equal to the actually read data amount at one time; Writing the data of the file to be downloaded into the new memory block.
4. The data processing method in flashing the machine according to claim 3, characterized in that, The writing the data of the file to be downloaded into the free memory of the shared memory according to the actually read data amount at one time includes: If a new memory block cannot be allocated, judging whether there is a memory block in the shared memory that meets the reset condition, the reset condition including: the data of the memory block is not currently used by a download thread, and the capacity of the memory block is greater than or equal to the actually read data amount at one time; Resetting the memory block that meets the reset condition, updating the memory data index table, and using the reset memory block as a free memory block; Writing the data of the file to be downloaded into the free memory block.
5. The data processing method in flashing the machine according to claim 4, characterized in that, If the number of memory blocks that meet the reset condition is multiple, the resetting the memory blocks that meet the reset condition includes: Resetting all the memory blocks that meet the reset condition; Alternatively, select one of the memory blocks that meet the reset condition for resetting.
6. The data processing method in flashing the machine according to claim 5, wherein, The selecting one of the memory blocks that meet the reset condition for resetting includes: Obtain the data download progress of all download threads; Estimate the expected usage time of the data in all memory blocks that meet the reset condition according to the data download progress of all download threads; Select the memory block with the latest expected usage time for resetting.
7. The data processing method in flashing the machine according to claim 4, wherein The writing the data of the file to be downloaded into the idle memory block according to the actually read data volume at one time includes: If there is no memory block that meets the reset condition, select one or more memory blocks not used by the download threads and release them, and update the memory data index table, so that the free memory obtained after the release is greater than or equal to the actually read data volume at one time; Allocate a new memory block from the free memory as the idle memory block according to the actually read data volume at one time, and write the data of the file to be downloaded into the idle memory block.
8. The data processing method in flashing the machine according to claim 7, characterized in that, The selecting and releasing one or more memory blocks not used by the download threads includes: Obtain the data download progress of all download threads; Estimate the expected usage time of the data in the memory blocks not used by the download threads according to the data download progress of all download threads; Select and release memory blocks according to the actually read data volume at one time and the expected usage time.
9. The data processing method in flashing the machine according to claim 1, characterized in that, The memory data index table includes the following parameters: File identifier, total data volume of the file, file data offset, memory block index corresponding to the file, actually read data volume at one time, memory block start address pointer, and number of download threads used.
10. A data processing device during flashing, characterized in that, including: A receiving unit, configured to receive a data packet request of a download thread, where the data packet request includes: a download thread identifier and data information of the data to be downloaded, and the data information of the data to be downloaded includes: the file to which the data to be downloaded belongs, the file data offset to which it belongs, and the data packet size, where the file data offset is used to indicate the position of the data to be downloaded in the file to which it belongs; A query unit, configured to perform data query according to the data information of the data to be downloaded and a preset memory data index table, where the memory data index table is used to record the indexes of the existing data in the shared memory; A data return unit, configured to return the data to be downloaded to the corresponding download thread according to the download thread identifier if the data to be downloaded is queried from the shared memory; An update unit, configured to write the data of the file to be downloaded into the free memory of the shared memory according to the actually read data volume at one time if the data to be downloaded is not queried from the shared memory, update the memory data index table, and the data return unit is configured to return the data to be downloaded to the corresponding download thread according to the download thread identifier, where the data of the file to be downloaded is determined based on the file to which the data to be downloaded belongs, the file data offset to which it belongs, and the data volume read at one time.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run by a processor, it executes the steps of the data processing method in the flashing machine according to any one of claims 1 to 9.
12. A terminal, comprising a memory and a processor, wherein a computer program capable of running on the processor is stored on the memory, characterized in that, When the processor runs the computer program, it executes the steps of the data processing method in the flashing described in any one of claims 1 to 9.
Citation Information
Patent Citations
Mobile terminal and MEDOM chip and LINUX chip unified downloading method thereof
CN103905631A
File storage and downloading method and device and storage medium
CN109634916A