A method, apparatus, device and medium for processing a device hot plug event

CN117667802BActive Publication Date: 2026-10-27INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311606258.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-28
Publication Date
2026-10-27
Estimated Expiration
2043-11-28

AI Technical Summary

Technical Problem

[0003]在对PCIe设备进行热插拔的过程中,可能会出现以下情况:1、设备频繁快速插拔;2、多个设备同时插拔;3、设备故障反复通电和断电,此时系统会频繁、反复地接收到大量设备插入和拔出的信号,系统对这些信号进行处理时可能会出现混乱,导致资源泄露、系统卡顿甚至宕机等严重问题

Benefits of technology

[0031]本发明的实施例通过获取事件列表并初始化,监听目标设备的插入插槽事件或拔出插槽事件,当监听到所述插入插槽事件时若所述目标设备不是新加入设备将所述插入插槽事件加入到所述事件列表中,当监听到所述拔出插槽事件时若所述事件列表不存在所述插入插槽事件则卸载所述目标设备对应的驱动以完成所述拔出插槽事件,按预设时间间隔对所述事件列表进行检测若所述事件列表存在所述插入插槽事件且满足预设条件则添加所述目标设备对应的驱动以完成所述插入插槽事件,避免了PCIe设备频繁插拔、反复通断等情况带来的系统处理混乱、内存泄漏等问题,提高了设备发生热插拔事件时系统的稳定性和高可用性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117667802B_ABST
    Figure CN117667802B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a device hot plug event processing method, device, apparatus and medium, by acquiring an event list and initializing, listening to a plug-in slot event or a plug-out slot event of a target device, if the target device is not a newly added device when the plug-in slot event is listened to, adding the plug-in slot event to the event list, if the event list does not exist the plug-in slot event when the plug-out slot event is listened to, uninstalling a driver corresponding to the target device to complete the plug-out slot event, detecting the event list at a preset time interval, if the event list exists the plug-in slot event and satisfies a preset condition, adding the driver corresponding to the target device to complete the plug-in slot event, avoiding system processing confusion, memory leakage and other problems caused by frequent plug-in and plug-out of PCIe devices, repeated on-off and other situations, and improving the stability and high availability of the system when a device hot plug event occurs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer hardware devices, and in particular to a method, apparatus, device, and medium for handling hot-plug events. Background Technology

[0002] A large data center typically consists of servers, switches, storage devices, and other components. Data communication throughout the data center relies heavily on a crucial component: PCIe devices. PCIe (Eripheral Component Interconnect Express) is a high-speed serial computer expansion bus standard. PCIe devices refer to devices with interfaces using this standard, such as high-speed network cards, solid-state drives for data storage, and graphics cards for computing. These components are generally plugged into slots on servers or storage devices. In certain situations, hot-swapping (inserting or removing devices without powering off or interrupting system applications) is necessary, such as in scenarios where equipment failure requires replacement, to ensure the system remains online and provides continuous service.

[0003] During the hot-swapping of PCIe devices, the following situations may occur: 1. Frequent and rapid insertion and removal of devices; 2. Simultaneous insertion and removal of multiple devices; 3. Repeated power-on and power-off of device malfunctions. In this case, the system will frequently and repeatedly receive a large number of device insertion and removal signals. When the system processes these signals, it may become chaotic, leading to serious problems such as resource leaks, system lag, or even system crashes. Summary of the Invention

[0004] In view of the above problems, a method, apparatus, device, and storage medium for handling device hot-plug events are proposed to overcome or at least partially solve the above problems, including:

[0005] Get the event list and initialize it;

[0006] Listen for insertion or removal events of the target device from the slot.

[0007] When the insertion slot event is detected, if the target device is not a newly added device, the insertion slot event is added to the event list;

[0008] When the "remove from slot" event is detected, if the "insert into slot" event does not exist in the event list, the driver corresponding to the target device is uninstalled to complete the "remove from slot" event.

