CN113835891A - Resource allocation method, device, electronic equipment and computer readable storage medium - Google Patents

Resource allocation method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113835891A
CN113835891A CN202111123443.6A CN202111123443A CN113835891A CN 113835891 A CN113835891 A CN 113835891A CN 202111123443 A CN202111123443 A CN 202111123443A CN 113835891 A CN113835891 A CN 113835891A
Authority
CN
China
Prior art keywords
descriptor
data
chain table
endpoint
storage space
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.)
Granted
Application number
CN202111123443.6A
Other languages
Chinese (zh)
Other versions
CN113835891B (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.)
Zeku Technology Beijing Corp Ltd
Original Assignee
Zeku Technology Beijing Corp 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 Zeku Technology Beijing Corp Ltd filed Critical Zeku Technology Beijing Corp Ltd
Priority to CN202111123443.6A priority Critical patent/CN113835891B/en
Publication of CN113835891A publication Critical patent/CN113835891A/en
Application granted granted Critical
Publication of CN113835891B publication Critical patent/CN113835891B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The embodiment of the application discloses a resource allocation method, a resource allocation device, electronic equipment and a computer readable storage medium. The method comprises the following steps: generating a descriptor chain table from the received data descriptors according to a receiving frequency of the descriptor chain table generator receiving the data descriptors; storing the descriptor chain table into the storage space. The resource allocation method, the resource allocation device, the electronic equipment and the computer-readable storage medium can improve the condition that the system allocates unreasonable storage space for storing the descriptor linked list.

Description

