An event queue scheduling method, device, apparatus and medium

By dividing the event queue into active buckets, alternative buckets, and default buckets, and utilizing a min-heap sorting mechanism, the performance bottleneck of the event queue scheduling algorithm in the network simulator is solved, the scheduling efficiency of the event queue is improved, and the running speed of the network simulator is increased.

CN114995976BActive Publication Date: 2026-02-03DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210625601.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-02
Publication Date
2026-02-03
Estimated Expiration
2042-06-02

AI Technical Summary

Technical Problem

The event queue scheduling algorithm of existing network simulators encounters a performance bottleneck when the number of events is large, which slows down the network simulation speed and increases the simulation time.

Method used

An event queue scheduling method is adopted, which divides the event queue into an active bucket, a number of candidate buckets not exceeding a preset number, and a default bucket. The target bucket is quickly determined and the target event is inserted using a min-heap sorting mechanism, and the event with the shortest trigger time is dequeued first.

Benefits of technology

It reduces the complexity of event scheduling, improves the scheduling efficiency of event queues, solves performance bottleneck problems, and improves the running speed of network simulators.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114995976B_ABST
    Figure CN114995976B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide an event queue scheduling method, device, equipment and medium. The method comprises: in response to an event enqueue request, determining a target bucket matching a target event to be enqueued in an event queue; the event queue is composed of one active bucket, no more than a preset number of alternative buckets, and one default bucket; inserting the target event into the target bucket, and performing heap sorting on events in the target bucket; and in response to an event dequeue request, taking a heap top event from the active bucket of the event queue. Through the above technical solution, the embodiments of the present disclosure reduce the event scheduling complexity based on the total number of events, and improve the scheduling efficiency of the event queue.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of computer network, and particularly relate to an event queue scheduling method, device, apparatus and medium. BACKGROUND

[0002] A network simulator is a tool for simulating a network at the computer software level, which is crucial for testing and tuning network-related programs. An event queue scheduling algorithm is the most significant factor affecting the performance of a network simulator.

[0003] In the prior art, the event queue scheduling algorithms widely used by network simulators, such as linked list scheduling algorithm and heap scheduling algorithm, all have performance bottlenecks when the total number of scheduled events is large, resulting in slow network simulation speed and increased simulation time. SUMMARY

[0004] The present disclosure provides an event queue scheduling method, device, apparatus and medium to reduce the event scheduling complexity based on the total number of events and improve the scheduling efficiency of the event queue.

[0005] In a first aspect, the embodiments of the present disclosure provide an event queue scheduling method, comprising:

[0006] In response to an event enqueue request, determining a target bucket matching a target event to be enqueued in an event queue; the event queue is composed of one active bucket, no more than a preset number of alternative buckets, and one default bucket;

[0007] Inserting the target event into the target bucket and performing heap sorting on the events in the target bucket;

[0008] In response to an event dequeue request, taking out a top-of-heap event from the active bucket of the event queue.

[0009] In a second aspect, the embodiments of the present disclosure further provide an event queue scheduling device, comprising:

[0010] A positioning module is configured to perform, in response to an event enqueue request, determining a target bucket matching a target event to be enqueued in an event queue; the event queue is composed of one active bucket, no more than a preset number of alternative buckets, and one default bucket;

[0011] An enqueue module is configured to perform inserting the target event into the target bucket and performing heap sorting on the events in the target bucket;

[0012] A dequeue module is configured to perform, in response to an event dequeue request, taking out a top-of-heap event from the active bucket of the event queue.

[0013] In a third aspect, the embodiments of the present disclosure further provide an electronic device, comprising:

[0014] One or more processors;

[0015] Storage device for storing one or more programs.

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the event queue scheduling method as described in the embodiments of this disclosure.

[0017] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the event queue scheduling method as described in embodiments of this disclosure.

[0018] In this embodiment, in response to an event enqueue request, a target bucket matching the target event to be enqueued is determined in the event queue; the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket; the target event is inserted into the target bucket, and the events in the target bucket are heap sorted; in response to an event dequeue request, the top event is retrieved from the active bucket of the event queue, thus solving the performance bottleneck problem of existing event queue scheduling algorithms when the number of scheduled events is large, achieving the effect of reducing the event scheduling complexity based on the total number of events and improving the scheduling efficiency of the event queue. Attached Figure Description