[0009] The event list is checked at preset time intervals. If the event list contains the insertion slot event and meets the preset conditions, the driver corresponding to the target device is added to complete the insertion slot event.

[0010] Optionally, the preset conditions include:

[0011] After the target device is inserted into the slot, it needs to wait for a preset time to add the driver, and the time difference between the current time and the time when the slot insertion event occurs exceeds the preset time.

[0012] Optionally, before the step of obtaining the event list and initializing, the following steps are included:

[0013] Obtain device information for all online devices and save the device information in a device information list.

[0014] Optionally, the step of adding the slot insertion event to the event list when the target device is not a newly added device after the slot insertion event is detected includes:

[0015] When the insertion slot event is detected, it is determined whether the target device is a newly added device based on the device information list;

[0016] If the target device is not a newly added device, add the insertion slot event to the event list.

[0017] Optionally, after the step of listening to the insertion or removal event of the target device, the method further includes:

[0018] When the insertion slot event is detected, if the target device is a newly added device, the driver corresponding to the target device is added to complete the insertion slot event.

[0019] Optionally, after the step of listening to the insertion or removal event of the target device, the method further includes:

[0020] When the "Remove from Slot" event is detected, if the "Insert into Slot" event exists in the event list, the "Insert into Slot" event is removed to complete the "Remove from Slot" event.

[0021] Optionally, the device information includes:

[0022] Device identifier, time the device was inserted into the slot, and the number of times the device was inserted into the slot.

[0023] A device hot-plug event handling apparatus, the apparatus comprising:

[0024] The event list retrieval module is used to retrieve and initialize the event list.

[0025] The event listener module is used to listen for insertion or removal events of the target device into the slot.

[0026] An insertion event handling module is used to add the insertion slot event to the event list when the insertion slot event is detected, if the target device is not a newly added device.

[0027] The unplug event handling module is used to unload the driver corresponding to the target device when the unplug slot event is detected, if the insertion slot event does not exist in the event list, so as to complete the unplug slot event.

[0028] The event list processing module is used to detect the event list at preset time intervals. If the event list contains the insertion slot event and meets the preset conditions, the driver corresponding to the target device is added to complete the insertion slot event.

[0029] An electronic device for handling device hot-plug events includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When executed by the processor, the computer program implements the steps of the device hot-plug event handling method as described above.

[0030] A computer-readable storage medium for device hot-plug events, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the steps of the device hot-plug event processing method as described above.

[0031] The embodiments of the present invention acquire and initialize an event list, listen for insertion or removal events of a target device, and add the insertion event to the event list if the target device is not a newly added device when the insertion event is detected. If the insertion event is not present in the event list when the removal event is detected, the driver corresponding to the target device is uninstalled to complete the removal event. The event list is checked at preset time intervals. If the insertion event exists in the event list and the preset conditions are met, the driver corresponding to the target device is added to complete the insertion event. This avoids system processing chaos and memory leaks caused by frequent insertion and removal of PCIe devices and repeated switching, and improves the stability and high availability of the system when hot-plugging events occur. Attached Figure Description

[0032] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a flowchart of the steps of a method for handling device hot-plug events according to an embodiment of the present invention;

[0034] Figure 2 This is a schematic diagram of the implementation location of the anti-shake strategy provided in an embodiment of the present invention;

[0035] Figure 3 This is a flowchart illustrating a specific implementation of the anti-shake strategy provided in an embodiment of the present invention;

[0036] Figure 4 This is a structural block diagram of a device for handling hot-plug events according to an embodiment of the present invention. Detailed Implementation

[0037] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0038] When a PCIe device is hot-plugged, the resulting system processing chaos and memory leaks can be collectively referred to as system jitter. Strategies to minimize or avoid this jitter are simply called anti-jitter strategies. While existing technologies include hardware or operating system-level protection measures to reduce system jitter, the individual driver applications for PCIe devices lack anti-jitter functionality.