Resource allocation method, device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a resource allocation method, an apparatus, an electronic device, and a computer-readable storage medium.
Background
USB (Universal Serial Bus) is a new data communication method, and has the advantages of high-speed transmission, convenient installation and configuration, and the like. Most electronic products on the market are provided with USB chips to support USB data transmission. In some USB data transmission mechanisms, in order to successfully transmit data, an electronic device may open up two memory spaces in a system memory, which are used for storing data to be transmitted and a descriptor for describing the data, respectively, and currently, there is a problem that it is not reasonable to allocate a storage space for storing the descriptor.
Disclosure of Invention
The embodiment of the application discloses a resource allocation method, a resource allocation device, electronic equipment and a computer-readable storage medium, which can improve the condition that the system allocates unreasonable storage space for storing descriptor linked lists.
The embodiment of the application discloses a resource allocation method, which comprises the following steps:
acquiring a storage space corresponding to a receiving frequency according to the receiving frequency of the data descriptors received by a descriptor chain table generator, wherein the descriptor chain table generator is used for generating a descriptor chain table according to the received data descriptors;
storing the descriptor chain table into the storage space.
The embodiment of the application discloses a resource allocation device, comprising:
the space acquisition module is used for acquiring a storage space corresponding to a receiving frequency according to the receiving frequency of the data descriptors received by the descriptor chain table generator, and the descriptor chain table generator is used for generating the descriptor chain table according to the received data descriptors;
a storage module for storing the descriptor chain table into the storage space.
The embodiment of the application discloses electronic equipment, includes:
a memory;
the descriptor linked list generator is used for acquiring a storage space corresponding to a receiving frequency of a received data descriptor from the storage according to the receiving frequency;
the descriptor chain table generator is also used for generating a descriptor chain table according to the received data descriptors and storing the descriptor chain table into the storage space.
The embodiment of the application discloses an electronic device, which comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor is enabled to realize the method.
An embodiment of the application discloses a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method as described above.
According to the resource allocation method, the device, the electronic equipment and the computer readable storage medium, the storage space corresponding to the receiving frequency is obtained according to the receiving frequency of the data descriptors received by the descriptor chain table generator, the descriptor chain table generator is used for generating the descriptor chain table according to the received data descriptors, and then the descriptor chain table is stored in the storage space.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a diagram illustrating an exemplary embodiment of a resource allocation method;
FIG. 2 is a block diagram of an electronic device in one embodiment;
FIG. 3 is a flow diagram of a method for resource allocation in one embodiment;
FIG. 4 is a diagram of a descriptor chain table in one embodiment;
FIG. 5 is a flow diagram of memory space retrieval based on the frequency of descriptor chain generator receiving data descriptors in one embodiment;
FIG. 6 is a flow chart of a resource allocation method in another embodiment;
FIG. 7 is a diagram of the analysis frequency of the descriptor chain table generator in one embodiment;
FIG. 8A is an architecture diagram of an electronic device in one embodiment;
FIG. 8B is a diagram illustrating the architecture of a frequency analyzer in one embodiment;
FIG. 9 is a block diagram of a resource allocation apparatus in one embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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 application.
It is to be noted that the terms "comprises" and "comprising" and any variations thereof in the examples and figures of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, a first frequency threshold may be referred to as a second frequency threshold, and similarly, a second frequency threshold may be referred to as a first frequency threshold, without departing from the scope of the present application. Both the first frequency threshold and the second frequency threshold are frequency thresholds, but they are not the same frequency threshold represented. The term "plurality", as used herein, refers to two or more.
Most electronic products on the market are provided with USB chips to support USB data transmission. In some USB data transmission mechanisms, in order to successfully transmit data, an electronic device sets two independent memory spaces in a system memory, where a first memory space is used to store data blocks to be transmitted, one or more data blocks may constitute a data packet, and a second memory space may store a data structure describing the data packet to be transmitted. The data structure is usually a chain structure, each data unit in the chain is placed in the memory in turn, each data unit is also called a data descriptor for describing the data blocks included in the data packet, and a data structure is called a descriptor chain table.
In order to increase the speed of creating the descriptor linked list, as one way, the electronic device may averagely divide the second memory space into a plurality of memory spaces, and store the descriptor linked list into the divided memory spaces after creating the descriptor linked list each time. Since the storage space is divided in an average manner, and the length of the descriptor chain table is not fixed, there may be problems of space waste caused by too large divided storage space, overlapping of the descriptor chain table caused by too small divided storage space, and the like, and there may be a problem that the storage space allocated for storing the descriptor is not reasonable.
The embodiment of the application provides a resource allocation method, a resource allocation device, an electronic device and a computer-readable storage medium, which can allocate a proper storage space according to the receiving frequency of a descriptor chain table generator for receiving a data descriptor, can avoid the problems of space waste caused by too large storage space or overlapping of stored descriptor chain tables caused by too small storage space, and the like, can improve the unreasonable condition of the storage space allocated by a system for storing the descriptor chain tables, improve the utilization rate of the storage space, and reduce the waste of the storage space.
Fig. 1 is a diagram illustrating an application scenario of a resource allocation method according to an embodiment. As shown in fig. 1, the electronic device 100 may establish a USB communication connection with the target device 200 through a USB interface, and perform data transmission with the target device 200 through USB. The electronic device 100 may include, but is not limited to, a mobile phone, a tablet Computer, a wearable device, a vehicle-mounted terminal, a Personal Computer (PC), and other devices supporting USB transmission, and the target device 200 may include, but is not limited to, a mobile phone, a tablet Computer, a keyboard, a mouse, a wearable device, and other devices supporting USB transmission, and the electronic device 100 and the target device 200 are not limited in this embodiment.
Fig. 2 is a block diagram of an electronic device in one embodiment. As shown in fig. 2, the electronic device 100 may include a processor 110, a memory 120, a descriptor chain table generator 130, and a USB module 140.
Processor 110 may include one or more processing cores. The processor 110 connects various parts within the overall electronic device 100 using various interfaces and lines, and performs various functions of the electronic device 100 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 120 and calling data stored in the memory 120. Alternatively, the processor 110 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 110 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 110, but may be implemented by a communication chip.
The Memory 120 may include a Random Access Memory (RAM), a Read-Only Memory (ROM), a Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), and the like. The memory 120 may be used to store instructions, programs, code sets, or instruction sets. The memory 720 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various functions in the electronic device 100, and the like. The storage data area may also store data created by the electronic device 100 in use, and the like.
The USB module 140 may include a USB chip supporting a USB communication function, and the USB module 140 may transmit data to a target device or receive data transmitted from the target device according to a control instruction issued by the processor 110, and the like. The USB module 140 may obtain data to be sent from the memory 120, package the data according to the USB protocol, and send the data to the target device. The USB module 140 may also receive a data packet sent by the target device, unpack the data packet according to the USB protocol, and send the unpacked data to the memory 120 for storage.
In some USB transmission mechanisms, before the USB module 140 sends a packet to the destination device, the descriptor chain table generator 130 generates a descriptor chain table corresponding to the packet, and the descriptor chain table can be used to describe the packet to be sent. In the embodiment of the present application, the processor 110 may open up two independent memory spaces in the memory 120 for storing the data to be transmitted and the descriptor chain table generated by the descriptor chain table generator 130. The processor 110 may divide the space opened up in the memory 120 for storing the descriptor chain table into at least two groups of memory spaces of different sizes, each group of memory spaces may include one or more divided memory spaces thereunder.
When the processor 110 writes data to be transmitted to the memory 120, the processor 110 may send a data descriptor corresponding to the written data to be transmitted to the descriptor linked list generator 130, where the data descriptor may be used to describe the written data to be transmitted. The descriptor chain table generator 130 may determine a receiving frequency of the received data descriptors and retrieve a memory space corresponding to the receiving frequency from the memory 120 according to the receiving frequency, and after the descriptor chain table generator 130 generates the descriptor chain table according to the data descriptors, the generated descriptor chain table may be stored in the retrieved memory space. Because the memory 120 is divided into at least two groups of memory spaces with different sizes, the descriptor chain table generator 130 can acquire the memory space with the space size suitable for the length of the descriptor chain table from the memory 120 according to the receiving frequency of the data descriptors, so that the problems of space waste caused by overlarge memory space or overlapping stored descriptor chain tables caused by undersize memory space and the like can be avoided, the condition that the memory space allocated by a system for storing the descriptor chain table is unreasonable can be improved, the utilization rate of the memory space is improved, and the memory space waste is reduced.
It should be noted that the electronic device 100 may include more or less structural elements than those shown in the above structural block diagrams, for example, a power module, a physical button, a WiFi (Wireless Fidelity) module, a speaker, a bluetooth module, a sensor, etc., and is not limited herein.
As shown in fig. 3, in one embodiment, a resource allocation method is provided, which can be applied to the electronic device described above, and the method can include, but is not limited to, the following steps:
step 310, according to the receiving frequency of the descriptor chain table generator receiving the data descriptor, obtaining the storage space corresponding to the receiving frequency, wherein the descriptor chain table generator is used for generating the descriptor chain table according to the received data descriptor.
When the electronic device needs to send data to the target device through the USB, one complete data can be decomposed into a plurality of data blocks, and each data block can be written into the memory as data to be sent, so that the USB module can conveniently read a plurality of data to be sent from the memory and pack the data to be sent, and a data packet to be sent is obtained.
When a processor in the electronic device writes data to be sent into a memory, a data descriptor for describing the data to be sent can be sent to the descriptor linked list generator. The descriptor chain table generator may generate a descriptor chain table according to the received data descriptors, the descriptor chain table may be used to describe a data packet to be transmitted, and a data packet may include data to be transmitted described by each data descriptor included in the corresponding descriptor chain table.
In some embodiments, the data descriptor may include a memory address and control information, the memory address may be a starting address of the data to be sent described by the data descriptor stored in the memory, and the control information may be used to characterize a length of the data to be sent described by the data descriptor, where the length may be represented by a number of bytes. For example, the data descriptor may include Address 0x0000 — 0000 and Length 4byte, which may indicate that the start Address of the data to be sent stored in the memory is 0x0000 — 0000, and the Length of the data to be sent is 4 bytes.
In one embodiment, the control information may include a data length and a connection control signal, where the data length is a length of data to be transmitted, and the connection control signal may be used to characterize a range of the data packet. When the connection control signal of any data descriptor in the descriptor chain table is a first identifier, the data descriptor is represented as the last data descriptor of the descriptor chain table, and the description of a data packet is completed; when the connection control signal of any data descriptor is the second identifier, the data descriptor is not the last data descriptor of the descriptor chain table, and the data descriptor is connected later.
Alternatively, the first identifier and the second identifier may be a character or a character string composed of one or more of numbers, letters, symbols, and the like, for example, but not limited to, the first identifier is 0, the second identifier is 1, and the like.
Illustratively, FIG. 4 is a diagram of a descriptor chain table in one embodiment. As shown in fig. 4, the descriptor chain table in fig. 4 may include a data descriptor 1 and a data descriptor 2, and each data descriptor may include a start address of the described data to be transmitted (i.e., a data block) in the memory, a length of the data to be transmitted, and a connection control signal (CHN). The starting address of the data to be sent described by the data descriptor 1 is 0x0000_0000, the length is 4 bytes, that is, the data stored in the corresponding memory address 0x0000_ 0000-0 x0000_0003, and CHN ═ 1 indicates that the data descriptor 1 is not the last data descriptor of the descriptor chain table; the data descriptor 2 describes that the start address of the data to be sent is 0x0000_0004, and the length is 4 bytes, that is, the data stored in the corresponding memory address 0x0000_ 0004-0 x0000_0007, and CHN ═ 0 indicates that the data descriptor 2 is the last data descriptor of the descriptor chain table. Through the descriptor linked list, the USB module can acquire the memory address of the data to be sent contained in the data packet, and reads the corresponding data to be sent from the memory for packaging.
In some embodiments, the data descriptor may further include status information, where the status information may be used to define information that needs to be returned by the USB module after the data descriptor is used up, that is, information that needs to be returned by the USB module after the USB module reads corresponding data to be sent from the memory according to the data descriptor. For example, after the USB module runs out of each data descriptor, the USB module may return response information to the processor, and if the processor receives response information corresponding to all data descriptors in the descriptor chain table returned by the USB module, the descriptor chain table may be deleted from the storage space, the storage space is released, and the storage space may be used for storing the descriptor chain table.
In an embodiment of the present application, the descriptor chain table generator may determine a receiving frequency of receiving the data descriptors, which may be a number of data descriptors received by the descriptor chain table generator per unit time. As an embodiment, the number of data descriptors received by the descriptor linked list generator within a preset time period (e.g., within 1 second, within 3 seconds, etc.) may be counted, and the receiving frequency may be determined, for example, if the descriptor linked list generator receives 5 data descriptors within 1 second, the receiving frequency may be 5/second.
As an embodiment, the descriptor chain table generator may record a time interval between each time a data descriptor is received and the last time the data descriptor is received, and calculate the reception frequency according to the time interval. For example, if the descriptor chain table generator has a time interval between receiving the data descriptor 1 and the data descriptor 2 of T1 and a time interval between receiving the data descriptor 2 and the data descriptor 3 of T2, the receiving frequency may be 2/(T1+ T2).
If the receiving frequency of the descriptor chain table generator receiving the data descriptor is high, it can be said that the data volume to be transmitted is large, and in order to improve the transmission efficiency of the data, the USB module can use a larger data packet for transmission, and the descriptor chain table generated by the descriptor chain table generator is also long, and the required storage space is also large. The descriptor link table generator has low receiving frequency of receiving the data descriptors, which can indicate that the data volume to be transmitted is small, and the USB module can transmit the data by using a small data packet, so that the descriptor link table generated by the descriptor link table generator is short and the required storage space is small.
Therefore, according to the receiving frequency of the descriptor chain table generator for receiving the data descriptors, the storage space corresponding to the receiving frequency can be obtained from the memory, and the size of the obtained storage space can be more adaptive to the generated descriptor chain table. When the receiving frequency is high and the generated descriptor linked list is long, the acquired storage space can be large, and when the receiving frequency is low and the generated descriptor linked list is short, the acquired storage space can be small, so that the utilization rate of the storage space is improved.
In step 320, the descriptor chain table is stored in the memory space.
The descriptor chain table generator can synthesize a descriptor chain table from a plurality of received data descriptors, wherein the length of the descriptor chain table is smaller than or equal to the size of the acquired storage space, and the problem of memory overlapping of the descriptor chain table (namely that the descriptor chain table occupies other storage space due to the fact that the descriptor chain table is large, and the descriptor chain table stored subsequently can cover the previous descriptor chain table) is avoided.
The descriptor chain table generator may store the generated descriptor chain table in the acquired storage space, and the electronic device may acquire the descriptor chain table through the USB module. In some embodiments, the processor of the electronic device may send a first transmission instruction to the USB module, and the first transmission instruction may include address information of the storage space. The first transmission instruction can be used for instructing the USB module to acquire the descriptor chain table from the storage space according to the address information, acquire data to be transmitted corresponding to the descriptor chain table from the memory according to the descriptor chain table, and transmit the corresponding data to be transmitted to the target device according to the USB protocol.
The address information of the storage space may be an initial address of the storage space, that is, an initial address of the descriptor chain table in the memory, and after receiving the first transmission instruction, the USB module may read the descriptor chain table from the memory according to the initial address and analyze the descriptor chain table to obtain a memory address (that is, an initial address of data to be transmitted) indicated by each data descriptor included in the descriptor chain table. And reading a plurality of data to be sent from the memory according to each memory address obtained by analysis, packaging the read data to be sent into a data packet according to a USB protocol, and sending the data packet to the target equipment through a USB interface.
In the embodiment of the application, a proper storage space can be allocated according to the receiving frequency of the descriptor chain table generator for receiving the data descriptors, the problems that the space is wasted due to too large storage space or the stored descriptor chain tables are overlapped due to too small storage space and the like can be avoided, the unreasonable storage space allocated by a system for storing the descriptor chain tables can be improved, the utilization rate of the storage space is improved, and the waste of the storage space is reduced.
As shown in fig. 5, in an embodiment, the step of obtaining the storage space corresponding to the receiving frequency according to the receiving frequency of the descriptor chain table generator receiving the data descriptor may include the following steps:
step 502, determining a target frequency interval in which a receiving frequency of the descriptor chain table generator receiving the data descriptor is located from a plurality of frequency intervals.
The memory space in the memory for storing the descriptor chain table may be divided into a plurality of groups of memory spaces, each group may include one or more memory spaces, the memory spaces included in each group have the same size, and the memory spaces between different groups have different sizes. The descriptor resource pool corresponding to each group of storage space may be established separately, and the descriptor resource pool may include space information (such as a start address and an end address of the storage space, or a start address and a space size of the storage space) of the storage space available in the group (i.e., the storage space where data is not stored).
For example, the memory space for storing descriptor linked lists may be divided into 3 sets of memory spaces, where the size of each memory space in set 1 is X1, the size of each memory space in set 2 is X2, the size of each memory space in set 3 is X3, and X1< X2< X3. 3 descriptor resource pools can be established, wherein the descriptor resource pool 1 corresponds to the 1 st group of storage space, the descriptor resource pool 1 can include the available storage space in the 1 st group, the descriptor resource pool 2 corresponds to the 2 nd group of storage space, the descriptor resource pool 2 can include the available storage space in the 2 nd group, the descriptor resource pool 3 corresponds to the 3 rd group of storage space, and the descriptor resource pool 3 can include the available storage space in the 3 rd group.
The descriptor chain table generator can compare the receiving frequency with each frequency interval after determining the receiving frequency of the received data descriptor, and determine a target frequency interval where the receiving frequency is located.
Step 504, a storage space is obtained from a target descriptor resource pool corresponding to the target frequency interval.
The descriptor chain table generator may obtain spatial information of an available storage space from a destination descriptor resource pool corresponding to a destination frequency interval, and write the descriptor chain table into the storage space according to the spatial information after generating the descriptor chain table. After the descriptor chain table generator obtains the space information of the storage space from the target descriptor resource pool, the space information of the storage space can be deleted from the target descriptor resource pool. After the USB module sends out the data packet corresponding to the descriptor chain table stored in the storage space, the descriptor chain table in the storage space can be cleared, the storage space is released, the space information of the storage space can be put into the target descriptor resource pool again, the cyclic use of the storage space is realized, and the waste of memory resources is avoided.
In one embodiment, the plurality of descriptor resource pools includes a first descriptor resource pool and a second descriptor resource pool, the frequency interval may include a first frequency interval and a second frequency interval, the first frequency interval may correspond to the first descriptor resource pool, the second frequency interval corresponds to the second descriptor resource pool, the first descriptor resource pool includes spatial information of one or more available first storage spaces, and the second descriptor resource pool includes spatial information of one or more available second storage spaces. The space size of each first storage space divided in the first descriptor resource pool may be smaller than the space size of each second storage space divided in the second descriptor resource pool, wherein the frequency in the first frequency interval corresponding to the first descriptor resource pool is lower than the frequency in the second frequency interval corresponding to the second descriptor resource pool.
In some embodiments, if the receiving frequency of the descriptor linked list generator receiving the data descriptor is less than the first frequency threshold, it may be determined that the target frequency interval in which the receiving frequency is located is the first frequency interval, and the first storage space may be obtained from a first descriptor resource pool corresponding to the first frequency interval.
If the receiving frequency of the descriptor linked list generator receiving the data descriptor is greater than the second frequency threshold, it may be determined that the target frequency interval in which the receiving frequency is located is the second frequency interval, and a second storage space may be obtained from a second descriptor resource pool corresponding to the second frequency interval.
When the receiving frequency is in a first frequency interval with smaller frequency, the data packet transmitted by the USB module is smaller, the descriptor chain table generated by the descriptor chain table generator is shorter, and a first storage space with smaller space can be obtained from the first descriptor resource pool, so that the problem of space waste caused by overlarge storage space can be avoided, and the utilization rate of the storage space can be improved. When the receiving frequency is in a second frequency interval with larger frequency, the data packet transmitted by the USB module is larger, the descriptor chain table generated by the descriptor chain table generator is longer, a second storage space with larger space can be obtained from the second descriptor resource pool, the problem that the stored descriptor chain tables are overlapped due to undersize of the storage space can be avoided, and when the receiving frequency is larger, the descriptor chain table generator generates a longer descriptor chain table, namely, the USB module can transmit a large data packet, so that the transmission efficiency of the USB can be improved.
In the embodiment of the application, by setting a plurality of frequency intervals and descriptor resource pools corresponding to the frequency intervals, the space sizes of the storage spaces divided in different descriptor resource pools are different, and the storage space can be acquired from the corresponding target descriptor resource pool according to the target frequency interval where the receiving frequency of the data descriptor received by the descriptor chain table generator is located, so that the acquired space size of the storage space is more adaptive to the length of the generated descriptor chain table, the unreasonable condition of the storage space allocated by a system for storing the descriptor chain table can be improved, the cyclic utilization of the storage space can be realized in a resource pool mode, and the utilization rate of the storage space is improved.
As shown in fig. 6, in another embodiment, a resource allocation method is provided, which is applicable to the electronic device described above, and the method may include the following steps:
step 602, obtaining the endpoint identifier corresponding to each data descriptor received by the descriptor linked list generator, where the endpoint identifier is used to represent a target USB endpoint for data transmission of data to be transmitted described by the corresponding data descriptor.
In the USB communication mechanism, a host and a slave device may be included, one host may be connected to one or more slave devices, and the host may assign a corresponding device address to each connected slave device and access the slave device based on the device address. One or more USB endpoints (endpoints) can be configured in the slave device, USB communication between the host and the slave device is realized based on the USB endpoints, each USB Endpoint can correspond to a unique Endpoint identification which can be numbers, characters, symbols or the like, for example, the slave device can comprise 16 USB endpoints with the Endpoint identifications of 0-15 and the like. The host transmits data to a specific USB endpoint of the slave device by sending out the device address and the endpoint identification for each data transmission.
In the transmission mechanism of the USB, the USB communication may include a plurality of data transmission types, for example, may include one or more of control transmission, bulk transmission, synchronous transmission, interrupt transmission, and the like, where the control transmission refers to transmission of control information, the bulk transmission refers to transmission of data with a large amount of data, the synchronous transmission refers to transmission of synchronous information, and the interrupt transmission refers to an interrupt event occurring in the transmission. Alternatively, the USB endpoints may be classified according to data transfer type, and each USB endpoint may support one data transfer type.
The processor of the electronic device writes data to be sent into a memory, and sends a data descriptor for describing the data to be sent and an endpoint identifier corresponding to the data to be sent to the descriptor linked list generator.
As an embodiment, the electronic device may be a slave device in USB communication, and the target device may be a host in USB communication, and then the USB module of the electronic device may be configured with one or more USB endpoints, where the endpoint identifier may be used to characterize a target USB endpoint for sending the data to be sent, and the USB module of the electronic device sends the data to be sent to the target device through the target USB endpoint.
As another embodiment, the electronic device may be a host in USB communication, the target device may be a slave in USB communication, and one or more USB endpoints are configured in the target device, so that the endpoint identifier may be used to characterize the target USB endpoint receiving the data to be sent, and the USB module of the electronic device sends the data to be sent to the target USB endpoint of the target device.
Step 604, determining the receiving frequency corresponding to each target USB endpoint according to the endpoint identifier corresponding to each data descriptor.
And the descriptor chain table generator is used for generating the descriptor chain table corresponding to each target USB endpoint according to the data descriptor corresponding to each target USB endpoint. The USB module can pack a plurality of data to be sent corresponding to the same endpoint identifier to improve the transmission efficiency of the data, so that the descriptor linked list generator can describe a plurality of data corresponding to the same endpoint identifier into the descriptor linked list. The descriptor chain table generator can respectively obtain corresponding storage space from the memory for each target USB endpoint, and is used for storing the descriptor chain table corresponding to each target USB endpoint.
In this embodiment of the present application, the descriptor chain table generator may determine a receiving frequency corresponding to each target USB endpoint according to an endpoint identifier corresponding to each received data descriptor, where the receiving frequency corresponding to a target USB endpoint may refer to the number of data descriptors received by the descriptor chain table generator in a unit time and corresponding to the same target USB endpoint. For example, if the descriptor linked list generator receives 5 data descriptors corresponding to USB endpoint 1 and 3 data descriptors corresponding to USB endpoint 2 in 1 second, the receiving frequency corresponding to USB endpoint 1 is 5/second and the receiving frequency corresponding to USB endpoint 2 is 3/second.
In some embodiments, determining the receiving frequency corresponding to each target USB endpoint according to the endpoint identifier corresponding to each data descriptor may include: when the descriptor linked list generator receives a data descriptor corresponding to a first endpoint identifier, determining a receiving time interval between the descriptor linked list generator and the last time the data descriptor corresponding to the first endpoint identifier is received, wherein the first endpoint identifier is used for representing that data to be sent described by the corresponding data descriptor is transmitted through a first target USB endpoint; and calculating the receiving frequency corresponding to the first target USB endpoint according to the at least one determined receiving time interval.
And the descriptor linked list generator can acquire a receiving time interval between the descriptor linked list generator and the last data descriptor corresponding to the first endpoint identifier when receiving the data descriptor corresponding to the first endpoint identifier, wherein the receiving time interval is the interval duration between two adjacent data descriptors corresponding to the first endpoint identifier.
In one embodiment, the descriptor chain table generator may include a counter corresponding to each USB endpoint, and the counter corresponding to each USB endpoint may be configured to record a receiving time interval during which the descriptor chain table generator receives the data descriptor of the USB endpoint corresponding to the counter.
Optionally, when the descriptor chain table generator receives the data descriptor corresponding to the first endpoint identifier, determining a receiving time interval between the last time the data descriptor corresponding to the first endpoint identifier is received may include: when the descriptor linked list generator receives the data descriptor corresponding to the first endpoint identifier, acquiring the time length recorded by the counter corresponding to the first target USB endpoint, and taking the time length as the receiving time interval between the time length and the last received data descriptor corresponding to the first endpoint identifier; and the counter is reset to an initial value every time the descriptor chain table generator receives the data descriptor corresponding to the first endpoint identifier.
Taking a first target USB endpoint of the USB endpoints as an example, the endpoint id of the first target USB endpoint is a first endpoint id, and each time the descriptor linked list generator receives the data descriptor corresponding to the first endpoint id, the counter corresponding to the first target USB endpoint is reset and starts to count (may be to count the number of pulses). The value recorded by the counter corresponding to the first target USB endpoint between two resets can be used as the duration recorded by the counter, that is, the receiving time interval between two data descriptors corresponding to the first endpoint identifier.
Alternatively, the reset initial value of the counter may be 0, and when the counter receives a time pulse, the counter may be incremented by 1, and the increments are sequentially incremented until the descriptor linked list generator receives the data descriptor corresponding to the first endpoint identifier again, the counter is reset to 0 again, and the value recorded before the counter is reset to 0 again may be used as the receiving time interval.
Illustratively, FIG. 7 is a diagram of the analysis frequency of the descriptor chain table generator in one embodiment. As shown in FIG. 7, clock represents a time pulse waveform, system _ rst represents a system reset waveform, type _ a _ wen represents a waveform that the descriptor chain table generator receives the data descriptor of the USB endpoint A, type _ a _ cnt _ rst represents a reset waveform of the counter of the USB endpoint A, type _ B _ wen represents a waveform that the descriptor chain table generator receives the data descriptor of the USB endpoint B, and type _ B _ cnt _ rst represents a reset waveform of the counter of the USB endpoint B.
As can be seen from fig. 7, the counter is reset each time the system resets and the descriptor chain generator receives a data descriptor for the corresponding USB endpoint. The number of time pulses recorded by the counter between two resets can be used as the receiving time interval, for example, in type _ a _ cnt _ rst, 3 time pulses ( pulses 6, 7, and 8) are included between the 2 nd reset and the 3 rd reset of the counter, so that the receiving time interval of the data descriptor corresponding to the USB endpoint a is 3; in type _ B _ cnt _ rst, 10 time pulses (pulses 12-21) are included between the 2 nd reset and the 3 rd reset of the counter, and the receiving time interval of the data descriptor corresponding to the USB endpoint B is 10.
After determining at least one receiving time interval recorded by the counter corresponding to the first target USB endpoint, the receiving frequency corresponding to the first target USB endpoint may be calculated according to the at least one determined receiving time interval. In some embodiments, the determined N reception time intervals may be obtained, the N reception time intervals being the first N reception time intervals arranged from near to far according to the determined time, N being an integer greater than 1. And calculating the average time interval of the N receiving time intervals, and calculating the receiving frequency corresponding to the first target USB endpoint according to the average time interval.
N can be set according to actual requirements, such as 3, 4 and the like. When the descriptor chain table generator receives the data descriptor corresponding to the first target USB endpoint the mth time, the receiving time intervals (i.e., N receiving time intervals) recorded by the mth time, the mth-1 time, the mth-2 time, … … time and the mth-N +1 time of the counter may be obtained, and the average time interval may be calculated. The receiving frequency of the first destination USB endpoint may be a ratio of a unit time to an average time interval, for example, the unit time is 100 time pulses, the average time interval for the descriptor chain table generator to receive the data descriptor of the first destination USB endpoint is 3 time pulses, and the receiving frequency may be 33.3.
Step 606, respectively obtaining the storage space corresponding to each target USB endpoint according to the receiving frequency corresponding to each target USB endpoint.
Step 608, store the descriptor chain table corresponding to each target USB endpoint into the storage space corresponding to each target USB endpoint.
Taking the first target USB endpoint as an example, the first target USB endpoint may be any target USB endpoint, the first descriptor chain table corresponding to the first target USB endpoint may be stored in the storage space corresponding to the first target USB endpoint, and the storage space corresponding to the first target USB endpoint is obtained based on the receiving frequency of the descriptor chain table generator receiving the data descriptor corresponding to the first target USB endpoint. The descriptor chain table generator may obtain a storage space corresponding to the first target USB endpoint according to a receiving frequency of the received data descriptor corresponding to the first endpoint identifier, may generate a first descriptor chain table according to the plurality of data descriptors corresponding to the first endpoint identifier, and stores the first descriptor chain table into the storage space corresponding to the first target USB endpoint.
In some embodiments, a target frequency interval in which the receiving frequency corresponding to each target USB endpoint is located may be determined, and a storage space corresponding to each target USB endpoint is obtained from a target descriptor resource pool corresponding to the target frequency interval. The descriptor chain table generator may store the generated descriptor chain table corresponding to each target USB endpoint into a storage space corresponding to each target USB endpoint.
For example, if the receiving frequency of the USB endpoint a is in the first target frequency interval, the first storage space may be obtained from the first descriptor resource pool corresponding to the first frequency interval. The descriptor linked list generator may conform the data descriptions of the plurality of corresponding USB endpoints a into a data symbol linked list and store the data symbol linked list into the acquired first storage space. For another example, if the receiving frequency of the USB endpoint B is in the second target frequency interval, the second storage space may be obtained from the second descriptor resource pool corresponding to the second target frequency interval, and the descriptor linked list generator may match the data descriptions of the USB endpoint B into the descriptor linked list, and store the descriptor linked list into the obtained second storage space. The appropriate memory space of the descriptor chain table can be allocated to each target USB endpoint according to the frequency of the data to be transmitted to each target USB endpoint, the memory space of different descriptor chain tables does not need to be allocated to each USB endpoint rigorously in the design stage, and the allocation mode is more flexible and reasonable.
In some embodiments, the above method further comprises: and acquiring a first descriptor linked list from a storage space corresponding to the first target USB endpoint through the USB module, wherein the first descriptor linked list is used for describing data to be transmitted through the first target USB endpoint. In one embodiment, the processor in the electronic device may send a second transmission instruction to the USB module, where the second transmission instruction includes address information of a memory space corresponding to the first target USB endpoint. And the second transmission instruction is used for instructing the USB module to acquire the first descriptor linked list from the second storage space according to the address information, acquire data to be transmitted corresponding to the first descriptor linked list from the memory according to the first descriptor linked list, and transmit the acquired data to be transmitted to the target equipment through the first target USB endpoint according to the USB protocol.
After the descriptor chain table generator writes the descriptor chain table corresponding to the target USB endpoint into the corresponding storage space, the USB module can read the descriptor chain table from the storage space, read the data to be sent corresponding to the target USB endpoint from the memory according to the descriptor chain table, package the read data to be sent according to the USB protocol to obtain a data packet, and send the data packet to the target USB endpoint.
Taking the first target USB endpoint as an example, the first target USB endpoint may be any target USB endpoint, and after the descriptor chain table generator writes the first descriptor chain table corresponding to the first target USB endpoint into the storage space corresponding to the first target USB endpoint, the processor may send the second transmission instruction to the USB module. The USB module may read the first descriptor linked list from the memory according to the address information included in the second transmission instruction, and parse the first descriptor linked list to obtain the memory address of the data to be sent, and then read the data to be sent from the memory according to the memory address of the data to be sent. The USB module may encapsulate data to be transmitted according to a USB protocol, and transmit a packet obtained by encapsulation to the first target USB endpoint. If the electronic equipment is the host, the USB module sends the data packet to a first target USB endpoint of the target equipment, and if the electronic equipment is the slave equipment, the USB module sends the data packet to the first target USB endpoint and then the data packet is transmitted to the target equipment by the first target USB endpoint.
In one embodiment, before the obtaining, by the USB module, the first descriptor linked list from the storage space corresponding to the first target USB endpoint, the method further includes: and judging whether the descriptor chain table corresponding to each target USB endpoint is stored in the storage space corresponding to each target USB endpoint by the endpoint arbiter in turn.
The electronic device may be provided with an endpoint arbiter, and the endpoint arbiter may check whether the descriptor chain table of each USB endpoint in the descriptor generator has been stored in the corresponding storage space in a polling manner, that is, may determine whether the descriptor chain table corresponding to each target USB endpoint is ready in turn. If the endpoint arbiter detects that the descriptor chain table of the currently viewed target USB endpoint is stored in the corresponding storage space, a corresponding transmission instruction may be sent to the USB module. Taking the first target USB endpoint as an example, if the endpoint arbiter determines that the first descriptor chain table corresponding to the first target USB endpoint is stored in the storage space corresponding to the first target USB endpoint, the first descriptor chain table may be obtained from the storage space corresponding to the first target USB endpoint through the USB module.
If the endpoint arbiter detects that the descriptor chain table of the currently viewed target USB endpoint is not stored in the corresponding memory space, the next target USB endpoint may be viewed. Through the polling mode, each target USB endpoint can be ensured to perform data transmission at a fairer frequency, and the communication efficiency and the communication quality of the USB are improved.
FIG. 8A is an architecture diagram of an electronic device in one embodiment. As shown in fig. 8A, the electronic device may include a processor 810, a descriptor generator 820, an endpoint arbiter 830, a USB module 840, and a memory (not shown).
The descriptor generator 820 may include a scheduling unit 821, a frequency analyzer 822, a descriptor resource pool selector 826, and a plurality of linked list establishers, where each linked list establisher corresponds to 1 USB endpoint, respectively, for example, the endpoint 0 linked list establisher 823 corresponds to USB endpoint 0, the endpoint 1 linked list establisher 824 corresponds to USB endpoint 1, and the endpoint 2 linked list establisher 825 corresponds to USB endpoint 2.
A data resource pool 870, a first descriptor resource pool 850 and a second descriptor resource pool 860 may be provided, wherein the data resource pool 870 includes a start address of a usable data storage space, the first descriptor resource pool 850 includes a start address of a usable first storage space for storing a descriptor chain table, and the second descriptor resource pool 860 includes a start address of a usable second storage space for storing a descriptor chain table, and a space size of the first storage space is different from a space size of the second storage space.
When the processor 810 needs to send data to a target device through the USB module 840, a start address of an available data storage space may be obtained from the data resource pool, data to be sent may be written into a memory according to the start address, and a data descriptor for describing the data to be sent is sent to the descriptor generator 820.
The scheduling unit 821 may analyze the endpoint id corresponding to the data descriptor and distribute the received data descriptor to the linked list builder corresponding to the endpoint id. The frequency analyzer 822 may determine the receiving frequency corresponding to each target USB endpoint according to the endpoint identifier corresponding to the data descriptor. Further, the frequency analyzer 822 may determine a target frequency interval in which the receiving frequency corresponding to each target USB endpoint is located, and send the target frequency interval to the descriptor resource selector 826.
The descriptor resource selector 826 may obtain a storage space from a target descriptor resource pool corresponding to a target frequency interval according to the target frequency interval in which the receiving frequency corresponding to each target USB endpoint is located. For example, if the receiving frequency corresponding to the target USB endpoint is in the first frequency interval, the starting address of the first storage space is obtained from the first descriptor resource pool 850; if the receiving frequency corresponding to the target USB endpoint is in the second frequency interval, the starting address of the first storage space is obtained from the second descriptor resource pool 860.
FIG. 8B is a diagram illustrating the architecture of a frequency analyzer, according to one embodiment. In one embodiment, as shown in fig. 8B, the frequency analyzer 822 may set a resource idle counter, a space time equalizer, and a frequency coefficient generator for each target USB endpoint, respectively. After the processor 810 obtains the data storage space from the data resource pool 870 and writes the data to be sent to the memory, the processor 810 may send a data descriptor to the descriptor generator 820.
The frequency analyzer 822 may determine the receiving frequency (i.e., the frequency of occurrence) of the data descriptor of each target USB endpoint according to the endpoint identifier corresponding to the data descriptor. The resource idle counter is reset each time a data descriptor corresponding to the endpoint identifier is received, so as to record the receiving time interval between two adjacent data descriptors corresponding to the endpoint identifiers. The idle time equalizer may average the N receive time intervals to obtain an average time interval. The frequency coefficient generator may determine the receiving frequency from the averaging time interval, and the frequency interval in which the receiving frequency is located.
In some embodiments, the frequency coefficient generator may also directly compare the average time interval with a time threshold, and if the average time interval is smaller than the first time threshold, a first frequency coefficient (e.g., a coefficient such as 1) may be generated, where the average time interval smaller than the first time threshold indicates that the receiving frequency is higher, and the first frequency coefficient may indicate that the receiving frequency is in the second frequency interval. If the average time interval is greater than a second time threshold, a second frequency coefficient (e.g., a coefficient such as 0) may be generated, and if the average time interval is greater than the second time threshold, the receiving frequency may be lower, and the second frequency coefficient may indicate that the receiving frequency is in the first frequency interval. Wherein the first time threshold may be less than or equal to the second time threshold.
The descriptor resource selector 826 may feed back the obtained start address of the storage space corresponding to each target USB endpoint to the linked list builder corresponding to each target USB endpoint. The linked list builder generates a descriptor linked list according to a plurality of data descriptors corresponding to the target USB endpoints, and writes the descriptor linked list into a memory according to an initial address fed back by the descriptor resource selector 826.
The endpoint arbiter 830 may sequentially check whether each linked list builder in the descriptor generator 820 writes the descriptor linked list of the corresponding target USB endpoint into the corresponding storage space in a polling manner, and if it is detected that the descriptor linked list of the target USB endpoint has been written into the corresponding storage space, may send a transmission instruction including the start address of the storage space to the USB module 840. The USB module 840 may read the descriptor chain table from the memory according to the transmission instruction, obtain data to be sent from the memory according to the descriptor chain table, and send the data to be sent to the target USB endpoint according to the USB protocol.
After the USB module 840 completes transmission of a data packet, the memory may release a memory space for storing the descriptor chain table of the data packet, and the descriptor resource selector 826 may replace the starting address of the released memory space into the corresponding descriptor resource pool. After the USB module 840 completes sending all data to be sent in one data storage space, the memory may release the data storage space, and the processor 810 may put the initial address of the released data storage space into the data resource pool 810 again, so as to facilitate reuse of the memory space and save memory resources.
In the embodiment of the application, the storage space for storing the descriptor chain table can be more reasonably allocated to each target USB endpoint according to the receiving frequency of the data descriptor corresponding to each target USB endpoint, the problems that the space is wasted due to overlarge storage space or the stored descriptor chain table is overlapped due to too small storage space and the like can be avoided, and the condition that the storage space allocated by a system for storing the descriptor chain table is unreasonable can be improved. Moreover, the descriptor chain table generator has the capability of adaptively allocating storage spaces with different space sizes to each endpoint according to the occurrence frequency of the data descriptors, and the allocation mode is more flexible.
As shown in fig. 8A, in one embodiment, an electronic device is provided that may include a descriptor generator 820, a memory (not shown).
And a descriptor chain table generator 820 for acquiring a storage space corresponding to the receiving frequency from the memory according to the receiving frequency of the received data descriptor.
And the descriptor chain table generator 820 is also used for generating the descriptor chain table according to the received data descriptors and storing the descriptor chain table into the storage space.
In one embodiment, the descriptor chain table generator 820 may include a frequency analyzer 822 and a descriptor resource selector 826.
The frequency analyzer 822 is configured to determine a target frequency interval in which the receiving frequency is located from the plurality of frequency intervals. The multiple frequency intervals correspond to the multiple descriptor resource pools one by one, and the space sizes of the storage spaces divided in different descriptor resource pools are different.
A descriptor resource selector 826, configured to obtain a storage space from a target descriptor resource pool corresponding to the target frequency interval.
Further, as shown in fig. 8A, the electronic device may further include a USB module 840. The USB module 840 is configured to obtain the descriptor chain table from the storage space, and obtain data to be sent from the memory according to the descriptor chain table.
It should be noted that, for the description in the embodiment of the present application, reference may be made to the description of the embodiment related to fig. 8A, and repeated description is omitted here.
As shown in fig. 9, in an embodiment, a resource allocation apparatus 900 is provided, which can be applied to the electronic device described above, and the resource allocation apparatus 900 can include a space obtaining module 910 and a storage module 920.
A space obtaining module 910, configured to obtain a storage space corresponding to a receiving frequency according to the receiving frequency of the descriptor chain table generator receiving the data descriptor, where the descriptor chain table generator is configured to generate the descriptor chain table according to the received data descriptor.
A storage module 930 for storing the descriptor chain table into a storage space.
In an embodiment, the resource allocation apparatus 900 further includes a linked list obtaining module, configured to obtain, by the USB module, the descriptor linked list from the storage space, where the descriptor linked list is used to describe data to be sent by the USB module.
In the embodiment of the application, a proper storage space can be allocated according to the receiving frequency of the descriptor chain table generator for receiving the data descriptors, the problems that the space is wasted due to too large storage space or the stored descriptor chain tables are overlapped due to too small storage space and the like can be avoided, the unreasonable storage space allocated by a system for storing the descriptor chain tables can be improved, the utilization rate of the storage space is improved, and the waste of the storage space is reduced.
In one embodiment, the space obtaining module 910 is further configured to determine a target frequency interval in which the receiving frequency is located from the multiple frequency intervals; and acquiring a storage space from a target descriptor resource pool corresponding to the target frequency interval, wherein the plurality of frequency intervals correspond to the plurality of descriptor resource pools one by one, and the space sizes of the storage spaces divided in different descriptor resource pools are different.
In one embodiment, the plurality of descriptor resource pools include a first descriptor resource pool and a second descriptor resource pool, a space size of each first storage space divided in the first descriptor resource pool is smaller than a space size of each second storage space divided in the second descriptor resource pool, and a frequency in a first frequency interval corresponding to the first descriptor resource pool is lower than a frequency in a second frequency interval corresponding to the second descriptor resource pool.
In the embodiment of the application, by setting a plurality of frequency intervals and descriptor resource pools corresponding to the frequency intervals, the space sizes of the storage spaces divided in different descriptor resource pools are different, and the storage space can be acquired from the corresponding target descriptor resource pool according to the target frequency interval where the receiving frequency of the data descriptor received by the descriptor chain table generator is located, so that the acquired space size of the storage space is more adaptive to the length of the generated descriptor chain table, the unreasonable condition of the storage space allocated by a system for storing the descriptor chain table can be improved, the cyclic utilization of the storage space can be realized in a resource pool mode, and the utilization rate of the storage space is improved.
In one embodiment, the data descriptor corresponds to an endpoint identifier, and the endpoint identifier is used for characterizing a target USB endpoint for data transmission of data to be transmitted described by the data descriptor. And the descriptor chain table generator is used for generating the descriptor chain table corresponding to each target USB endpoint according to the data descriptor corresponding to each target USB endpoint. The first descriptor chain table corresponding to the first target USB endpoint is stored in a storage space corresponding to the first target USB endpoint, and the storage space corresponding to the first target USB endpoint is obtained based on the receiving frequency of the descriptor chain table generator for receiving the data descriptor corresponding to the first target USB endpoint, wherein the first target USB endpoint is any one target USB endpoint.
In an embodiment, the resource allocation apparatus 900 further includes a frequency determination module, and the frequency determination module includes an identifier obtaining unit and a frequency calculating unit.
And the identifier acquisition unit is used for acquiring the endpoint identifier corresponding to each data descriptor received by the descriptor linked list generator, and the endpoint identifier is used for representing a target USB endpoint for data transmission of the data to be transmitted described by the corresponding data descriptor.
And the frequency calculation unit is used for determining the receiving frequency corresponding to each target USB endpoint according to the endpoint identifier corresponding to each data descriptor.
In one embodiment, the frequency calculation unit is further configured to determine, when the descriptor linked list generator receives the data descriptor corresponding to the first endpoint identifier, a reception time interval between the last time the data descriptor corresponding to the first endpoint identifier was received; and calculating a receiving frequency corresponding to a first target USB endpoint according to at least one determined receiving time interval, wherein the first endpoint identification is used for representing that the data to be sent described by the corresponding data descriptor is transmitted through the first target USB endpoint.
In one embodiment, the frequency calculation unit is further configured to, when the descriptor linked list generator receives the data descriptor corresponding to the first endpoint identifier, obtain a duration recorded by a counter corresponding to the first target USB endpoint, and use the duration as a receiving time interval between the last received data descriptor corresponding to the first endpoint identifier and the counter corresponding to the first endpoint identifier; and the counter is reset to an initial value every time the descriptor chain table generator receives the data descriptor corresponding to the first endpoint identifier.
In one embodiment, the frequency calculation unit is further configured to obtain N determined receiving time intervals, where the N receiving time intervals are the first N receiving time intervals arranged from near to far according to the determined time, and N is an integer greater than 1; and the receiving frequency calculation module is used for calculating the average time interval of the N receiving time intervals and calculating the receiving frequency corresponding to the first target USB endpoint according to the average time interval.
The space obtaining module 910 is further configured to obtain storage spaces corresponding to the target USB endpoints according to the receiving frequencies corresponding to the target USB endpoints.
The storing module 920 is further configured to store the descriptor chain table corresponding to each target USB endpoint into a storage space corresponding to each target USB endpoint.
In an embodiment, the linked list obtaining module is further configured to obtain, by the USB module, a first descriptor linked list from a storage space corresponding to the first target USB endpoint, where the first descriptor linked list is used to describe data to be transmitted that is transmitted by the first target USB endpoint; the first target USB endpoint is any target USB endpoint.
In an embodiment, the resource allocation apparatus 900 further includes a polling module, configured to determine, by the endpoint arbiter, whether the descriptor chain table corresponding to each target USB endpoint is stored in the storage space corresponding to each target USB endpoint in turn.
And the linked list acquisition module is further used for acquiring the first descriptor linked list from the storage space corresponding to the first target USB endpoint through the USB module if the endpoint arbiter determines that the first descriptor linked list corresponding to the first target USB endpoint is stored in the storage space corresponding to the first target USB endpoint.
In the embodiment of the application, the storage space for storing the descriptor chain table can be more reasonably allocated to each target USB endpoint according to the receiving frequency of the data descriptor corresponding to each target USB endpoint, the problems that the space is wasted due to overlarge storage space or the stored descriptor chain table is overlapped due to too small storage space and the like can be avoided, and the condition that the storage space allocated by a system for storing the descriptor chain table is unreasonable can be improved. Moreover, the descriptor chain table generator has the capability of adaptively allocating storage spaces with different space sizes to each endpoint according to the occurrence frequency of the data descriptors, and the allocation mode is more flexible.
In an embodiment, an electronic device is provided, comprising a memory and a processor, the memory having stored therein a computer program, which, when executed by the processor, causes the processor to carry out the method as described in the embodiments above.
The embodiment of the application discloses a computer readable storage medium, which stores a computer program, wherein the computer program realizes the method described in the above embodiment when being executed by a processor.
Embodiments of the present application disclose a computer program product comprising a non-transitory computer readable storage medium storing a computer program, and the computer program, when executed by a processor, implements the method as described in the embodiments above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. The storage medium may be a magnetic disk, an optical disk, a ROM, etc.
Any reference to memory, storage, database, or other medium as used herein may include non-volatile and/or volatile memory. Suitable non-volatile memory can include ROM, Programmable ROM (PROM), Erasable PROM (EPROM), Electrically Erasable PROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, RAM can take many forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus Direct RAM (RDRAM), and Direct Rambus DRAM (DRDRAM).
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also appreciate that the embodiments described in this specification are all alternative embodiments and that the acts and modules involved are not necessarily required for this application.
In various embodiments of the present application, it should be understood that the size of the serial number of each process described above does not mean that the execution sequence is necessarily sequential, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing detailed description has provided a resource allocation method, apparatus, electronic device, and computer-readable storage medium, which are disclosed in the embodiments of the present application, and the present application is described in detail by applying specific examples, and the description of the foregoing embodiments is only used to help understand the method and the core idea of the present application. Meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (17)

1. A method for resource allocation, comprising:
acquiring a storage space corresponding to a receiving frequency according to the receiving frequency of the data descriptors received by a descriptor chain table generator, wherein the descriptor chain table generator is used for generating a descriptor chain table according to the received data descriptors;
storing the descriptor chain table into the storage space.
2. The method of claim 1, wherein the obtaining a storage space corresponding to a receiving frequency of the descriptor chain table generator according to the receiving frequency of the data descriptor comprises:
determining a target frequency interval in which a receiving frequency of a descriptor chain table generator receiving a data descriptor is located from a plurality of frequency intervals, wherein the plurality of frequency intervals correspond to a plurality of descriptor resource pools in a one-to-one manner, and the space sizes of storage spaces divided in different descriptor resource pools are different;
and acquiring a storage space from a target descriptor resource pool corresponding to the target frequency interval.
3. The method of claim 2, wherein the plurality of descriptor resource pools comprises a first descriptor resource pool and a second descriptor resource pool, and wherein a size of a space of each first storage space divided in the first descriptor resource pool is smaller than a size of a space of each second storage space divided in the second descriptor resource pool, and wherein a frequency in a first frequency interval corresponding to the first descriptor resource pool is lower than a frequency in a second frequency interval corresponding to the second descriptor resource pool.
4. The method of claim 1, further comprising:
and acquiring the descriptor chain table from the storage space through the USB module, wherein the descriptor chain table is used for describing data to be sent by the USB module.
5. The method according to any one of claims 1 to 4, wherein the data descriptor corresponds to an endpoint identifier, and the endpoint identifier is used for characterizing a target USB endpoint for data transmission of data to be transmitted, which is described by the data descriptor;
the descriptor chain table generator is used for generating a descriptor chain table corresponding to each target USB endpoint according to the data descriptor corresponding to each target USB endpoint;
the descriptor chain table generator is used for generating a descriptor chain table corresponding to a first target USB endpoint, wherein the descriptor chain table corresponding to the first target USB endpoint is stored in a storage space corresponding to the first target USB endpoint, the storage space corresponding to the first target USB endpoint is obtained based on the receiving frequency of the descriptor chain table generator for receiving the data descriptor corresponding to the first target USB endpoint, and the first target USB endpoint is any one of the target USB endpoints.
6. The method of claim 5, wherein before the retrieving the memory space corresponding to the receiving frequency according to the receiving frequency of the descriptor chain table generator receiving the data descriptors, the method further comprises:
when the descriptor chain table generator receives a data descriptor corresponding to a first end point identification, determining a receiving time interval between the last time the data descriptor corresponding to the first end point identification is received; the first endpoint identification is used for representing that the data to be sent described by the corresponding data descriptor is transmitted through a first target USB endpoint;
and calculating the receiving frequency corresponding to the first target USB endpoint according to at least one determined receiving time interval.
7. The method of claim 6, wherein determining a receive time interval between the last time a data descriptor corresponding to a first endpoint identification was received by the descriptor linked list generator comprises:
when the descriptor linked list generator receives a data descriptor corresponding to a first endpoint identifier, acquiring the time length recorded by a counter corresponding to the first target USB endpoint, and taking the time length as a receiving time interval between the time length and the last received data descriptor corresponding to the first endpoint identifier; wherein the counter is reset to an initial value each time the descriptor chain generator receives a data descriptor corresponding to the first endpoint identification.
8. The method according to claim 6 or 7, wherein the calculating a receiving frequency corresponding to the first target USB endpoint according to the at least one determined receiving time interval comprises:
acquiring N determined receiving time intervals, wherein the N receiving time intervals are the first N receiving time intervals arranged from near to far according to the determined time, and N is an integer larger than 1;
and calculating the average time interval of the N receiving time intervals, and calculating the receiving frequency corresponding to the first target USB endpoint according to the average time interval.
9. The method of claim 5, further comprising:
and acquiring the first descriptor linked list from a storage space corresponding to the first target USB endpoint through a USB module, wherein the first descriptor linked list is used for describing data to be transmitted through the first target USB endpoint.
10. The method of claim 9, wherein prior to said retrieving, by the USB module, the first descriptor linked list from the memory space corresponding to the first target USB endpoint, the method further comprises:
judging whether the descriptor chain table corresponding to each target USB endpoint is stored in the storage space corresponding to each target USB endpoint by an endpoint arbiter in turn;
the obtaining, by the USB module, the first descriptor linked list from the storage space corresponding to the first target USB endpoint includes:
and if the endpoint arbiter determines that the first descriptor chain table corresponding to the first target USB endpoint is stored in the storage space corresponding to the first target USB endpoint, acquiring the first descriptor chain table from the storage space corresponding to the first target USB endpoint through a USB module.
11. The method according to any one of claims 1 to 4, 6 to 7, and 9 to 10, wherein the data descriptor includes a memory address and control information, the memory address is a start address of the data to be sent described by the data descriptor stored in a memory, and the control information is used for representing a length of the data to be sent described by the data descriptor.
12. A resource allocation apparatus, comprising:
the space acquisition module is used for acquiring a storage space corresponding to a receiving frequency according to the receiving frequency of the data descriptors received by the descriptor chain table generator, and the descriptor chain table generator is used for generating the descriptor chain table according to the received data descriptors;
a storage module for storing the descriptor chain table into the storage space.
13. An electronic device, comprising:
a memory;
the descriptor linked list generator is used for acquiring a storage space corresponding to a receiving frequency of a received data descriptor from the storage according to the receiving frequency;
the descriptor chain table generator is also used for generating a descriptor chain table according to the received data descriptors and storing the descriptor chain table into the storage space.
14. The electronic device of claim 13, wherein the descriptor linked list generator comprises:
a frequency analyzer, configured to determine a target frequency interval in which the receiving frequency is located from a plurality of frequency intervals; the multiple frequency intervals correspond to multiple descriptor resource pools one by one, and the space sizes of storage spaces divided in different descriptor resource pools are different;
a descriptor resource selector, configured to obtain a storage space from a target descriptor resource pool corresponding to the target frequency interval.
15. The electronic device of claim 13, further comprising:
and the USB module is used for acquiring the descriptor chain table from the storage space and acquiring data to be transmitted from the memory according to the descriptor chain table.
16. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program that, when executed by the processor, causes the processor to carry out the method of any one of claims 1 to 11.
17. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1 to 11.
CN202111123443.6A 2021-09-24 2021-09-24 Resource allocation method, device, electronic equipment and computer readable storage medium Active CN113835891B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111123443.6A CN113835891B (en) 2021-09-24 2021-09-24 Resource allocation method, device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111123443.6A CN113835891B (en) 2021-09-24 2021-09-24 Resource allocation method, device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN113835891A true CN113835891A (en) 2021-12-24
CN113835891B CN113835891B (en) 2023-05-23

Family

ID=78970155

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111123443.6A Active CN113835891B (en) 2021-09-24 2021-09-24 Resource allocation method, device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113835891B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020118690A1 (en) * 2001-02-23 2002-08-29 International Business Machines Corporation Assignment of packet descriptor field positions in a network processor
CN1547358A (en) * 2003-12-02 2004-11-17 烽火通信科技股份有限公司 A data frame buffer memory device and method for Ethernet passive optical network
US20090119460A1 (en) * 2007-11-07 2009-05-07 Infineon Technologies Ag Storing Portions of a Data Transfer Descriptor in Cached and Uncached Address Space
CN105446898A (en) * 2014-09-23 2016-03-30 Arm有限公司 Descriptor ring management
CN108259380A (en) * 2017-12-21 2018-07-06 安凯(广州)微电子技术有限公司 Method, system and the ethernet controller of Frame processes
CN109428827A (en) * 2017-08-21 2019-03-05 深圳市中兴微电子技术有限公司 Flow self-adaptive cache allocation device and method and ONU (optical network Unit) equipment
CN110795400A (en) * 2019-10-12 2020-02-14 苏州浪潮智能科技有限公司 File management method, device, equipment and medium
CN112131175A (en) * 2020-08-28 2020-12-25 山东云海国创云计算装备产业创新中心有限公司 SoC chip, power consumption control method and readable storage medium
CN113225307A (en) * 2021-03-18 2021-08-06 西安电子科技大学 Optimization method, system and terminal for pre-reading descriptors in offload engine network card

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020118690A1 (en) * 2001-02-23 2002-08-29 International Business Machines Corporation Assignment of packet descriptor field positions in a network processor
CN1547358A (en) * 2003-12-02 2004-11-17 烽火通信科技股份有限公司 A data frame buffer memory device and method for Ethernet passive optical network
US20090119460A1 (en) * 2007-11-07 2009-05-07 Infineon Technologies Ag Storing Portions of a Data Transfer Descriptor in Cached and Uncached Address Space
CN105446898A (en) * 2014-09-23 2016-03-30 Arm有限公司 Descriptor ring management
CN109428827A (en) * 2017-08-21 2019-03-05 深圳市中兴微电子技术有限公司 Flow self-adaptive cache allocation device and method and ONU (optical network Unit) equipment
CN108259380A (en) * 2017-12-21 2018-07-06 安凯(广州)微电子技术有限公司 Method, system and the ethernet controller of Frame processes
CN110795400A (en) * 2019-10-12 2020-02-14 苏州浪潮智能科技有限公司 File management method, device, equipment and medium
CN112131175A (en) * 2020-08-28 2020-12-25 山东云海国创云计算装备产业创新中心有限公司 SoC chip, power consumption control method and readable storage medium
CN113225307A (en) * 2021-03-18 2021-08-06 西安电子科技大学 Optimization method, system and terminal for pre-reading descriptors in offload engine network card

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
ZERUN LI等: "Bi-Transfer: A Data Packet Allocation Module with Chaining Transmission Mode", 《2019 IEEE 5TH INTERNATIONAL CONFERENCE ON COMPUTER AND COMMUNICATIONS (ICCC)》 *
陈紫卿: "数字对讲机监测系统用户接口单元的架构设计及驱动程序的开发", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
高健: "多通道PCI Express网卡与Linux系统交互机制研究与实现", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Also Published As

Publication number Publication date
CN113835891B (en) 2023-05-23

Similar Documents

Publication Publication Date Title
CN109558344B (en) DMA transmission method and DMA controller suitable for network transmission
US20050240688A1 (en) Efficient data transfer from an ASIC to a host using DMA
WO2016011811A1 (en) Memory management method and apparatus, and storage medium
CN111177025A (en) Data storage method and device and terminal equipment
CN113660351B (en) Data communication method, device, communication terminal and computer readable storage medium
CN101707565A (en) Method and device for transmitting and receiving zero-copy network message
CN105264930A (en) Transmission node and method for reporting buffer status thereof
CN113590512B (en) Self-starting DMA device capable of directly connecting peripheral equipment and application
CN112732628A (en) Inter-core data processing method and system, system on chip and electronic equipment
CN105630424A (en) Data processing method, device and system
CN108304272B (en) Data IO request processing method and device
CN115002046B (en) Message processing method, NUMA node, electronic equipment and storage medium
CN115102908B (en) Method for generating network message based on bandwidth control and related device
CN112422485B (en) Communication method and device of transmission control protocol
CN113835891B (en) Resource allocation method, device, electronic equipment and computer readable storage medium
CN113852533A (en) Multi-channel data communication system and method and electronic equipment
CN110489356B (en) Information processing method, information processing device, electronic equipment and storage medium
CN113672532B (en) USB equipment control device and data transmission device
CN113316230B (en) Method and device for scheduling data sending task, electronic equipment and storage medium
CN107911317B (en) Message scheduling method and device
CN115550442A (en) Data packet transmission method and device, electronic equipment and storage medium
CN112804027B (en) Data packet generation method and device and data reading method and device
CN110266814B (en) Transmission method and transmission device
CN104375871A (en) Method and device for accelerating system startup on basis of eMMC
CN111371799B (en) Method, device and equipment for controlling data receiving and transmitting of MCTP (Multi-channel media Port) controller

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