[0019] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0020] Figure 1 This is a flowchart illustrating an event queue scheduling method provided in an embodiment of this disclosure;

[0021] Figure 2 This is a flowchart illustrating an event queue scheduling method provided in an embodiment of this disclosure;

[0022] Figure 3 This is a flowchart illustrating the implementation of event queuing provided in an embodiment of this disclosure;

[0023] Figure 4 This is a flowchart illustrating an event queue scheduling method provided in an embodiment of this disclosure;

[0024] Figure 5 This is a flowchart illustrating the implementation of event dequeueing provided in an embodiment of this disclosure;

[0025] Figure 6 This is a schematic diagram of the structure of an event queue scheduling device provided in an embodiment of this disclosure;

[0026] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0027] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0028] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0029] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0030] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0031] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0032] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0033] Figure 1This is a flowchart illustrating an event queue scheduling method provided in this disclosure. This disclosure is applicable to scenarios involving rapid event enqueueing and dequeueing operations on the event queue of a network simulator. The method can be executed by an event queue scheduling device, which can be implemented in software and / or hardware, optionally through an electronic device such as a mobile terminal, PC, or server. Figure 1 As shown, the method includes:

[0034] S110. In response to an event enqueue request, determine the target bucket in the event queue that matches the target event to be enqueued.

[0035] The network simulator's event queue consists of several buckets. The core of the event queue scheduling algorithm is the event enqueue operation and the event dequeue operation. A bucket is a basic data structure for storing network simulator events. Each bucket has a time coverage range. The trigger times of the events contained in the bucket are within its corresponding coverage range. The length of the coverage range is called the time capacity of the bucket. The coverage ranges of any two buckets do not overlap.

[0036] In one implementation, the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket. All candidate buckets can be arranged into a candidate bucket queue according to their coverage order. Whether it's the active bucket, candidate bucket, or default bucket, their data structure is a min-heap sorted by event trigger time, so that when performing an event dequeue operation, events with earlier trigger times are retrieved first from the event queue.

[0037] In this embodiment, when responding to an event enqueue request and needing to store a target event in the event queue, the bucket whose coverage area can cover the target event's trigger time can be found among several buckets in the event queue. This bucket will be the target bucket to which the target event is to be stored. The target bucket may be an active bucket, a backup bucket, or a default bucket.

[0038] In this embodiment, when there are many scheduled events, considering that the trigger time of the events to be executed must be after the current analog clock time, and that the trigger time of most of the events to be executed is concentrated in a very small time interval after the current analog clock time, the small time interval with most of the events is divided into an active bucket and multiple alternative buckets, and the time interval with fewer events is divided into a default bucket. By dividing the events into buckets, the complexity of event scheduling based on the total number of events is reduced and the efficiency of event scheduling is improved.

[0039] S120. Insert the target event into the target bucket and perform heap sort on the events in the target bucket.

[0040] In this embodiment, after finding the target bucket that matches the target event in the event queue, the target event is inserted into the target bucket, and the events in the target bucket are heap sorted in ascending order of trigger time to maintain the min-heap property of the target bucket, so that events with shorter trigger times are dequeued first.

[0041] S130. In response to an event dequeue request, retrieve the top event from the active bucket of the event queue.

[0042] In this embodiment, when responding to an event dequeue request and retrieving an event with the shortest trigger time from the event queue, since the active bucket, candidate bucket, and default bucket in the event queue are arranged in ascending order of time, and each bucket is a min-heap, the top event of the active bucket, when there are events to be executed, is the event with the shortest trigger time. Therefore, the top event can be retrieved from the active bucket, and its triggering operation can be executed through the network simulator. If the active bucket is empty, the event with the shortest trigger time is found from either the candidate bucket or the default bucket based on the event storage situation of each bucket and dequeued.

[0043] The technical solution of this disclosure, in response to an event enqueue request, determines a target bucket in the event queue that matches the target event to be enqueued; the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket; the target event is inserted into the target bucket, and the events in the target bucket are heap sorted; in response to an event dequeue request, the top event is retrieved from the active bucket of the event queue, which solves the performance bottleneck problem of existing event queue scheduling algorithms when the number of scheduled events is large, and achieves the effect of reducing the event scheduling complexity based on the total number of events and improving the scheduling efficiency of the event queue.

[0044] Figure 2 This is a flowchart illustrating an event queue scheduling method provided in this embodiment. Based on the above embodiments, this embodiment further provides specific steps for determining the target bucket matching the target event to be enqueued in the event queue. Specifically, refer to... Figure 2 The method may include the following steps:

[0045] S210. In response to the enqueue request for the target event, obtain the active bucket splitting threshold and the default bucket splitting threshold of the event queue.

[0046] In this embodiment, the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket. To quickly find the bucket in the event queue where the trigger time of a given event matches, two threshold times are maintained in the event queue: the active bucket segmentation threshold and the default bucket segmentation threshold. The active bucket segmentation threshold is the upper limit of the time coverage range of the active bucket, and the default bucket segmentation threshold is the lower limit of the time coverage range of the default bucket.

[0047] In one possible implementation, obtaining the active bucket segmentation threshold and the default bucket segmentation threshold of the event queue includes: determining whether the count value of the event queue is 0; if the count value is 0, calculating the sum of the trigger time of the target event and the time capacity of a single bucket as the active bucket segmentation threshold of the event queue; and calculating the sum of the active bucket segmentation threshold and the time capacity of a preset number of buckets as the default bucket segmentation threshold of the event queue.

[0048] In this embodiment, since the trigger time of an event added later to the event queue is always after the trigger time of an event added earlier to the event queue, the active bucket segmentation threshold and the default bucket segmentation threshold of the event queue will be reset according to the trigger time of the first enqueued event. Therefore, as Figure 3 As shown, after the target event enqueue operation begins, it is first determined whether the count value of the event queue is 0. If the count value is not 0, it means that the event queue is not empty. In this case, the upper limit of the time coverage range of the active bucket in the event queue is directly obtained as the active bucket segmentation threshold, and the lower limit of the time coverage range of the default bucket is obtained as the default bucket segmentation threshold.

[0049] If the count value is 0, it indicates that the event queue is empty, and the target event becomes the first enqueued event. In this case, the active bucket segmentation threshold can be set to the sum of the target event's trigger time and the time capacity of a single bucket. Since the default bucket segmentation threshold and the active bucket segmentation threshold are separated by a preset number of candidate bucket time capacities, the default bucket segmentation threshold is set to the sum of the active bucket segmentation threshold and the time capacity of the preset number of buckets. That is, the default bucket segmentation threshold is set to the sum of the target event's trigger time and the time capacity of (preset number + 1) buckets. The time capacity of a single active bucket is the same as that of a single candidate bucket.

[0050] S220. If the trigger time of the target event is less than or equal to the active bucket segmentation threshold, then the active bucket will be used as the target bucket.

[0051] In this embodiment, as Figure 3As shown, in determining the target bucket that matches the target event E, it can first be determined whether the trigger time of the target event is before the active bucket segmentation threshold. If it is before the active bucket segmentation threshold, it is determined that the trigger time of the target event falls within the coverage of the active bucket, and the active bucket can be used as the target bucket; if it is not before the active bucket segmentation threshold, S230 is executed to further determine whether the trigger time of the target event falls within the coverage of the default bucket.

[0052] S230. If the trigger time of the target event is greater than or equal to the default bucket segmentation threshold, then the default bucket will be used as the target bucket.

[0053] In this embodiment, as Figure 3 As shown, if the trigger time of the target event is after the default bucket segmentation threshold, then the trigger time of the target event is determined to fall within the coverage of the default bucket, and the default bucket can be used as the target bucket; otherwise, the trigger time of the target event is determined to fall within the coverage of one of the candidate buckets in the event queue, and S240 can be executed to calculate the target bucket that covers its trigger time based on the time capacity of a single bucket.

[0054] S240. If the trigger time of the target event is greater than the active bucket segmentation threshold and less than the default bucket segmentation threshold, then select a candidate bucket as the target bucket based on the time capacity of a single bucket.

[0055] In this embodiment, if the triggering time of the target event is after the active bucket segmentation threshold but before the default bucket segmentation threshold, the position of the target bucket is found from the candidate bucket queue, and the target bucket is created if the target bucket does not exist.

[0056] In one possible implementation, selecting a candidate bucket as the target bucket based on the time capacity of a single bucket includes: calculating the bucket offset value of the trigger time of the target event relative to the active bucket segmentation threshold based on the time capacity of a single bucket, and using it as the candidate bucket index value; if there is no candidate bucket in the event queue that matches the candidate bucket index value, then creating a candidate bucket in the event queue at the position corresponding to the candidate bucket index value; and using the candidate bucket that matches the candidate bucket index value as the target bucket.

[0057] In this embodiment, as Figure 3 As shown, since each bucket has the same time capacity and the candidate buckets are numbered starting from 0, the candidate bucket index can be obtained by calculating (target event trigger time - active bucket segmentation threshold) / time capacity of a single bucket and rounding the result down. Since each candidate bucket is generated on demand, it is determined whether a candidate bucket corresponding to the candidate bucket index exists in the event queue. If it does not exist, a candidate bucket is created at the position corresponding to the candidate bucket index in the candidate bucket queue, and the target bucket is set to the candidate bucket matching the candidate bucket index.

[0058] If the candidate bucket numbers start from 1, the candidate bucket index value is obtained by calculating (the trigger time of the target event - the active bucket segmentation threshold) / the time capacity of a single bucket and rounding the result up.

[0059] S250. Insert the target event into the target bucket and perform heap sort on the events in the target bucket.

[0060] In one possible implementation, after inserting the target event into the target bucket and performing a heap sort on the events in the target bucket, the method further includes: incrementing the count value of the event queue by 1 to update the number of events stored in the event queue.

[0061] S260. In response to an event dequeue request, retrieve the top event from the active bucket of the event queue.

[0062] The technical solution of this disclosure improves event queuing efficiency by assembling an active bucket, multiple candidate buckets, and a default bucket into an event queue arranged in ascending order of time coverage. This is achieved by maintaining active bucket and default bucket segmentation thresholds within the event queue. This allows for quick identification of the bucket corresponding to the event's trigger time in the event queue when an event is enqueued, thus determining the event's insertion position and improving queuing efficiency. Furthermore, creating candidate buckets in the event queue as needed reduces memory consumption.

[0063] Figure 4 This is a flowchart illustrating an event queue scheduling method provided in this embodiment. Based on the above embodiments, this embodiment further provides specific steps for updating the active bucket and re-heap-sorting the default bucket after retrieving the top event from the active bucket in response to an event dequeue request. Specifically, as follows... Figure 4 As shown, the method may include the following steps:

[0064] S410. In response to an event enqueue request, determine the target bucket in the event queue that matches the target event to be enqueued.

[0065] S420. Insert the target event into the target bucket and perform heap sort on the events in the target bucket.

[0066] S430, In response to an event dequeue request, retrieve the top event from the active bucket of the event queue.

[0067] In this embodiment, as Figure 5As shown, in response to an event dequeue request, it checks whether the event queue is empty, i.e., whether the event queue count is 0. If the count is 0, dequeueing fails; if the count is not 0, according to the event enqueue operation, when the event queue is not empty, the active bucket contains at least one event. Therefore, the top event can be retrieved from the active bucket, and the event triggering operation can be executed through the network simulator.

[0068] S440. If the active bucket is not empty, perform heap sort on the events in the active bucket.

[0069] In this embodiment, as Figure 5 As shown, after the top event of the active bucket is dequeued, it is determined whether the active bucket is empty, that is, whether the count value of the active bucket is 0. If there are still events to be dequeued in the active bucket, the events in the active bucket are heap sorted to maintain the min-heap property of the active bucket, and the count value of the active bucket is reduced by 1.

[0070] In one possible implementation, after retrieving the top event from the active bucket of the event queue in response to an event dequeue request, the method further includes: decrementing the count value of the event queue by 1 to update the number of events in the event queue.

[0071] S450. If the active bucket is empty, then the candidate buckets in the event queue are used as new active buckets in turn, and the active bucket splitting threshold and the default bucket splitting threshold of the event queue are updated until the active bucket is not empty.

[0072] In this embodiment, as Figure 5 As shown, if the active bucket is empty, then when the candidate bucket queue is not empty, the candidate bucket at the head of the candidate bucket queue is selected as the active bucket, and both the active bucket splitting threshold and the default bucket splitting threshold are incremented by the time capacity of one bucket. Then, it is checked whether the current active bucket is empty. If the current active bucket is empty, it returns to check whether the candidate bucket queue is empty. If the candidate bucket queue is not empty, it returns to the step of selecting the candidate bucket at the head of the candidate bucket queue as the new active bucket, until the active bucket is not empty, or until the candidate bucket queue is empty.

[0073] It should be noted that when updating the active bucket, the count value of each candidate bucket can be used to determine whether each candidate bucket is empty. If there is a non-empty candidate bucket, the first non-empty candidate bucket in the event queue is used as the new active bucket. If all candidate buckets are empty, the last candidate bucket is used as the active bucket. The number of candidate buckets between the new active bucket and the original active bucket is determined, and both the active bucket splitting threshold and the default bucket splitting threshold are incremented by the corresponding number of bucket time capacities.

[0074] S460. Based on the updated default bucket splitting threshold, perform heap sort on the events in the default bucket.

[0075] In one possible implementation, the events in the default bucket are heap-sorted according to the updated default bucket splitting threshold, including: sequentially retrieving events from the default bucket whose trigger time is less than the default bucket splitting threshold and re-enqueuing the events; and heap-sorting the remaining events in the default bucket.

[0076] In this embodiment, after updating the default bucket splitting threshold, if there are events in the default bucket whose trigger times are less than the new default bucket splitting threshold, all events in the default bucket that do not meet the new threshold are removed, and the enqueue operation is re-executed. Furthermore, all buckets that have undergone changes, including the default bucket and the buckets where events have been re-enqueued, are re-heap-sorted to maintain their min-heap property. If the trigger times of all events in the default bucket are less than the new default bucket splitting threshold, then only the events in the default bucket are heap-sorted.

[0077] The technical solution of this disclosure improves the efficiency of event dequeueing by placing most events with earlier trigger times into the active bucket and the alternative bucket of the event queue, and placing a small number of events with later trigger times into the default bucket. This allows the event with the shortest trigger time to be dequeued quickly from the active bucket at the head of the queue when dequeuing events, and flexibly maintains the active bucket.

[0078] Figure 6 This is a schematic diagram of an event queue scheduling device provided in an embodiment of the present disclosure, as shown below. Figure 6 As shown, the device includes: a positioning module 610, an enqueue module 620, and a dequeue module 630.

[0079] The positioning module 610 is used to respond to the event enqueueing request and determine the target bucket in the event queue that matches the target event to be enqueued; the event queue consists of an active bucket, no more than a preset number of alternative buckets and a default bucket;

[0080] The enqueue module 620 is used to insert the target event into the target bucket and perform heap sort on the events in the target bucket;

[0081] The dequeue module 630 is used to perform actions in response to event dequeue requests, retrieving the top event from the active bucket of the event queue.

[0082] The technical solution provided in this disclosure, in response to an event enqueue request, determines a target bucket in the event queue that matches the target event to be enqueued; the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket; the target event is inserted into the target bucket, and the events in the target bucket are heap sorted; in response to an event dequeue request, the top event is retrieved from the active bucket of the event queue, solving the performance bottleneck problem of existing event queue scheduling algorithms when the number of scheduled events is large, and achieving the effect of reducing the event scheduling complexity based on the total number of events and improving the scheduling efficiency of the event queue.

[0083] Optionally, the positioning module 610 includes:

[0084] The acquisition unit is used to acquire the active bucket splitting threshold and the default bucket splitting threshold of the event queue.

[0085] The first positioning unit is used to execute the action of selecting the active bucket as the target bucket if the trigger time of the target event is less than or equal to the active bucket segmentation threshold.

[0086] The second positioning unit is used to execute the following: if the trigger time of the target event is greater than or equal to the default bucket segmentation threshold, then the default bucket will be used as the target bucket.

[0087] The third positioning unit is used to select a candidate bucket as the target bucket based on the time capacity of a single bucket if the trigger time of the target event is greater than the active bucket segmentation threshold and less than the default bucket segmentation threshold.

[0088] Optional, a third positioning unit, specifically used for execution:

[0089] Based on the time capacity of a single bucket, calculate the bucket offset value of the trigger time of the target event relative to the active bucket segmentation threshold, and use it as the candidate bucket index value.

[0090] If there is no candidate bucket in the event queue that matches the candidate bucket index value, then create a candidate bucket in the event queue at the position corresponding to the candidate bucket index value.

[0091] Select the candidate bucket that matches the candidate bucket index value as the target bucket.

[0092] Optional, obtain the unit, specifically used for execution:

[0093] Check if the event queue count is 0;

[0094] If the count value is 0, the sum of the trigger time of the target event and the time capacity of a single bucket is calculated and used as the active bucket segmentation threshold of the event queue.

[0095] The sum of the active bucket splitting threshold and the time capacity of a preset number of buckets is calculated and used as the default bucket splitting threshold for the event queue.

[0096] Optionally, it also includes: an update module, used to perform actions after retrieving the top event from the active bucket of the event queue in response to an event dequeue request.

[0097] If the active bucket is not empty, then perform a heap sort on the events in the active bucket;

[0098] If the active bucket is empty, the candidate buckets in the event queue will be used as new active buckets in turn, and the active bucket splitting threshold and the default bucket splitting threshold of the event queue will be updated until the active bucket is not empty.

[0099] Based on the updated default bucket splitting threshold, the events in the default bucket are heap sorted.

[0100] Optional, update module, specifically used for execution:

[0101] Events whose trigger time is less than the default bucket splitting threshold are retrieved from the default bucket in sequence, and the enqueue operation is re-executed for the events;

[0102] Perform a heap sort on the remaining events in the default bucket.

[0103] Optionally, it also includes: a counting module, used to increment the count value of the event queue by 1 after inserting the target event into the target bucket and performing heap sort on the events in the target bucket;

[0104] And, after retrieving the top event from the active bucket of the event queue in response to an event dequeue request, decrement the event queue count by 1.

[0105] The event queue scheduling apparatus provided in this disclosure can execute the event queue scheduling method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0106] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.

[0107] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Reference is made below. Figure 7 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 7The diagram below shows the structure of the terminal device or server 500. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0108] like Figure 7 As shown, electronic device 500 may include a processing unit (e.g., central processing unit, graphics processor, etc.) 501, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 502 or a program loaded from storage device 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. An edit / output (I / O) interface 505 is also connected to bus 504.

[0109] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 500 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0110] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.

[0111] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0112] The electronic device provided in this embodiment and the event queue scheduling method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0113] This disclosure provides a computer storage medium storing a computer program that, when executed by a processor, implements the event queue scheduling method provided in the above embodiments.

[0114] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0115] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0116] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0117] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to:

[0118] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: in response to an event enqueue request, determine a target bucket in an event queue that matches the target event to be enqueued; the event queue consists of an active bucket, no more than a preset number of alternative buckets, and a default bucket; insert the target event into the target bucket and perform heap sort on the events in the target bucket; and in response to an event dequeue request, retrieve the top event from the active bucket of the event queue.

[0119] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0121] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0122] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0123] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0124] According to one or more embodiments of this disclosure, Example 1 provides an event queue scheduling method, including:

[0125] In response to an event enqueue request, a target bucket matching the target event to be enqueued is determined in the event queue; the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket;

[0126] Insert the target event into the target bucket, and perform heap sort on the events in the target bucket;

[0127] In response to an event dequeue request, the top event is retrieved from the active bucket of the event queue.

[0128] According to one or more embodiments of this disclosure, Example 2, based on the method described in Example 1, includes determining the target bucket in the event queue that matches the target event to be enqueued, comprising:

[0129] Obtain the active bucket splitting threshold and the default bucket splitting threshold of the event queue;

[0130] If the trigger time of the target event is less than or equal to the active bucket segmentation threshold, then the active bucket is used as the target bucket.

[0131] If the trigger time of the target event is greater than or equal to the default bucket segmentation threshold, then the default bucket is used as the target bucket;

[0132] If the trigger time of the target event is greater than the active bucket segmentation threshold and less than the default bucket segmentation threshold, then a candidate bucket is selected as the target bucket based on the time capacity of a single bucket.

