CN109344091B - Buffer array regulation method, device, terminal and readable medium - Google Patents

Buffer array regulation method, device, terminal and readable medium Download PDF

Info

Publication number
CN109344091B
CN109344091B CN201811147158.6A CN201811147158A CN109344091B CN 109344091 B CN109344091 B CN 109344091B CN 201811147158 A CN201811147158 A CN 201811147158A CN 109344091 B CN109344091 B CN 109344091B
Authority
CN
China
Prior art keywords
array
buffer
data information
queue
linked list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811147158.6A
Other languages
Chinese (zh)
Other versions
CN109344091A (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201811147158.6A priority Critical patent/CN109344091B/en
Publication of CN109344091A publication Critical patent/CN109344091A/en
Application granted granted Critical
Publication of CN109344091B publication Critical patent/CN109344091B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0806Multiuser, multiprocessor or multiprocessing cache systems
    • G06F12/0815Cache consistency protocols
    • G06F12/0817Cache consistency protocols using directory methods
    • G06F12/0824Distributed directories, e.g. linked lists of caches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a buffer array regulation method, a buffer array regulation device, a terminal and a readable medium, wherein the method comprises the following steps: scanning each cache queue in the cache queue group corresponding to the buffer array according to the received regular instruction, wherein the cache queue can store the data information updated in the buffer array each time; when the scanned data information is not empty, adding the data information into a predefined linked list object; when the scanning of each cache queue in the cache queue group is finished, acquiring data information in a linked list object and storing the data information in a temporary array; and when all the data information in the linked list object is stored into the temporary array, returning the data information of the temporary array to the buffer array. The buffer array arrangement method, the buffer array arrangement device, the terminal and the readable medium provided by the embodiment of the invention realize the arrangement of the buffer array, improve the arrangement efficiency of the buffer array and avoid data loss in the arrangement process.

Description

Buffer array regulation method, device, terminal and readable medium
Technical Field
The embodiment of the invention relates to computer technology, in particular to a buffer array regulation method, a buffer array regulation device, a terminal and a readable medium.
Background
In an Android terminal, a buffer area (e.g., a buffer array) of a data stream is often required to be opened up for buffering the data stream, and the buffer array is often required to be normalized so as to facilitate operations such as reading data in the data stream. The regularization processing can be understood as processing operation in which data is sequentially stored into an array according to the sequence of index sequence numbers of the array of 0, 1, 2. Currently, a common buffer array regulation method is to migrate data in an array one by one. The operation of transferring large amount of data one by one is long in time consumption and slow in speed, so that the buffer array arrangement efficiency is low. In addition, when the data in the buffer array is updated faster, the buffer array is not completely structured, and the original data is replaced by the new data, which results in the data loss phenomenon.
Disclosure of Invention
In view of this, embodiments of the present invention provide a buffer array normalization method, apparatus, terminal and readable medium, which implement buffer array normalization, improve buffer array normalization efficiency, and avoid data loss in the normalization process.
In a first aspect, an embodiment of the present invention provides a buffer array normalization method, including:
receiving a normalization instruction, and sequentially scanning each cache queue in a cache queue group corresponding to a buffer array according to the normalization instruction, wherein when data information in the buffer array is updated, the updated data information is migrated to the cache queue in the cache queue group;
when the scanned data information is not empty, adding the data information into a predefined linked list object, and emptying a buffer queue after scanning;
when scanning of each cache queue in the cache queue group is finished, sequentially acquiring data information in a linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array;
when all the data information in the linked list object is stored in the temporary array, the data information of the temporary array is transmitted back to the buffer array, and the data information of the temporary array is emptied when the data information transmission is finished.
Optionally, the sequentially scanning, according to the normalization instruction, each buffer queue in the buffer queue group corresponding to the buffer array includes:
acquiring information of each cache queue in a cache queue group corresponding to the buffer array according to the regular instruction;
and scanning each buffer queue in sequence according to the information of each buffer queue and the priority of each buffer queue.
Optionally, the buffer queue information includes a buffer queue head address and a queue length of the buffer queue;
correspondingly, the sequentially scanning each buffer queue according to the information of each buffer queue and the priority of each buffer queue includes:
determining the last address of each buffer queue according to the first address of each buffer queue and the queue length of each buffer queue;
and scanning the buffer queues from the first address to the last address in sequence according to the sequence of the priorities of the buffer queues from high to low.
Optionally, when the data information in the buffer array is updated, migrating the updated data information to a buffer queue in the buffer queue group, where the migrating includes:
when the data information in the buffer array is updated, determining a target buffer queue from the buffer queue which does not store the data information in the buffer array in the buffer queue group;
and storing the updated data information in the buffer array into a target buffer queue, and emptying the buffer array.
Optionally, adding the data information to a predefined linked list object when the scanned data information is not empty, where the adding includes:
acquiring data information obtained by scanning, and judging whether the data information is empty or not;
and when the data information is not empty, calling an adding method of the linked list object to add the data information into the linked list object.
Optionally, the sequentially obtaining the data information in the linked list object and storing the obtained data information in the linked list object in the temporary array includes:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object;
and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
Optionally, after the receiving the warping instruction, the method includes:
calling a chain table definition method to define a chain table object;
judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of each cache queue in the cache queue group is finished, if the temporary array is defined, sequentially acquiring the data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the buffer array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
In a second aspect, an embodiment of the present invention provides a buffer array arrangement apparatus, including:
the buffer queue scanning module is used for receiving a normalization instruction and sequentially scanning each buffer queue in a buffer queue group corresponding to the buffer array according to the normalization instruction, wherein when the data information in the buffer array is updated, the updated data information is migrated to the buffer queue in the buffer queue group;
the data adding module is used for adding the data information into a predefined linked list object and emptying a buffer queue after scanning when the scanned data information is not empty;
the data storage to temporary array module is used for sequentially acquiring data information in a linked list object when the scanning of each cache queue in the cache queue group is finished, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array;
and the data returning module is used for returning the data information of the temporary array to the buffer array when all the data information in the linked list object is stored in the temporary array, and emptying the data information of the temporary array when the data information returning is finished.
In a third aspect, an embodiment of the present invention provides a terminal, including:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a buffer array arrangement method as in any one of the embodiments of the invention.
In a fourth aspect, an embodiment of the present invention provides a readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a buffer array arrangement method according to any embodiment of the present invention.
According to the buffer array regulating method, the buffer array regulating device, the terminal and the readable medium, each buffer queue in a buffer queue group corresponding to a buffer array is scanned according to a received regulating instruction, wherein the buffer queue can store data information updated in the buffer array every time; when the scanned data information is not empty, adding the data information into a predefined linked list object; when the scanning of each cache queue in the cache queue group is finished, acquiring data information in a linked list object and storing the data information in a temporary array; and when all the data information in the linked list object is stored into the temporary array, returning the data information of the temporary array to the buffer array. Therefore, the buffer array is structured, the efficiency of structuring the buffer array is improved, and data loss in the structuring process is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of a buffer array normalization method according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a buffer array organizing device according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a terminal according to a third embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Fig. 1 is a flowchart of a buffer array arrangement method according to an embodiment of the present invention, where the embodiment is applicable to a buffer array arrangement situation, and the method may be implemented by a terminal, and may specifically be implemented by software and/or hardware in the terminal. Referring to fig. 1, the buffer array normalization method includes the following steps:
s110, receiving a normalization instruction, and sequentially scanning each cache queue in the cache queue group corresponding to the buffer array according to the normalization instruction, wherein when the data information in the buffer array is updated, the updated data information is migrated to the cache queue in the cache queue group.
The normalization command may be a command generated by a user by pressing a physical key of the terminal or a virtual key on a screen of the terminal. The normalization instruction may also be generated after the bottom-layer program automatically detects a trigger condition, for example, the normalization instruction may be generated by triggering when empty data exists between data stored in the buffer array, or the normalization instruction may be generated by triggering when data stored in the buffer array is detected but the initial position of the buffer array is empty.
Each buffer array can be provided with a buffer queue group corresponding to the buffer array, and the buffer queue group can comprise a plurality of buffer queues. The corresponding relationship between the buffer array group and the buffer queue group may be stored in a global variable, or may be stored in a text document, which is not specifically limited herein. The corresponding relationship between the buffer array group and the buffer queue group may include information such as the number of buffer queues in the buffer queue group corresponding to the buffer array, a storage address, and a queue length of the buffer queue. The number of the buffer queues included in the buffer queue group may be related to the average update rate of the data information in the buffer array, specifically, the higher the update rate is, the larger the number of the buffer queues is, so as to ensure that the data in the buffer array can be backed up to the buffer queue in time after being updated each time, and avoid loss of the updated information data. The length of each buffer queue in the buffer queue group may be the same or different, and preferably, the queue lengths may all be equal to the array length of the buffer array, so as to ensure that data information (including null information) in all storage spaces in the buffer array can be backed up to the buffer queue at one time.
Optionally, sequentially scanning each cache queue in the cache queue group corresponding to the buffer array according to the normalization instruction, including:
acquiring information of each cache queue in a cache queue group corresponding to the buffer array according to the regular instruction; and scanning each buffer queue in sequence according to the information of each buffer queue and the priority of each buffer queue.
The information of each cache queue in the cache queue group corresponding to the buffer array can be obtained by inquiring the corresponding relation between the buffer array and the cache queue group. The scanning of each buffer queue is performed in sequence, which can be understood as performing polling scanning on the buffer queues. In the polling loop structure, data information of one scanning position in the cache queue can be acquired every time the loop structure is circulated.
Optionally, the buffer queue information may include a buffer queue first address and a queue length of the buffer queue;
correspondingly, the method for scanning the buffer queues in sequence according to the information of the buffer queues and the priorities of the buffer queues comprises the following steps:
determining the last address of each buffer queue according to the first address of each buffer queue and the queue length of each buffer queue; and scanning the buffer queues from the first address to the last address in sequence according to the sequence of the priorities of the buffer queues from high to low.
The last address of each buffer queue can be obtained by adding the first address of each buffer queue to the queue length of each buffer queue. The buffer queue capable of storing the data information updated for the first time by the buffer array is marked as a buffer queue with a first priority, the buffer queue capable of storing the data information updated for the second time by the buffer array is marked as a buffer queue with a second priority, and so on, the earlier the buffer queue stores the data information in the updated buffer array, the higher the priority of the data information is. The first address to the last address of the buffer queue are scanned according to the sequence of the priorities from high to low, so that the scanning sequence can be ensured to be the sequence of updating the data information in the buffer array, and the ordering correctness of the data information in the buffer array after the ordering can be ensured.
Optionally, when the data information in the buffer array is updated, migrating the updated data information to a buffer queue in the buffer queue group, where the migrating includes:
when the data information in the buffer array is updated, determining a target buffer queue from the buffer queue which does not store the data information in the buffer array in the buffer queue group; and storing the updated data information in the buffer array into a target buffer queue, and emptying the buffer array.
When the buffer array is updated each time, the data information in the buffer array can be completely backed up to the buffer queue. In order to ensure that the updated information of each buffer array can be accurately acquired, the updated information of each buffer array can be stored in a new buffer queue. Therefore, when the data information in the buffer array is updated, which buffer queues do not store the data information in the buffer array are searched from the buffer queue group, and any one of the buffer queues which do not store the data information in the buffer array is selected as a target buffer queue, and the priority of the target buffer queue is marked. After the updated information in the buffer array is stored in the target buffer queue, the data information of the buffer array may be emptied by calling a byte-null method, where byte is a name of the buffer array and may represent the buffer array, and the name of the buffer array is not limited to byte. The garbage recoverer in the empty bottom program can automatically release the memory space of the empty buffer array, so that the effective use of memory resources is realized, and the regular data information is favorably transmitted back to the buffer array.
And S120, when the scanned data information is not empty, adding the data information into a predefined linked list object, and emptying the scanned buffer queue.
When the data information of the scanned buffer queue is not empty, the data information can be used as effective data information and added to the linked list object. When the polling scanning of each cache queue in the cache queue group is finished, all the effective data in the cache queue group can be added into the linked list object, and therefore the cleaning of the space data of the effective data information in the cache queue group is achieved. Because the data information in the buffer array group is the backup data information of the updated information in the buffer array every time, the work of primarily clearing the empty data regularly by the buffer array can be considered to be finished. When scanning of one buffer queue is finished, the data in the buffer queue can be emptied, so that storage of data information after next updating of the buffer array is facilitated.
Optionally, when the scanned data information is not empty, adding the data information to a predefined linked list object includes:
acquiring data information obtained by scanning, and judging whether the data information is empty or not; and when the data information is not empty, calling an adding method of the linked list object to add the data information into the linked list object.
The index sequence numbers of the 1 st, 2 nd and 3. n positions in the buffer queue are respectively 0, 1 st and 2. n-1, so that the index sequence numbers from the first address to the last address of the buffer queue are 0, 1 st and 2. size-1 in sequence; wherein the size may represent the queue length of each buffer queue. In the process of scanning the location from the location with index sequence number index ═ 0 to the location with index sequence number index ═ size-1 of the cache queue, the data information at the location corresponding to the index sequence number, that is, the data information at the scanning location, can be obtained by calling a cacheArray [ index ], where cacheArray is the name of the cache queue, and can represent the cache queue, and the name of the cache queue is not limited to cacheArray.
After the data information is acquired, whether the data information is empty or not may be determined by calling a method of "null | | | cacheArray [ index ] =", and a return value is true when the data information is empty and false when the data information is not empty. When the data is judged not to be empty, the data information can be added to the linked list object.
The method for adding the linked list object may specifically be:
linkList.add(cacheArray[index]);
the linkList is the name of the linked list object and can represent the linked list object, and the name of the linked list object is not limited to the linkList; wherein, cacheArray [ index ] can be added to linkList by add method. The data information is added to the linked list object by the add method, the insertion position of the linked list object is not required to be instructed during insertion, and the data information can be guaranteed to be stored in the storage unit pointed by the pointer of the previous storage unit of the linked list object every time during addition, so that the data information addition speed is high, the addition efficiency is high, and the array arrangement efficiency is improved.
S130, when scanning of each cache queue in the cache queue group is finished, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array.
When the scanning of each cache queue in the cache queue group is finished, all non-empty data information in the cache queue group is added to the linked list object, and when the memory space of the temporary array is successfully developed, the data in the linked list object can be transferred to the temporary array. The temporary array length is defined to be equal to the buffer array length so as to facilitate the data information to be transmitted back to the buffer array by the temporary array. The data information can be more efficiently transmitted back from the temporary array to the buffer array by the transmission back method among the arrays.
Optionally, the obtaining the data information in the linked list object in sequence, and storing the obtained data information in the linked list object into a temporary array includes:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object; and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
The method specifically includes the steps that a linkedlist.get (index1) method is called to obtain data information in a linked list object; the index1 may represent an index sequence number of the linked list object, and the data information at a position corresponding to the index sequence number may be obtained by calling the get method. After the data information at the position corresponding to the index sequence number of the linked list object is obtained, the data information can be assigned to a numerical variable, and the numerical variable is assigned to the temporary array, so that the data information in the linked list object can be stored in the temporary array. Illustratively, the storage of the data information in the linked list object into the temporary array is realized by assigning linkedlist.get (index1) to the variable item and storing the value variable to the position of the temporary array with the index sequence number of index2 by calling the method of tmpbyte [ index2] ═ item.
The acquired data information in the linked list object is assigned to the variable, and the value of the variable is added to the position in the corresponding index serial number of the temporary array, so that the data reading and adding operation is completed through one polling, and the data processing efficiency is improved.
And S140, when all the data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the buffer array, and emptying the data information of the temporary array when the data information is returned.
When all data in the linked list object are stored to the temporary array, the data information of the temporary array can be transmitted back to the buffer array by calling a byte-tmpbyte method, the temporary array can be completely copied to the buffer array, and the data information transmission between the data is completed. And emptying the temporary array after the data information of the buffer array is completely returned, so that the effective use of system memory resources can be realized.
Optionally, after receiving the warping instruction, the method includes:
calling a chain table definition method to define a chain table object; judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of each cache queue in the cache queue group is finished, if the temporary array is defined, sequentially acquiring the data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array; when the scanning of the buffer array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
The method for defining the linked list specifically may be:
LinkedList linkList=new LinkedList();
the linkList is the name of the linked list object and can represent the linked list object, and the name of the linked list object is not limited to the linkList; wherein, a linked list object of LinkedList type can be newly created by a new method.
Wherein, the remaining memory satisfies the requirement of defining the temporary array, including: the remaining memory has a continuous memory space of an array length equal to or greater than the temporary array.
When opening up the array memory space, the continuous storage unit with the array length of the defined array needs to be searched in the residual memory space, and the opening up of the array memory space can be carried out only when the continuous memory space with the array length being more than or equal to the array length exists in the residual memory, so that the definition of the array is realized. Therefore, after the data information of the buffer array is emptied, the time consumption for waiting for opening up the memory space of the temporary array is short, the probability of successfully defining the temporary array is high, the memory space opening up of the temporary array is easily realized, and the array arrangement efficiency can be improved.
Wherein a temporary array may be defined by calling private tmpbyte [1024 × 5] { } method; 1024 × 5 indicates that the size of the temporary array tmpbyte is 5M, the length of the temporary array is equal to the length of the buffer array, and the temporary array may be changed according to the length of the buffer array, and is not limited to 5M.
The temporary array may be defined after the normalization instruction is received, and when a continuous memory space with an array length greater than or equal to that of the temporary array exists in the remaining memory, the array definition method may be invoked to define the temporary array. When the scanning of the buffer array is finished, namely all non-empty data information of the buffer array is added to the linked list object, if the temporary array is defined, the opening up of the memory space is finished, the step of storing the data information in the linked list to the temporary array can be directly carried out, so that the time for defining the temporary array is saved, and the array arrangement efficiency is further improved; if the definition of the temporary array is not finished, namely the opening of the memory space is not finished, the array definition method is called to define the temporary array only when the remaining memory meets the requirement of defining the temporary array.
In the buffer array normalization method provided by this embodiment, each buffer queue in the buffer queue group corresponding to the buffer array is scanned according to the received normalization instruction, where the buffer queue can store data information updated in the buffer array each time, so as to avoid a situation that the data information in the buffer array is lost due to too fast update; when the scanned data information is not empty, adding the data information into a predefined linked list object; when the scanning of each cache queue in the cache queue group is finished, acquiring data information in a linked list object and storing the data information in a temporary array; and when all the data information in the linked list object is stored into the temporary array, returning the data information of the temporary array to the buffer array. Therefore, the buffer array is structured, the efficiency of structuring the buffer array is improved, and data loss in the structuring process is avoided.
Example two
Fig. 2 is a schematic structural diagram of a buffer array organizing device according to a second embodiment of the present invention, which is applicable to buffer array organizing in this embodiment.
Referring to fig. 2, the buffer array organizing apparatus in this embodiment includes:
the buffer queue scanning module 210 is configured to receive a normalization instruction, and sequentially scan each buffer queue in a buffer queue group corresponding to the buffer array according to the normalization instruction, where when data information in the buffer array is updated, the updated data information is migrated to the buffer queue in the buffer queue group;
a data adding to linked list object module 220, configured to add the data information to a predefined linked list object and empty the scanned buffer queue when the scanned data information is not empty;
the data storage to temporary array module 230, when the scanning of each cache queue in the cache queue group is finished, sequentially obtaining data information in the linked list object, and storing the obtained data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array;
the data returning module 240 returns the data information of the temporary array to the buffer array when all the data information in the linked list object is stored in the temporary array, and clears the data information of the temporary array when the data information returning is finished.
Optionally, the buffer queue scanning module 210 includes:
the queue information acquisition submodule is used for acquiring the information of each cache queue in the cache queue group corresponding to the buffer array according to the regular instruction;
and the buffer queue scanning submodule is used for scanning each buffer queue in sequence according to the information of each buffer queue and the priority of each buffer queue.
Further, the cache queue scanning submodule is specifically configured to:
determining the last address of each buffer queue according to the first address of each buffer queue and the queue length of each buffer queue;
and scanning the buffer queues from the first address to the last address in sequence according to the sequence of the priorities of the buffer queues from high to low.
Optionally, the buffer array arranging device further includes:
the target buffer queue determining module is used for determining a target buffer queue from the buffer queues which do not store the data information in the buffer array group when the data information in the buffer array is updated;
and the data storage to buffer queue module is used for storing the updated data information in the buffer array into the target buffer queue and emptying the buffer array.
Optionally, the data adding to linked list object module 220 includes:
the judging submodule is used for acquiring the data information obtained by scanning and judging whether the data information is empty or not;
and the data adding to linked list object submodule is used for calling a linked list object adding method to add the data information to the linked list object when the data information is not empty.
Optionally, the data is stored in the temporary array module 230, which includes:
the data information acquisition submodule is used for calling an acquisition method of the linked list object to sequentially acquire the data information in the linked list object;
and the data storage to temporary array submodule is used for calling an array storage method to store the acquired data information in the linked list object to a temporary array.
Optionally, the buffer array arranging device further includes:
the linked list object definition module is used for calling a linked list definition method to define linked list objects after receiving a normalization instruction;
the temporary array definition module is used for judging whether the residual memory meets the requirement of defining the temporary array and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, the data is stored in the temporary array module 230, which is specifically configured to:
when scanning of each cache queue in the cache queue group is finished, if the temporary array is defined, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the buffer array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
The buffer array organizing device provided in this embodiment is the same as the buffer array organizing method provided in the first embodiment, and the technical details not described in detail in this embodiment can be referred to in the first embodiment.
EXAMPLE III
The embodiment provides a terminal which can be used for buffering the condition of array regulation. Fig. 3 is a schematic structural diagram of a terminal according to a third embodiment of the present invention. Referring to fig. 3, the terminal includes:
one or more processors 310;
a memory 320 for storing one or more programs;
when executed by the one or more processors 310, cause the one or more processors 310 to implement a buffer array normalization method as set forth in one embodiment.
In FIG. 3, a processor 310 is illustrated as an example; the processor 310 and the memory 320 may be connected by a bus or other means, such as the bus connection shown in FIG. 3.
The memory 320 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the buffer array normalization method in the embodiment of the present invention. The processor 310 executes various functional applications of the terminal and data processing by executing software programs, instructions and modules stored in the memory 320, that is, implements the buffer array arrangement method described above.
The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 320 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 320 may further include memory located remotely from the processor 310, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The terminal proposed in this embodiment and the buffer array warping method proposed in the first embodiment belong to the same inventive concept, and the technical details that are not described in detail in this embodiment can be referred to in the first embodiment, and this embodiment and the first embodiment have the same beneficial effects.
Example four
The present embodiment provides a readable medium, on which a computer program is stored, which when executed by a processor implements the buffer array regularization method as set forth in one embodiment.
The readable medium proposed by the embodiment and the buffer array normalization method proposed by the first embodiment belong to the same inventive concept, and technical details not described in detail in the embodiment can be referred to in the first embodiment, and the first embodiment and the second embodiment have the same beneficial effects.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A buffer array normalization method, comprising:
receiving a normalization instruction, and sequentially scanning each cache queue in a cache queue group corresponding to a buffer array according to the normalization instruction, wherein when data information in the buffer array is updated, the updated data information is migrated to the cache queue in the cache queue group;
when the scanned data information is not empty, adding the data information into a predefined linked list object from a cache queue in a cache queue group, and emptying the scanned cache queue;
when scanning of each cache queue in the cache queue group is finished, sequentially acquiring data information in a linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array;
when all the data information in the linked list object is stored in the temporary array, the data information of the temporary array is transmitted back to the buffer array, and the data information of the temporary array is emptied when the data information transmission is finished.
2. The method as claimed in claim 1, wherein the sequentially scanning each buffer queue in the buffer queue group corresponding to the buffer array according to the normalization instruction comprises:
acquiring information of each cache queue in a cache queue group corresponding to the buffer array according to the regular instruction;
and scanning each buffer queue in sequence according to the information of each buffer queue and the priority of each buffer queue.
3. The method of claim 2, wherein the buffer queue information comprises a buffer queue head address and a queue length of a buffer queue;
correspondingly, the sequentially scanning each buffer queue according to the information of each buffer queue and the priority of each buffer queue includes:
determining the last address of each buffer queue according to the first address of each buffer queue and the queue length of each buffer queue;
and scanning the buffer queues from the first address to the last address in sequence according to the sequence of the priorities of the buffer queues from high to low.
4. The method of claim 1, wherein migrating the updated data information to a buffer queue in the buffer queue group when the data information in the buffer array is updated comprises:
when the data information in the buffer array is updated, determining a target buffer queue from the buffer queue which does not store the data information in the buffer array in the buffer queue group;
and storing the updated data information in the buffer array into a target buffer queue, and emptying the buffer array.
5. The method of claim 1, wherein adding the data information to a predefined linked list object when the scanned data information is not empty comprises:
acquiring data information obtained by scanning, and judging whether the data information is empty or not;
and when the data information is not empty, calling an adding method of the linked list object to add the data information into the linked list object.
6. The method according to claim 1, wherein the sequentially obtaining the data information in the linked list object and storing the obtained data information in the linked list object in a temporary array comprises:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object;
and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
7. The method of claim 1, after said receiving a warping instruction, comprising:
calling a chain table definition method to define a chain table object;
judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of each cache queue in the cache queue group is finished, if the temporary array is defined, sequentially acquiring the data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the buffer array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
8. A buffer array arranging device is characterized by comprising:
the buffer queue scanning module is used for receiving a normalization instruction and sequentially scanning each buffer queue in a buffer queue group corresponding to the buffer array according to the normalization instruction, wherein when the data information in the buffer array is updated, the updated data information is migrated to the buffer queue in the buffer queue group;
the data adding module is used for adding the data information into a predefined linked list object from a cache queue in a cache queue group and emptying the cache queue after scanning when the scanned data information is not empty;
the data storage to temporary array module is used for sequentially acquiring data information in a linked list object when the scanning of each cache queue in the cache queue group is finished, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the buffer array;
and the data returning module is used for returning the data information of the temporary array to the buffer array when all the data information in the linked list object is stored in the temporary array, and emptying the data information of the temporary array when the data information returning is finished.
9. A terminal, characterized in that the terminal comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the buffer array normalization method of any of claims 1-7.
10. A readable medium, on which a computer program is stored which, when being executed by a processor, carries out the buffer array regularization method as claimed in any one of claims 1 to 7.
CN201811147158.6A 2018-09-29 2018-09-29 Buffer array regulation method, device, terminal and readable medium Active CN109344091B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811147158.6A CN109344091B (en) 2018-09-29 2018-09-29 Buffer array regulation method, device, terminal and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811147158.6A CN109344091B (en) 2018-09-29 2018-09-29 Buffer array regulation method, device, terminal and readable medium

Publications (2)

Publication Number Publication Date
CN109344091A CN109344091A (en) 2019-02-15
CN109344091B true CN109344091B (en) 2021-03-12

Family

ID=65307366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811147158.6A Active CN109344091B (en) 2018-09-29 2018-09-29 Buffer array regulation method, device, terminal and readable medium

Country Status (1)

Country Link
CN (1) CN109344091B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621478A (en) * 2009-08-07 2010-01-06 中兴通讯股份有限公司 Method and device for array dispatch
CN103544110A (en) * 2013-10-08 2014-01-29 华中科技大学 Block-level continuous data protection method based on solid-state disc
CN104125168A (en) * 2013-04-27 2014-10-29 中兴通讯股份有限公司 A scheduling method and system for shared resources
CN106095587A (en) * 2016-06-24 2016-11-09 北京金山安全软件有限公司 Cache scanning method and device of application program and electronic equipment
US9900632B1 (en) * 2016-12-30 2018-02-20 Echostar Technologies L.L.C. Viewing suggestions based on closed-captioned content from multiple tuners

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8656494B2 (en) * 2012-02-28 2014-02-18 Kaspersky Lab, Zao System and method for optimization of antivirus processing of disk files
US9547604B2 (en) * 2012-09-14 2017-01-17 International Business Machines Corporation Deferred RE-MRU operations to reduce lock contention

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101621478A (en) * 2009-08-07 2010-01-06 中兴通讯股份有限公司 Method and device for array dispatch
CN104125168A (en) * 2013-04-27 2014-10-29 中兴通讯股份有限公司 A scheduling method and system for shared resources
CN103544110A (en) * 2013-10-08 2014-01-29 华中科技大学 Block-level continuous data protection method based on solid-state disc
CN106095587A (en) * 2016-06-24 2016-11-09 北京金山安全软件有限公司 Cache scanning method and device of application program and electronic equipment
US9900632B1 (en) * 2016-12-30 2018-02-20 Echostar Technologies L.L.C. Viewing suggestions based on closed-captioned content from multiple tuners

Also Published As

Publication number Publication date
CN109344091A (en) 2019-02-15

Similar Documents

Publication Publication Date Title
US20190026157A1 (en) Accelerator control apparatus, accelerator control method, and program
CN110427256B (en) Priority-based job scheduling optimization method, device, storage medium and apparatus
CN109597818A (en) Data-updating method, device, storage medium and equipment
CN102801737B (en) A kind of asynchronous network communication means and device
CN113485822A (en) Memory management method, system, client, server and storage medium
US10942777B2 (en) Sorting apparatus
CN111400005A (en) Data processing method and device and electronic equipment
CN108304272B (en) Data IO request processing method and device
CN110543359A (en) Task queue running device
CN111949389B (en) Slurm-based information acquisition method and device, server and computer-readable storage medium
CN108549534B (en) Graphical user interface redrawing method, terminal device and computer-readable storage medium
CN108415962A (en) A kind of cloud storage system
CN113031864A (en) Data processing method and device, electronic equipment and storage medium
KR100678930B1 (en) Real-time Control System for Digital Signal Processor
US20200252314A1 (en) Method and apparatus for managing network connection, and storage medium
US20180322075A1 (en) Method for processing client requests in a cluster system, a method and an apparatus for processing i/o according to the client requests
CN114218135A (en) Source end flow control method and system based on Redis cache
CN109819674B (en) Computer storage medium, embedded scheduling method and system
CN109344091B (en) Buffer array regulation method, device, terminal and readable medium
CN110308998B (en) Mass data sampling method and device
CN116089477B (en) Distributed training method and system
CN111831408A (en) Asynchronous task processing method and device, electronic equipment and medium
CN108595270B (en) Memory resource recovery method and device
JP2016509306A (en) System and method for supporting work sharing multiplexing in a cluster
CN112306827A (en) Log collection device, method and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant