Metadata drawing method and device
By using PID control algorithm to adjust the metadata drawing frequency in embedded devices, the device lag or crash caused by the increase in processor occupancy is solved, and the stability of processor load and the efficiency of metadata drawing is achieved.
Patent Information
- Application Number
- CN202310981680.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
When metadata is frequently drawn in embedded devices, the processor occupancy increases, resulting in the device being stuck or crashed, and the existing methods are complex and error-prone.
The PID control algorithm is used to adjust the drawing frequency of metadata based on the processor occupancy rate and automatically adjust the processor load to ensure moderate processing speed and reasonable processor occupancy rate.
It effectively reduces the risk of device lag or crash, and ensures the stable operation of the processor during frequent drawing of metadata.
Smart Images

Figure CN119440793A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a metadata drawing method and device. Background Art
[0002] Metadata drawing plays an important role in modern data visualization, knowledge graph construction and other fields.
[0003] In order to realize the visualization of metadata, the computer needs to process and calculate a large amount of metadata, which will inevitably lead to an increase in the occupancy rate of the central processing unit (CPU) in the embedded device, and even cause the embedded device to crash. At present, methods to reduce the processor occupancy rate include concurrent programming, multi-threaded task allocation, etc. However, these methods need to be manually added to the program, which is complicated and error-prone.
[0004] Therefore, when metadata is frequently drawn in embedded devices, how to effectively reduce processor usage to reduce device freezes or crashes needs to be solved urgently. Summary of the invention
[0005] The present invention provides a metadata drawing method and device, which are used to realize that when metadata is frequently drawn in an electronic device, a PID control algorithm is used to adjust the processor occupancy rate, thereby automatically adjusting the drawing frequency to draw different types of metadata, so as to effectively ensure that the processing speed is moderate and the processor occupancy rate is reasonable, thereby reducing problems such as device freeze or crash.
[0006] The present invention provides a metadata drawing method, comprising:
[0007] Get the metadata and processor occupancy rate in the cache queue;
[0008] Determining a drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm;
[0009] The metadata is rendered according to the rendering frequency.
[0010] According to a metadata drawing method provided by the present invention, the method further includes: determining the type of the metadata when the metadata is monitored; and storing the metadata and the type of the metadata in the cache list accordingly.
[0011] According to a metadata drawing method provided by the present invention, the drawing frequency of the metadata is determined according to the processor occupancy rate in combination with a PID control algorithm, including: obtaining a first processor occupancy rate of the processor at a current moment and a second processor occupancy rate of a preset interval at the current moment; using the PID control algorithm to determine a distribution frequency of the metadata according to the first processor occupancy rate and the second processor occupancy rate; and determining a drawing frequency of the metadata according to the distribution frequency.
[0012] According to a metadata drawing method provided by the present invention, determining the drawing frequency of the metadata according to the distribution frequency includes: determining the drawing frequency of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue, the proportions of different types of metadata and the distribution frequency of the metadata.
[0013] According to a metadata drawing method provided by the present invention, drawing the metadata according to the drawing frequency includes: writing the corresponding metadata into a drawing queue linked list according to the drawing frequencies of the different types of metadata in the cache queue; and drawing the metadata according to the metadata order in the drawing queue linked list.
[0014] According to a metadata drawing method provided by the present invention, the drawing frequency of different types of metadata in the cache queue is determined according to the priorities of different types of metadata in the cache queue, the type ratios of different types of metadata and the distribution frequency of the metadata, including: determining the weight ratios of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue; determining the type ratios of different types of metadata in the cache queue according to the total number of metadata in the cache queue and the corresponding numbers of different types of metadata; and determining the drawing frequency of different types of metadata in the cache queue according to the weight ratios, the type ratios and the distribution frequency of the metadata.
[0015] According to a metadata drawing method provided by the present invention, drawing the metadata according to the drawing frequency includes: determining random numbers of the different types of metadata; and drawing the metadata for any type of metadata according to the random number and the drawing frequency of the metadata.
[0016] According to a metadata drawing method provided by the present invention, the first processor occupancy rate of the processor at the current moment is obtained, including: obtaining the first total time slice of the processor at the current moment; obtaining the second total time slice and the idle time slice of the processor after a preset time length; and determining the first processor occupancy rate of the processor at the current moment based on the first total time slice, the second total time slice and the idle time slice.
[0017] The present invention also provides a metadata drawing device, comprising:
[0018] The acquisition module is used to obtain the metadata and processor occupancy rate in the cache queue;
[0019] The processing module is used to determine the drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm; and draw the metadata according to the drawing frequency.
[0020] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the above-mentioned metadata drawing methods is implemented.
[0021] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the metadata drawing method described in any one of the above is implemented.
[0022] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned metadata drawing methods.
[0023] The metadata drawing method and device provided by the present invention obtain the metadata and processor occupancy rate in the cache queue; determine the drawing frequency of the metadata according to the processor occupancy rate and in combination with the PID control algorithm; and draw the metadata according to the drawing frequency. In the case of frequent metadata drawing in an electronic device, the method uses a PID control algorithm to adjust the processor occupancy rate, and then automatically adjusts the drawing frequency to draw different types of metadata, which can effectively ensure that the processing speed is moderate and the processor occupancy rate is reasonable, thereby reducing problems such as device freezes or crashes. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 is a flowchart of a metadata drawing method provided by an embodiment of the present invention;
[0026] Figure 2 is a schematic diagram of an image obtained by drawing metadata provided by an embodiment of the present invention;
[0027] Figure 3 is a scene schematic diagram of a metadata drawing method provided by an embodiment of the present invention;
[0028] Figure 4 is a schematic diagram of the structure of a metadata drawing device provided by an embodiment of the present invention;
[0029] Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] The metadata drawing process in the embedded device is as follows: the pixel values corresponding to the pixels to be drawn on the metadata line segment are written into the frame buffer, and then after being processed by the chip, the image composed of all the pixels in the frame buffer is sent to the display device (such as a monitor / display) in the embedded device for display. Among them, the frame buffer is a memory area used to store the color value of each pixel on the display device. The display server will periodically refresh the color value on the frame buffer to the display device, thereby realizing the presentation of the human-computer interface.
[0032] In order to solve the problem that the metadata drawing process in embedded devices causes the processor occupancy rate of embedded devices to be high, resulting in freezes or crashes, the embodiment of the present invention provides a metadata drawing method and device, which obtains the metadata and processor occupancy rate in the cache queue; determines the drawing frequency of the metadata according to the processor occupancy rate in combination with the PID control algorithm; and draws the metadata according to the drawing frequency. In the case of frequent metadata drawing in electronic devices, the method uses a PID control algorithm to automatically adjust the drawing frequency according to the processor occupancy rate to draw different types of metadata, which can effectively ensure moderate processing speed and reasonable processor occupancy rate, thereby reducing problems such as freezes or crashes of the device.
[0033] It should be noted that the execution subject involved in the embodiment of the present invention may be a metadata drawing device or an electronic device, and the electronic device is an embedded device.
[0034] Optionally, the electronic device may include: a computer, a mobile terminal, a wearable device, etc.
[0035] The embodiment of the present invention is further described below by taking an electronic device as an example.
[0036] like Figure 1 FIG. 1 is a flow chart of a metadata drawing method provided by an embodiment of the present invention, which may include:
[0037] 101. Obtain metadata and processor occupancy in the cache queue.
[0038] The cache queue refers to a queue used to store various metadata.
[0039] Metadata, also known as intermediary data or relay data, refers to data that describes data attribute information and is used to support functions such as indicating storage location, historical data, resource search, and file records. The metadata involved in the embodiments of the present application carries the pixel value of the pixel to be drawn.
[0040] The processor occupancy rate refers to the processor resources occupied by the application program in the electronic device when it is running. If the processor occupancy rate is high, it means that more applications are running in the electronic device. The processor occupancy rate includes a first processor occupancy rate and a second processor occupancy rate. The first processor occupancy rate refers to the processor occupancy rate of the processor in the electronic device at the current moment, and the second processor occupancy rate refers to the processor occupancy rate of the processor at a preset interval at the current moment.
[0041] It should be noted that there is no limit to the timing of the electronic device acquiring the metadata and the electronic device acquiring the processor occupancy rate.
[0042] In some embodiments, before step 101, the method may further include: the electronic device determines the type of metadata when monitoring the metadata; and the electronic device stores the metadata and the type of metadata in a corresponding cache queue.
[0043] The types corresponding to the metadata in the cache queue may be the same or different, and the numbers of the metadata of each type may be the same or different, which is not specifically limited here.
[0044] In addition, the electronic device monitors multiple metadata.
[0045] Optionally, the electronic device determining the type of metadata may include: the electronic device determining the type of metadata according to an alarm classification.
[0046] Optionally, the alarm categories may include: motion detection, face recognition, and behavior analysis, etc.
[0047] That is, when the electronic device monitors multiple metadata, it can first determine the type of each metadata according to the alarm classification, and then insert the metadata and the type of each metadata into the cache list accordingly.
[0048] In some embodiments, the electronic device obtains the first processor occupancy rate of the processor at the current moment, which may include: S1, the electronic device obtains the first total time slice of the processor at the current moment; S2, the electronic device obtains the second total time slice and the idle time slice of the processor after a preset time length; S3, the electronic device determines the first processor occupancy rate of the processor at the current moment based on the first total time slice, the second total time slice and the idle time slice.
[0049] The idle time slice refers to the time period during which the application is not running.
[0050] The total time slice refers to the total amount of time that an electronic device allows the processor to allocate to each application.
[0051] The preset duration may also be called a sampling period, which refers to a period of time calculated from the current moment. Optionally, the preset duration may be set before the electronic device leaves the factory or may be user-defined, and is not specifically limited here.
[0052] When an electronic device detects that an application is running, it can read the / proc / stat file to determine the usage of the processor in the electronic device at the current moment and obtain the first total time slice; then, the electronic device starts calculating from the current moment, and after a preset period of time, obtains the second total time slice and idle time slice of the processor, and then determines the occupancy rate of the first processor corresponding to the electronic device based on the second total time slice, the idle time slice and the first total time slice, so as to accurately determine the drawing frequency of the metadata later.
[0053] Optionally, the electronic device obtaining the first total time slice may include: the electronic device determining the first total time slice according to a time slice formula.
[0054] The time slice formula is: first total time slice = user state time + system state time + idle time + input output (IO) waiting time.
[0055] The electronic device can accurately determine the first total time slice of the processor at the current moment according to the above time slice formula, so as to prepare for the subsequent determination of the first processor occupancy rate with higher accuracy.
[0056] Optionally, the electronic device determines the first processor occupancy of the processor at the current moment based on the first total time slice, the second total time slice and the idle time slice, which may include: the electronic device determines the first processor occupancy of the processor at the current moment based on an occupancy formula.
[0057] The occupancy rate formula is: C = (c 2total -c 1total ) / (c 2total -c 2idle );
[0058] C represents the occupancy rate of the first processor; c 2total Indicates the second total time slice; c 1total Indicates the first total time slice; c 2idle Indicates an idle time slice.
[0059] The electronic device can accurately determine the occupancy rate of the first processor according to the occupancy rate formula.
[0060] 102. Determine the drawing frequency of the metadata according to the processor occupancy rate and in combination with the PID control algorithm.
[0061] Among them, the Proportional Integration Differentiation (PID) control algorithm refers to a control algorithm that can dynamically adjust the processor occupancy rate.
[0062] The drawing frequency refers to the frequency at which metadata is drawn on a display screen of an electronic device.
[0063] Optionally, the drawing frequencies corresponding to different types of metadata may be the same or different, which is not specifically limited here.
[0064] In some embodiments, the electronic device determines the frequency of drawing metadata based on the processor occupancy rate in combination with a PID control algorithm, which may include: the electronic device obtains a first processor occupancy rate of the processor at a current moment and a second processor occupancy rate at a preset interval at the current moment; the electronic device adopts a PID control algorithm to determine the distribution frequency of the metadata based on the first processor occupancy rate and the second processor occupancy rate; the electronic device determines the drawing frequency of the metadata based on the distribution frequency.
[0065] After the electronic device obtains the first processor occupancy rate of the processor at the current moment and the second processor occupancy rate of the processor at a preset interval at the current moment, the specific acquisition process is in step 101, which is not described in detail here. A PID control algorithm can be used to adjust the first processor occupancy rate and the second processor occupancy rate to obtain a distribution frequency of metadata with higher accuracy, and then obtain a drawing frequency of metadata with higher accuracy.
[0066] It should be noted that the distribution frequency of each metadata in the cache list is the same.
[0067] Optionally, the electronic device adopts a PID control algorithm to determine the distribution frequency of the metadata according to the occupancy rate of the first processor and the occupancy rate of the second processor, which may include: the electronic device determines the distribution frequency of the metadata according to a PID control discretization formula.
[0068] Among them, the PID control discretization formula is:
[0069] f=Kp[e(k)+Ts*e_I(k)+Td / Ts*(e(k)-e(k-1))];
[0070] f represents the distribution frequency of metadata; Kp represents the proportional control coefficient; e(k)=C′(k)-C(k), represents the first error; C′(k) represents the first predicted occupancy; C(k) represents the first processor occupancy; Ts represents the preset duration; e_I(k) represents the accumulated error value of the integral term, which is obtained by summing the error history; Td represents the differential time constant; e(k-1)=C′(k-1)-C(k-1), represents the second error; C′(k-1) represents the second predicted occupancy; C(k-1) represents the second processor occupancy, and k represents the current time.
[0071] The first processor occupancy rate C(k) and the second processor occupancy rate C(k-1) are both actual measured values.
[0072] The electronic device adjusts the deviation corresponding to the occupancy rate of the first processor and the deviation corresponding to the occupancy rate of the second processor according to the PID control discretization formula in the PID control algorithm, and can accurately determine the distribution frequency corresponding to all metadata in the cache list.
[0073] In some embodiments, the electronic device determines the drawing frequency of metadata based on the distribution frequency, which may include: the electronic device determines the drawing frequency of different types of metadata in the cache queue based on the priority of different types of metadata in the cache queue, the type ratio of different types of metadata and the distribution frequency of metadata.
[0074] The priorities of different types of metadata may be set according to specific requirements. For example, as shown in Table 1, it is a correspondence table of different types of metadata and their priorities.
[0075] Table 1:
[0076] type Priority Motion Detection 1 Face Recognition 4 Behavioral analysis 5
[0077] As can be seen from Table 1, different types of metadata have different priorities. The priorities increase from 1 to 5, with 5 being the highest, that is, the priority of the metadata for behavior analysis is the highest, the priority of the metadata for face recognition is second only to the highest priority, and the priority of the metadata for motion detection is the lowest.
[0078] Exemplary: As shown in Table 2, it is a correspondence table of different types of metadata and priorities of different types of metadata.
[0079] Table 2:
[0080] type Priority Face Recognition 3 Motion Detection 2 Behavioral analysis 1
[0081] As can be seen from Table 1, the priority increases from 1 to 3, with 3 being the highest, that is, the priority of the metadata for face recognition is the highest, the priority of the metadata for motion detection is second only to the highest priority, and the priority of the metadata for behavior analysis is the lowest.
[0082] As can be seen from the above two tables, the priorities of different types of metadata can be set according to specific needs, and users can set the priorities of categories according to their importance.
[0083] In addition, the proportions of different types of metadata may be the same or different, depending on the metadata in the cache list, and are not specifically limited here.
[0084] In the process of determining the drawing frequency of metadata according to the distribution frequency, the electronic device can first obtain different types of metadata from the cache queue; then, for any type of metadata, the electronic device can determine the drawing frequency of the metadata according to the priority of the metadata, the type ratio of the metadata and the distribution frequency corresponding to all metadata in the cache list. Based on this, the electronic device can accurately determine the drawing frequency of different types of metadata in the cache queue according to the priority of different types of metadata in the cache queue, the type ratio of different types of metadata and the distribution frequency of metadata.
[0085] It should be noted that the priorities of the electronic device in acquiring different types of metadata and the timing of the proportions of the different types of metadata acquired by the electronic device are not limited.
[0086] In some embodiments, the electronic device determines the drawing frequency of different types of metadata in the cache queue based on the priorities of different types of metadata in the cache queue, the type ratios of different types of metadata and the distribution frequency of the metadata, which may include: the electronic device determines the weight ratios of different types of metadata in the cache queue based on the priorities of different types of metadata in the cache queue; the electronic device determines the type ratios of different types of metadata in the cache queue based on the total number of metadata in the cache queue and the corresponding numbers of different types of metadata; the electronic device determines the drawing frequency of different types of metadata in the cache queue based on the weight ratios, the type ratios and the distribution frequency of the metadata.
[0087] When the electronic device stores metadata and the types of metadata in a cache list, it can sort the weight values according to the types of metadata. For example, after classifying the alarms, the number of various types of metadata in the cache queue within a certain period of time can be obtained, and then the weight ratio of the metadata can be obtained after adding the weight calculation based on the alarm priority of the user. Based on this, the electronic device can determine the weight ratio of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue.
[0088] Then, in the process of determining the type ratio of different types of metadata, the electronic device can first obtain the total number of all metadata in the cache queue and obtain the corresponding number of different types of metadata; then, the electronic device calculates the total number and the corresponding number of different types of metadata to obtain the type ratio of different types of metadata, and the accuracy of the type ratio is relatively high; finally, the electronic device can accurately determine the drawing frequency of different types of metadata according to the weight ratio of different types of metadata, the type ratio of different types of metadata and the distribution frequency of all metadata.
[0089] Optionally, for each type of metadata, the electronic device determines the weight ratio of the metadata according to the priority of the metadata, which may include: the electronic device determines the weight value of the metadata according to the priority of the metadata, and determines the sum of the weight values of all the metadata; the electronic device determines the weight ratio of the metadata according to the sum and the weight value of the metadata.
[0090] Since each type of metadata has a corresponding weight value, when determining the weight ratio of a certain type of metadata, the electronic device can first determine the weight values of all metadata according to their respective priorities, and determine the sum of all weight values; then, the electronic device calculates the sum and the weight value of the metadata to obtain the weight ratio of the metadata. Based on this, the electronic device can determine the weight ratios of different types of metadata, and these weight ratios are highly accurate, so as to prepare for the subsequent accurate determination of the drawing frequency of different types of metadata.
[0091] In this way, the electronic device uses a priority strategy to subsequently determine the drawing frequency of different types of metadata to ensure that key types of metadata are smooth and not lost. In addition, when processor resources are limited, the electronic device draws as much metadata as possible and ensures the smooth speed of the electronic device.
[0092] Optionally, for each metadata, the electronic device determines the weight ratio of the metadata according to the sum value and the weight value of the metadata, which may include: the electronic device determines the weight ratio of the metadata according to a first ratio formula.
[0093] The first proportion formula is: Kn = Wx / (W1+W2+…+Wn);
[0094] Wx represents the weight value of metadata of the xth category among n categories, n≥2; W1+W2+…+Wn represents the sum of all weight values.
[0095] The electronic device can accurately determine the weight ratios of different types of metadata according to the first ratio formula.
[0096] Optionally, for each type of metadata, the electronic device determines the metadata type ratio according to the total number and the number corresponding to the metadata, which may include: the electronic device determines the metadata type ratio according to a second ratio formula.
[0097] The second proportion formula is: Zn = Zx / (Zw);
[0098] Zx represents the number of metadata of the xth category among n categories; Zw represents the total number of all metadata.
[0099] The electronic device can accurately determine the proportions of different types of metadata according to the second proportion formula.
[0100] Optionally, the electronic device determines the drawing frequency of different types of metadata in the cache queue according to the weight ratio, type ratio and metadata distribution frequency, which may include: the electronic device determines the drawing frequency of different types of metadata in the cache queue according to the drawing frequency formula.
[0101] Among them, the formula for drawing frequency is: Yn=(f*Kn+f*Zn) / a;
[0102] Yn represents the drawing frequency; Kn represents the weight ratio; Zn represents the category ratio; a represents a constant, which is generally taken as 2.
[0103] For example, assuming that the distribution frequency f is 40 per second, a=2, the number of motion detection metadata is 3, and the total number of metadata in the cache queue is 10, then the metadata category ratio Zn is 0.3; the metadata weight ratio Kn is 0.1. Based on the frequency formula, the electronic device obtains the drawing frequency of the metadata as Yn=(f*Kn+f*Zn) / a=(40×0.1+40*0.3) / 2=8 per second.
[0104] The electronic device can accurately determine the drawing frequencies of different types of metadata according to the above drawing frequency formula.
[0105] 103. Draw the metadata according to the drawing frequency.
[0106] Since each type of metadata has a corresponding drawing frequency, the electronic device can draw the metadata of each type according to the corresponding drawing frequency to obtain the desired image displayed on the display screen of the electronic device.
[0107] For example, Figure 2 FIG. 1 is a schematic diagram of an image obtained by drawing metadata according to an embodiment of the present invention. Figure 2 As can be seen from the drawing position of the metadata, the electronic device writes the metadata to the corresponding drawing position, and can obtain images corresponding to all metadata. Since the drawing frequencies corresponding to different types of metadata are different, the processor occupancy rate of the device can be effectively reduced, so that the final image can effectively avoid the loss of important pictures, thereby effectively improving the quality of the image.
[0108] In some embodiments, the electronic device draws the metadata according to the drawing frequency, which may include but is not limited to at least one of the following implementations:
[0109] Implementation method 1: The electronic device writes the corresponding metadata into a drawing queue linked list according to the drawing frequencies of different types of metadata in the cache queue; the electronic device draws the metadata according to the metadata order in the drawing queue linked list.
[0110] After determining the drawing frequencies of different types of metadata in the cache queue, the electronic device can write the corresponding metadata into the drawing queue linked list according to the respective drawing frequencies of these types of metadata, and then draw the metadata according to the metadata order in the drawing queue linked list to realize the drawing process of different types of metadata.
[0111] Based on the above process, it can be concluded that when drawing, the electronic device will continuously take out metadata from the cache list for drawing. In addition, when drawing metadata, it can effectively avoid drawing the same type of metadata in a short period of time, causing delays in drawing other types of metadata.
[0112] Implementation method 2: The electronic device determines random numbers of different types of metadata; the electronic device draws the metadata according to the random number and drawing frequency of the metadata for any type of metadata.
[0113] Optionally, the random number can be an odd number or an even number, which is not specifically limited here.
[0114] In the process of writing these metadata and their respective types and priorities into the drawing queue linked list, the electronic device can determine the random numbers corresponding to different types of metadata based on rand()%(ulLen-i)+i+1. The electronic device writes these different types of metadata and their respective types and priorities into the drawing queue linked list based on these random numbers to realize the drawing process of the metadata.
[0115] Wherein, rand(·) represents a random number generation function, %(ulLen-i)+i+1 represents the range of random numbers as [0, ulLen-i-1], and ulLen-i-1 represents the random number length threshold input manually.
[0116] In summary, if Figure 3 FIG. 3 is a schematic diagram of a scene of a metadata drawing method provided by an embodiment of the present invention. As can be seen from FIG. 3, the method is applied to an electronic device, and the electronic device may include an acquisition thread, a distribution thread, and a drawing thread. In the process of drawing metadata, the electronic device, 301, determines the type of metadata when monitoring metadata, and inserts the metadata and the type of metadata into the cache queue accordingly; 302, the acquisition thread sends the cache queue to the distribution thread, and the distribution thread receives the cache queue sent by the acquisition thread; 303, the distribution thread determines the processor occupancy rate for the metadata in the cache queue, and determines the distribution frequency of the metadata according to the processor occupancy rate and the PID control algorithm; 304, the distribution thread determines the drawing frequency of different types of metadata according to the distribution frequency, the priority of different types of metadata in the cache queue and the proportion of different types of metadata; 305, the distribution thread sends different types of metadata and the drawing frequency of different types of metadata to the drawing thread; the drawing thread receives the different types of metadata and the drawing frequency of different types of metadata sent by the distribution thread; 306, the drawing thread writes different types of metadata into the drawing queue linked list, and draws the different types of metadata in the drawing queue linked list according to the corresponding drawing frequency. This process can automatically adjust the drawing frequency according to the processor occupancy rate to draw different types of metadata, which can effectively improve the metadata drawing efficiency.
[0117] In an embodiment of the present invention, metadata and processor occupancy in a cache queue are obtained; the drawing frequency of the metadata is determined according to the processor occupancy in combination with a PID control algorithm; and the metadata is drawn according to the drawing frequency. In the case where metadata is frequently drawn in an electronic device, the method uses a PID control algorithm to automatically adjust the drawing frequency according to the processor occupancy to draw different types of metadata, which can effectively ensure a moderate processing speed and a reasonable processor occupancy, thereby reducing problems such as device freezes or crashes.
[0118] The metadata drawing device provided by the present invention is described below. The metadata drawing device described below and the metadata drawing method described above can be referred to each other.
[0119] like Figure 4 FIG. 1 is a schematic diagram of the structure of a metadata drawing device provided by an embodiment of the present invention, which may include:
[0120] The acquisition module 401 is used to acquire metadata and processor occupancy in the cache queue;
[0121] The processing module 402 is used to determine the drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm; and draw the metadata according to the drawing frequency.
[0122] Optionally, the processing module 402 is specifically used to obtain the occupancy rate of the second processor at the previous moment of the occupancy rate of the first processor; adopt a proportional integral derivative PID control algorithm to determine the distribution frequency of the metadata according to the occupancy rate of the first processor and the occupancy rate of the second processor; and determine the drawing frequency of the metadata according to the distribution frequency.
[0123] Optionally, the processing module 402 is further configured to determine the type of the metadata when the metadata is monitored; and store the metadata and the type of the metadata in the cache list accordingly.
[0124] Optionally, the acquisition module 401 is specifically used to acquire a first processor occupancy rate of the processor at the current moment and a second processor occupancy rate at a preset interval at the current moment;
[0125] The processing module 402 is specifically configured to adopt the PID control algorithm to determine the distribution frequency of the metadata according to the occupancy rate of the first processor and the occupancy rate of the second processor; and determine the drawing frequency of the metadata according to the distribution frequency.
[0126] Optionally, the processing module 402 is specifically configured to determine the drawing frequency of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue, the proportions of different types of metadata, and the distribution frequency of the metadata.
[0127] Optionally, the processing module 402 is specifically configured to write corresponding metadata into a drawing queue linked list according to drawing frequencies of the different types of metadata in the cache queue; and draw the metadata according to the metadata order in the drawing queue linked list.
[0128] Optionally, processing module 402 is specifically used to determine the weight ratios of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue; determine the type ratios of different types of metadata in the cache queue according to the total number of metadata in the cache queue and the corresponding numbers of different types of metadata; and determine the drawing frequency of different types of metadata in the cache queue according to the weight ratio, the type ratio and the distribution frequency of the metadata.
[0129] Optionally, the acquisition module 401 is specifically used to determine the random numbers of the different types of metadata; for any type of metadata, the metadata is drawn according to the random number and drawing frequency of the metadata.
[0130] Optionally, acquisition module 401 is specifically used to obtain the first total time slice of the processor at the current moment; obtain the second total time slice and idle time slice of the processor after a preset time length; and determine the first processor occupancy rate of the processor at the current moment based on the first total time slice, the second total time slice and the idle time slice.
[0131] like Figure 5 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the metadata drawing method, the method comprising: obtaining the metadata and the processor occupancy rate in the cache queue; determining the drawing frequency of the metadata according to the processor occupancy rate and the PID control algorithm; and drawing the metadata according to the drawing frequency.
[0132] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0133] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the metadata drawing method provided by the above methods, and the method includes: obtaining the metadata and processor occupancy in the cache queue; determining the drawing frequency of the metadata based on the processor occupancy and in combination with a PID control algorithm; and drawing the metadata based on the drawing frequency.
[0134] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the metadata drawing method provided by the above-mentioned methods, the method comprising: obtaining metadata and processor occupancy in a cache queue; determining a drawing frequency of the metadata based on the processor occupancy in combination with a PID control algorithm; and drawing the metadata based on the drawing frequency.
[0135] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A metadata drawing method, characterized in that: include: Get the metadata and processor occupancy rate in the cache queue; Determining a drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm; The metadata is rendered according to the rendering frequency.
2. The metadata drawing method according to claim 1, characterized in that: The method further comprises: In case the metadata is monitored, determining the type of the metadata; The metadata and the type of the metadata are correspondingly stored in the cache list.
3. The metadata drawing method according to claim 1, characterized in that: Determining the drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm includes: Obtaining a first processor occupancy rate of the processor at the current moment and a second processor occupancy rate at a preset interval at the current moment; Using the PID control algorithm, according to the occupancy rate of the first processor and the occupancy rate of the second processor, determining the distribution frequency of the metadata; A drawing frequency of the metadata is determined according to the distribution frequency.
4. The metadata drawing method according to claim 3, characterized in that: The step of determining the drawing frequency of the metadata according to the distribution frequency includes: The drawing frequency of the different types of metadata in the cache queue is determined according to the priorities of the different types of metadata in the cache queue, the proportions of the different types of metadata, and the distribution frequency of the metadata.
5. The metadata drawing method according to claim 4, characterized in that: The step of drawing the metadata according to the drawing frequency includes: According to the drawing frequencies of the different types of metadata in the cache queue, writing the corresponding metadata into a drawing queue linked list; The metadata is rendered according to the metadata order in the rendering queue linked list.
6. The metadata drawing method according to claim 4, characterized in that: The determining, according to the priorities of different types of metadata in the cache queue, the proportions of different types of metadata, and the distribution frequency of the metadata, the drawing frequency of different types of metadata in the cache queue includes: Determining weight proportions of different types of metadata in the cache queue according to the priorities of different types of metadata in the cache queue; Determining the proportion of different types of metadata in the cache queue according to the total number of metadata in the cache queue and the corresponding numbers of different types of metadata; The drawing frequencies of different types of metadata in the cache queue are determined according to the weight proportions, the type proportions, and the distribution frequency of the metadata.
7. The metadata drawing method according to any one of claims 1 to 6, characterized in that: The step of drawing the metadata according to the drawing frequency includes: Determining random numbers for the different types of metadata; For any type of metadata, the metadata is drawn according to the random number and drawing frequency of the metadata.
8. The metadata drawing method according to any one of claims 3 to 6, characterized in that: The obtaining of the first processor occupancy rate of the processor at the current moment includes: Obtain a first total time slice of the processor at the current moment; Obtaining a second total time slice and an idle time slice of the processor after a preset time length; A first processor occupancy rate of the processor at the current moment is determined according to the first total time slice, the second total time slice, and the idle time slice.
9. A metadata drawing device, characterized in that: include: The acquisition module is used to obtain the metadata and processor occupancy rate in the cache queue; The processing module is used to determine the drawing frequency of the metadata according to the processor occupancy rate in combination with a PID control algorithm; and draw the metadata according to the drawing frequency.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the metadata drawing method according to any one of claims 1 to 8 is implemented.