[0133] According to one or more embodiments of this disclosure, Example 3, based on the method described in Example 2, includes selecting a candidate bucket as the target bucket based on the time capacity of a single bucket, comprising:

[0134] Based on the time capacity of the individual bucket, calculate the bucket offset value of the trigger time of the target event relative to the active bucket segmentation threshold, and use it as the candidate bucket index value;

[0135] If there is no candidate bucket in the event queue that matches the candidate bucket index value, then a candidate bucket is created in the event queue at the position corresponding to the candidate bucket index value.

[0136] The candidate bucket that matches the candidate bucket index value is selected as the target bucket.

[0137] According to one or more embodiments of this disclosure, Example 4, based on the method described in Example 2, includes obtaining the active bucket segmentation threshold and the default bucket segmentation threshold of the event queue, comprising:

[0138] Determine whether the count value of the event queue is 0;

[0139] If the count value is 0, the sum of the trigger time of the target event and the time capacity of a single bucket is calculated as the active bucket segmentation threshold of the event queue.

[0140] The sum of the active bucket segmentation threshold and the time capacity of a preset number of buckets is calculated and used as the default bucket segmentation threshold for the event queue.

[0141] According to one or more embodiments of this disclosure, Example 5, based on the method of Example 1, further includes, after retrieving the top event from the active bucket of the event queue in response to an event dequeue request:

[0142] If the active bucket is not empty, then the events in the active bucket are heap sorted.

[0143] If the active bucket is empty, then the candidate buckets in the event queue are used as new active buckets in turn, and the active bucket splitting threshold and the default bucket splitting threshold of the event queue are updated until the active bucket is not empty.

[0144] Based on the updated default bucket splitting threshold, the events in the default bucket are heap sorted.

[0145] According to one or more embodiments of this disclosure, Example 6 describes the method described in Example 5, wherein the step of heap-sorting the events in the default bucket based on the updated default bucket splitting threshold includes:

[0146] Events whose trigger time is less than the default bucket segmentation threshold are sequentially retrieved from the default bucket, and the enqueue operation is re-executed for the events;

[0147] Perform a heap sort on the remaining events in the default bucket.

[0148] According to one or more embodiments of this disclosure, Example 7, based on the method of Example 1, further includes, after inserting the target event into the target bucket and performing heap sort on the events in the target bucket:

[0149] Increment the count value of the event queue by 1;

[0150] And, after retrieving the top-of-the-heap event from the active bucket of the event queue in response to the event dequeue request, the method further includes:

[0151] Decrease the count value of the event queue by 1.

[0152] According to one or more embodiments of this disclosure, Example 8 provides an event queue scheduling apparatus, comprising:

[0153] The positioning module is used to respond to an event enqueueing request by determining the target bucket in the event queue that matches the target event to be enqueued; the event queue consists of an active bucket, no more than a preset number of candidate buckets, and a default bucket;

[0154] The enqueue module is used to insert the target event into the target bucket and perform heap sort on the events in the target bucket;

[0155] The dequeue module is used to retrieve the top event from the active bucket of the event queue in response to an event dequeue request.

[0156] According to one or more embodiments of this disclosure, Example 9 provides an electronic device, the electronic device comprising:

[0157] One or more processors;

[0158] Storage device for storing one or more programs.

[0159] When the one or more programs are executed by the one or more processors, the one or more processors implement the event queue scheduling method as described in any of Examples 1-7.

[0160] According to one or more embodiments of the present disclosure, Example 10 provides a storage medium containing computer-executable instructions that, when executed by a computer processor, are used to perform an event queue scheduling method as described in any of Examples 1-7.

[0161] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0162] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0163] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. An event queue scheduling method, characterized in that, include: In response to an event enqueue request, determine the target bucket in the event queue that matches the target event to be enqueued; The event queue consists of an active bucket, no more than a preset number of alternative buckets, and a default bucket. Insert the target event into the target bucket, and perform heap sort on the events in the target bucket; In response to an event dequeue request, the top event is retrieved from the active bucket of the event queue; The step of determining the target bucket that matches the target event to be enqueued in the event queue includes: Obtain the active bucket splitting threshold and the default bucket splitting threshold of the event queue; If the trigger time of the target event is less than or equal to the active bucket segmentation threshold, then the active bucket is used as the target bucket. If the trigger time of the target event is greater than or equal to the default bucket segmentation threshold, then the default bucket is used as the target bucket; If the trigger time of the target event is greater than the active bucket segmentation threshold and less than the default bucket segmentation threshold, then a candidate bucket is selected as the target bucket based on the time capacity of a single bucket. Each bucket has a time coverage range, the active bucket segmentation threshold is the upper limit of the time coverage range of the active bucket, and the default bucket segmentation threshold is the lower limit of the time coverage range of the default bucket.