[0039] like Figure 2 As shown, the operating system's memory space is divided according to the access permissions of user operation instructions, into the protected kernel space and the user space outside the protected memory space. For example, if the memory space is 4GB, then the higher-level 1GB address space (0xFFFFFFFF-0xC0000000) is the protected space and is defined as the kernel space, while the lower-level other 3GB address space (0xC0000000-0x00000000) is allocated as user space.

[0040] The kernel space can directly communicate with hardware devices, performing low-level operations such as system interface calls, memory management, and hardware driver management. While user space cannot directly access hardware devices, it can interact with kernel-mode drivers in the kernel space through user-mode drivers, feeding back device operating status and other information to higher-level applications for processing to implement corresponding business logic.

[0041] When PCIe devices such as fiber optic network cards and Ethernet cards are hot-plugged, the system first captures the hot-plug event of the hardware through the PCIe hot-plug driver in the kernel space, performs basic event processing (such as responding to the signal of receiving the device being inserted or removed), and then passes the hot-plug information to the kernel-mode driver for related driver processing (such as adding or unloading the driver).

[0042] The main embodiment of this invention is to set an anti-bouncing strategy (such as...) during the information exchange between the PCIe hot-plug driver and the kernel-mode driver. Figure 2 (As shown in the debouncing position), when hot-plugging information is transmitted to the kernel-mode driver, the debouncing strategy is first used for debouncing processing, and then the relevant driver processing is performed.

[0043] The core concept of this invention is that when a device is inserted into a slot, instead of immediately responding to the device insertion signal to perform the corresponding driver addition operation, a fake preprocessing method is adopted. That is, in response to the device insertion signal, the system kernel is immediately returned with a callback result indicating that the slot insertion event has been completed. In fact, no driver addition processing is performed. Instead, the slot insertion event is placed in an event list to wait for processing. If the device meets the preset conditions, the driver addition processing is performed only after a preset time. This delayed device driver addition processing method is the debouncing strategy adopted in this invention.

[0044] Reference Figure 1 The diagram illustrates a flowchart of a method for handling device hot-plug events according to an embodiment of the present invention, which may specifically include the following steps:

[0045] Step 101: Obtain the event list and initialize it;

[0046] In this embodiment of the invention, the event list can be a linked list (List) data type, storing device information and corresponding insertion or removal event information from slots. To prevent historical events that have remained unprocessed due to system processing errors from remaining in the event list, the event list needs to be cleared and initialized.

[0047] Step 102: Listen for the insertion or removal event of the target device into the slot;

[0048] In this embodiment of the invention, the target device can be a PCIe device, such as an Ethernet card, fiber optic network card, sound card, graphics card, disk array, memory module, etc. When the device is inserted into or removed from a specific slot, an insertion or removal signal is reported to the system kernel, and the system performs relevant processing after receiving the signal.

[0049] Step 103: When the insertion slot event is detected, if the target device is not a newly added device, add the insertion slot event to the event list;

[0050] In some embodiments, prior to step 101, the method further includes:

[0051] Step 1001: Obtain device information for all online devices and save the device information in the device information list.

[0052] When the main device is powered on, the system iterates through the device information of all PCIe devices connected to and online with the main device, and saves all device information in the device list. For example... Figure 3 As shown, dev0, dev1, dev2, etc. in the device list represent the device information corresponding to each PCIe device.

[0053] The device information may include: device identifier, the time the device was inserted into the slot, and the number of times the device was inserted into the slot.

[0054] The device identifier, which can be the BDF (Bus-Device-Function) identifier of a PCIe device, consists of three parts: Bus Number, Device Number, and Function Number. In the BDF, the Bus Number occupies 8 bits, the Device Number occupies 5 bits, and the Function Number occupies 3 bits. The Function Number represents a function that may include a hard drive interface, display controller, Ethernet controller, USB controller, etc. The BDF identifier serves as a unique identifier for PCIe devices, allowing the corresponding device information to be found in the device list.

[0055] The time when the device is inserted into the slot can be recorded when the system receives the insertion signal reported by the device, and only the latest insertion time into the slot is recorded.

[0056] The number of times the device is inserted into the slot is counted, that is, every time an insertion signal reported by the device is received, a count is performed and the count is updated.

[0057] Step 103 includes:

[0058] Sub-step 131: When the insertion slot event is detected, determine whether the target device is a newly added device based on the device information list;

[0059] Sub-step 132: If the target device is not a newly added device, add the insertion slot event to the event list.

[0060] like Figure 3As shown, when a PCIe device insertion slot event is detected, the device is searched in the device list based on its BDF identifier. If the corresponding device information is found, it indicates that the device is not a newly added device, and it is preliminarily determined that the device may require debouncing. The insertion slot time is then added to the event list, awaiting processing by the event handler. Simultaneously, the latest insertion slot time and insertion slot count are updated.

[0061] In some embodiments, after step 102, the following is included:

[0062] Step 1021: When the insertion slot event is detected, if the target device is a newly added device, add the driver corresponding to the target device to complete the insertion slot event.

[0063] like Figure 3 As shown, if no matching device information is found in the device list, the device is being inserted into the slot for the first time, i.e., a newly added device. Generally, adding a driver for a newly added device for the first time will not conflict with the driver processing of existing devices. Therefore, debouncing is not required, and the event does not need to be added to the event list. The corresponding driver for the device can be added directly to complete the insertion into the slot event.

[0064] Step 104: When the "remove from slot" event is detected, if the "insert into slot" event does not exist in the event list, the driver corresponding to the target device is uninstalled to complete the "remove from slot" event.

[0065] In embodiments of the present invention, such as Figure 3 As shown, when a PCIe device is detected to be removed from its slot, the system first checks the event list to see if there is a corresponding insertion event for that device. If it is not detected, it means that the insertion event for that device has already been completed and is not in a pending intermediate state, so it will not cause a conflict in driver processing. In this case, the system directly uninstalls the driver corresponding to that device and completes the removal event for that device from its slot.

[0066] In some embodiments, after step 102, the method further includes:

[0067] Step 1022: When the "remove slot" event is detected, if the "insert slot" event exists in the event list, the "insert slot" event is removed to complete the "remove slot" event.

[0068] like Figure 3As shown, when a slot removal event is detected, if a corresponding slot insertion event for the target device is found in the event list, it indicates that the slot insertion event for that device is in a waiting state and has not been processed. Therefore, the slot insertion event is removed from the event list, and the subsequent steps of adding the device driver are not required. Since the device driver has not been added, there is no need to uninstall the device driver; the slot removal event is completed directly after removing the slot insertion event.

[0069] Step 105: Detect the event list at preset time intervals. If the event list contains the insertion slot event and meets the preset conditions, add the driver corresponding to the target device to complete the insertion slot event.

[0070] The preset conditions include:

[0071] After the target device is inserted into the slot, it needs to wait for a preset time to add the driver, and the time difference between the current time and the time when the slot insertion event occurs exceeds the preset time.

[0072] In this embodiment of the invention, based on the principle of delayed sampling and multiple sampling, the event processor will detect the event list at a preset time interval (e.g., once every 1 second), traverse the event list (List), and determine whether there is an insertion slot event that needs to be processed. If an insertion slot event is detected, it will first determine whether the target device corresponding to the event needs to adopt a debouncing strategy, that is, after the target device inserts into the slot, it needs to wait for a preset time before adding the driver.