2. The method according to claim 1, characterized in that, The step of selecting a candidate bucket as the target bucket based on the time capacity of a single bucket includes: Based on the time capacity of the individual bucket, calculate the bucket offset value of the trigger time of the target event relative to the active bucket segmentation threshold, and use it as the candidate bucket index value; If there is no candidate bucket in the event queue that matches the candidate bucket index value, then a candidate bucket is created in the event queue at the position corresponding to the candidate bucket index value. The candidate bucket that matches the candidate bucket index value is selected as the target bucket.

3. The method according to claim 1, characterized in that, The step of obtaining the active bucket splitting threshold and the default bucket splitting threshold of the event queue includes: Determine whether the count value of the event queue is 0; If the count value is 0, the sum of the trigger time of the target event and the time capacity of a single bucket is calculated as the active bucket segmentation threshold of the event queue. The sum of the active bucket segmentation threshold and the time capacity of a preset number of buckets is calculated and used as the default bucket segmentation threshold for the event queue.

4. The method according to claim 1, characterized in that, After retrieving the top-of-the-heap event from the active bucket of the event queue in response to an event dequeue request, the method further includes: If the active bucket is not empty, then the events in the active bucket are heap sorted. If the active bucket is empty, then the candidate buckets in the event queue are used as new active buckets in turn, and the active bucket splitting threshold and the default bucket splitting threshold of the event queue are updated until the active bucket is not empty. Based on the updated default bucket splitting threshold, the events in the default bucket are heap sorted.

5. The method according to claim 4, characterized in that, The step of performing heap sort on the events in the default bucket based on the updated default bucket splitting threshold includes: Events whose trigger time is less than the default bucket segmentation threshold are sequentially retrieved from the default bucket, and the enqueue operation is re-executed for the events; Perform a heap sort on the remaining events in the default bucket.

6. The method according to claim 1, characterized in that, After inserting the target event into the target bucket and performing heap sort on the events in the target bucket, the method further includes: Increment the count value of the event queue by 1; And, after retrieving the top-of-the-heap event from the active bucket of the event queue in response to the event dequeue request, the method further includes: Decrease the count value of the event queue by 1.

7. An event queue scheduling device, characterized in that, include: The positioning module is used to respond to event enqueueing requests and determine the target bucket in the event queue that matches the target event to be enqueued. The event queue consists of an active bucket, no more than a preset number of alternative buckets, and a default bucket. The enqueue module is used to insert the target event into the target bucket and perform heap sort on the events in the target bucket; The dequeue module is used to retrieve the top event from the active bucket of the event queue in response to an event dequeue request. The positioning module includes: an acquisition unit, used to acquire the active bucket segmentation threshold and the default bucket segmentation threshold of the event queue; The first positioning unit is used to execute the action of selecting the active bucket as the target bucket if the trigger time of the target event is less than or equal to the active bucket segmentation threshold. The second positioning unit is used to execute the following: if the trigger time of the target event is greater than or equal to the default bucket segmentation threshold, then the default bucket will be used as the target bucket. The third positioning unit is used to select a candidate bucket as the target bucket based on the time capacity of a single bucket if the trigger time of the target event is greater than the active bucket segmentation threshold and less than the default bucket segmentation threshold. Each bucket has a time coverage range, the active bucket segmentation threshold is the upper limit of the time coverage range of the active bucket, and the default bucket segmentation threshold is the lower limit of the time coverage range of the default bucket.

8. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the event queue scheduling method as described in any one of claims 1-6.

9. A storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the event queue scheduling method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Scheduling method and system applied to wireless communication system simulation

    CN103929769A

  • Scheduling non-integral simulation time for mixed-signal simulation

    EP1061463A2