[0073] In practical applications, the need for debouncing strategies can be determined based on the type of PCIe device inserted into the slot. For example, Ethernet cards are inherently slower at processing data, and the initialization processes performed after adding drivers for these devices are also slow, leading to system delays. Therefore, debouncing strategies are necessary for this type of PCIe device. On the other hand, fiber optic network cards (FC cards), due to their high performance and fast data processing speed, do not require debouncing strategies and can be added directly with drivers. By customizing debouncing strategies for different types of devices, the system's efficiency in handling hot-plug events can be improved, ensuring system stability while also meeting performance requirements.

[0074] If it is determined that the target device requires a debounce strategy, then it is further determined whether the time difference between the current time and the time of the slot insertion event exceeds the preset duration defined in the debounce strategy. If it exceeds the preset duration, the device driver is added, the slot insertion event is completed, and the event is removed from the event list. If it does not exceed the preset duration, the event is ignored, and the next round of traversal of the event list begins.

[0075] In practical applications, the types of devices requiring stabilization strategies and the preset duration of these strategies can both be configured through a configuration file. This configuration file can adjust the stabilization strategy and perform differentiated configurations based on the characteristics of different devices and business needs, and is preloaded after obtaining the event list and device list.

[0076] In some embodiments, the entire hot-plugging process of the device can be recorded in a log, and the anti-shake process can be viewed by debugging the log, so as to test and verify the anti-shake effect in a fast plugging and unplugging manner.

[0077] The embodiments of the present invention acquire and initialize an event list, listen for insertion or removal events of a target device, and add the insertion event to the event list if the target device is not a newly added device when the insertion event is detected. If the insertion event is not present in the event list when the removal event is detected, the driver corresponding to the target device is uninstalled to complete the removal event. The event list is checked at preset time intervals. If the insertion event exists in the event list and the preset conditions are met, the driver corresponding to the target device is added to complete the insertion event. This avoids system processing chaos and memory leaks caused by frequent insertion and removal of PCIe devices and repeated switching, and improves the stability and high availability of the system when hot-plugging events occur.

[0078] Reference Figure 4 The diagram illustrates a structural block diagram of a device hot-plug event handling apparatus according to an embodiment of the present invention, which may specifically include the following modules:

[0079] Event list retrieval module 401 is used to retrieve and initialize the event list;

[0080] Event listening module 402 is used to listen for insertion or removal events of the target device into the slot;

[0081] The insertion event handling module 403 is used to add the insertion slot event to the event list when the insertion slot event is detected, if the target device is not a newly added device.

[0082] The unplug event handling module 404 is used to unload the driver corresponding to the target device when the unplug slot event is detected, if the insertion slot event does not exist in the event list, so as to complete the unplug slot event.

[0083] The event list processing module 405 is used to detect the event list at preset time intervals. If the event list contains the insertion slot event and meets the preset conditions, the driver corresponding to the target device is added to complete the insertion slot event.

[0084] In one embodiment of the present invention, the preset conditions include:

[0085] After the target device is inserted into the slot, it needs to wait for a preset time to add the driver, and the time difference between the current time and the time when the slot insertion event occurs exceeds the preset time.

[0086] In one embodiment of the present invention, the device further includes:

[0087] The device list generation module is used to obtain device information of all online devices and save the device information in the device information list.

[0088] In one embodiment of the present invention, the insertion event handling module 403 includes:

[0089] The newly added device determination submodule is used to determine whether the target device is a newly added device based on the device information list when the insertion slot event is detected.

[0090] An insertion event handling submodule is used to add the insertion slot event to the event list if the target device is not a newly added device.

[0091] In one embodiment of the present invention, the device further includes:

[0092] The newly added device driver addition module is used to add the driver corresponding to the target device when the insertion slot event is detected, if the target device is a newly added device, in order to complete the insertion slot event.

[0093] In one embodiment of the present invention, the device further includes:

[0094] The Remove Event module is used to remove the Insert Slot event when the Remove Slot event is detected, if the Insert Slot event exists in the event list, in order to complete the Remove Slot event.

[0095] In one embodiment of the present invention, the device information includes:

[0096] Device identifier, time the device was inserted into the slot, and the number of times the device was inserted into the slot.

[0097] An embodiment of the present invention also provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-mentioned method for handling hot-plug events of the device.

[0098] An embodiment of the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned method for handling hot-plug events of a device.

[0099] The readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0100] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0101] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0102] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0103] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

[0104] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

[0105] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0106] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0107] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0108] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0109] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0110] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1The steps of the function specified in one or more boxes.

[0111] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0112] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the aforementioned element.

[0113] The above provides a detailed description of the data synchronization method, apparatus, electronic device, and storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for handling device hot-plug events, characterized in that, The method includes: Get the event list and initialize it; Listen for insertion or removal events of the target device from the slot. When the insertion slot event is detected, if the target device is not a newly added device, the insertion slot event is added to the event list; When the "remove from slot" event is detected, if the "insert into slot" event does not exist in the event list, the driver corresponding to the target device is uninstalled to complete the "remove from slot" event. The event list is checked at preset time intervals. If the event list contains the insertion slot event and meets the preset conditions, the driver corresponding to the target device is added to complete the insertion slot event. The preset conditions include: After the target device is inserted into the slot, it needs to wait for a preset time to add the driver, and the time difference between the current time and the time when the slot insertion event occurs exceeds the preset time. Prior to the step of obtaining and initializing the event list, the following is included: Obtain device information for all online devices and save the device information in a device information list; The step of adding the slot insertion event to the event list when the target device is not a newly added device after the slot insertion event is detected includes: When the insertion slot event is detected, it is determined whether the target device is a newly added device based on the device information list; If the target device is not a newly added device, add the insertion slot event to the event list; Following the step of monitoring the insertion or removal event of the target device, the method further includes: When the "Remove from Slot" event is detected, if the "Insert into Slot" event exists in the event list, the "Insert into Slot" event is removed to complete the "Remove from Slot" event.

2. The method according to claim 1, characterized in that, Following the step of monitoring the insertion or removal event of the target device, the method further includes: When the insertion slot event is detected, if the target device is a newly added device, the driver corresponding to the target device is added to complete the insertion slot event.

3. The method according to claim 1, characterized in that, The device information includes: Device identifier, time the device was inserted into the slot, and the number of times the device was inserted into the slot.

4. A device for handling hot-plug events, characterized in that, The device includes: The event list retrieval module is used to retrieve and initialize the event list. The event listener module is used to listen for insertion or removal events of the target device into the slot. An insertion event handling module is used to add the insertion slot event to the event list when the insertion slot event is detected, if the target device is not a newly added device. The unplug event handling module is used to unload the driver corresponding to the target device when the unplug slot event is detected, if the insertion slot event does not exist in the event list, so as to complete the unplug slot event. An event list processing module is used to detect the event list at preset time intervals. If the event list contains the insertion slot event and meets preset conditions, the driver corresponding to the target device is added to complete the insertion slot event. The preset conditions include: After the target device is inserted into the slot, it needs to wait for a preset time to add the driver, and the time difference between the current time and the time when the slot insertion event occurs exceeds the preset time. The device further includes: The device list generation module is used to obtain device information of all online devices and save the device information in the device information list; The insertion event handling module includes: The newly added device determination submodule is used to determine whether the target device is a newly added device based on the device information list when the insertion slot event is detected. An insertion event handling submodule is used to add the insertion slot event to the event list if the target device is not a newly added device; The device further includes: The Remove Event module is used to remove the Insert Slot event when the Remove Slot event is detected, if the Insert Slot event exists in the event list, in order to complete the Remove Slot event.

5. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements a method for handling device hot-plug events as described in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements a method for handling device hot-plug events as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method and device for dynamically adjusting hitting of target data based on time intervals

    CN104156551A

  • Event identification with out-of-order reporting in a cloud-based environment

    US11016824B1