Proxy method for high-frequency polling of operating system, electronic device and storage medium
Patent Information
- Application Number
- PCT/CN2025/128774
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-03-28
- Filing Date
- 2025-10-20
- Publication Date
- 2026-10-01
Smart Images

Figure CN2025128774_01102026_PF_FP_ABST
Abstract
Description
High-frequency polling proxy methods for operating systems, electronic devices and storage media
[0001] Cross-references to related applications
[0002] This application claims priority to Chinese Patent Application No. 202510386582.X, filed on March 28, 2025, entitled “A proxy method for high-frequency polling of an operating system, an electronic device and a storage medium”, the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of computer technology, and in particular to proxy methods for high-frequency polling of operating systems, electronic devices, and non-volatile readable storage media. Background Technology
[0004] Currently, most BMC (Baseboard Management Controller) systems adopt a solution that runs the Linux operating system on the main core. Linux, with its rich functionality and strong community support, can meet various business needs. Polling is a common hardware event detection mechanism, especially in scenarios without interrupt support, where it obtains event information by periodically checking the status of hardware registers.
[0005] In related technologies, when hardware events do not support interrupts, the Linux system cannot passively receive notifications and must actively poll. However, this method causes the resources of the Linux operating system's core, such as the central processing unit, to be occupied for extended periods, preventing it from processing other tasks and thus reducing overall system efficiency, which urgently needs to be addressed. Summary of the Invention
[0006] This application provides a proxy method, electronic device, and non-volatile readable storage medium for high-frequency polling of the operating system, so as to at least solve the problem that the central processing unit is occupied for a long time and cannot process other tasks due to high-frequency polling of the main core operating system, thereby achieving the technical effect of reducing system resource consumption.
[0007] This application provides a proxy method for high-frequency polling of an operating system, characterized in that the method is applied to a co-core operating system running on the co-core side of a baseboard management controller, wherein the method includes the following steps:
[0008] Respond to polling agent commands, which are generated by the main core operating system running on the main core of the baseboard management controller;
[0009] Polling agent commands are used to poll at least one register to be polled, generating polling results for at least one register to be polled;
[0010] Send at least one polling result and an interrupt signal from the pending polling register to the main core operating system to wake up the current business process of the main core operating system via the interrupt signal. Before the co-core operating system responds to the polling agent command, the main core operating system controls the current business process to enter a sleep state.
[0011] This application also provides another proxy method for high-frequency polling of an operating system, characterized in that the method is applied to a main core operating system running on the main core of a baseboard management controller, wherein the method includes the following steps:
[0012] Determine if the current business process requires polling the register;
[0013] If the current business process requires polling the register, generate a polling proxy command;
[0014] Send polling agent commands to the co-core operating system and receive the polling results generated by the co-core operating system after polling the register to be polled.
[0015] This application provides a proxy device for high-frequency polling of an operating system, characterized in that the device is applied to a co-core operating system running on the co-core side of a baseboard management controller, wherein the device includes:
[0016] The response module is used to respond to polling agent commands, which are generated by the main core operating system running on the main core of the baseboard management controller.
[0017] The polling module is used to poll at least one register to be polled based on the polling agent command, and generate the polling result of at least one register to be polled;
[0018] The sending module is used to send the polling result of at least one polling register and an interrupt signal to the main core operating system, so as to wake up the current business process of the main core operating system through the interrupt signal. Before the co-core operating system responds to the polling agent command, the main core operating system controls the current business process to enter a sleep state.
[0019] This application also provides another proxy device for high-frequency polling of an operating system, characterized in that the device is applied to a main core operating system running on the main core of a baseboard management controller, wherein the device includes:
[0020] The judgment module is used to determine whether the current business process requires polling the register;
[0021] The generation module is used to generate polling proxy commands when the current business process requires polling registers.
[0022] The transceiver module is used to send polling agent commands to the co-core operating system and receive the polling results generated by the co-core operating system after polling the register to be polled.
[0023] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the agent method of high-frequency polling of any of the above-described operating systems when executing the computer program.
[0024] This application also provides a non-volatile readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the agent method for high-frequency polling of any of the above-mentioned operating systems.
[0025] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the agent method for high-frequency polling of any of the above-described operating systems.
[0026] This application addresses the issue of a polling agent command generated by the main operating system running on the main core of the baseboard management controller. Based on this command, at least one register to be polled is polled. The polling result of each register, along with an interrupt signal, is sent to the main operating system to wake up its current business process via the interrupt signal. Before the co-core operating system responds to the polling agent command, the main operating system puts the current business process into a sleep state. Therefore, by utilizing the co-core operating system to perform high-frequency polling instead of the main operating system, the problem of the central processing unit being occupied for extended periods and unable to handle other tasks due to high-frequency polling by the main operating system is solved, achieving the technical effect of reducing system resource consumption. Attached Figure Description
[0027] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 is a flowchart of a proxy method for high-frequency polling of an operating system provided in an embodiment of this application;
[0029] Figure 2 is a schematic diagram of the architecture of the high-frequency polling agent system of the operating system provided in the embodiment of this application;
[0030] Figure 3 is a flowchart of another proxy method for high-frequency polling of an operating system provided in an embodiment of this application;
[0031] Figure 4 is a block diagram of an operating system high-frequency polling proxy device provided in an embodiment of this application;
[0032] Figure 5 is a block diagram of another high-frequency polling agent device for an operating system provided in an embodiment of this application;
[0033] Figure 6 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0034] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0035] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0036] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0037] The embodiments of this application provide a proxy method for high-frequency polling in an operating system. The method is described in detail below in conjunction with the execution flow of the proxy method for high-frequency polling in an operating system.
[0038] Figure 1 is a flowchart of a proxy method for high-frequency polling of the operating system according to some embodiments of this application.
[0039] For example, as shown in Figure 1, the high-frequency polling proxy method of the operating system is applied to a co-core operating system running on the co-core side of the baseboard management controller, wherein the method includes the following steps:
[0040] In step S101, a polling agent command is responded to, wherein the polling agent command is generated by the main core operating system running on the main core of the baseboard management controller.
[0041] Polling is a method for checking hardware status, specifically checking if a certain condition is met, such as whether the value of a register has changed. The polling agent command refers to the instruction generated by the main core operating system that instructs the co-core operating system to begin polling. The baseboard management controller (BMC) is an embedded processor used to monitor, report, and control the status of server hardware. The main core operating system can be Linux. The co-core operating system can be a Real-Time Operating System (RTOS). An RTOS is an operating system specifically designed for handling real-time tasks. Its core characteristic is its ability to guarantee task completion within strict time constraints, making it suitable for applications with very high time requirements. Compared to operating systems like Linux, it offers advantages such as low latency, lightweight design, high real-time performance, and high reliability.
[0042] To address the issue that in scenarios without interruption support, the main operating system's resources are occupied for extended periods due to its active polling of hardware registers, preventing it from handling other tasks, this application proposes utilizing a co-core operating system to handle the high-frequency polling work of the main operating system, thereby reducing the burden on the main operating system's core.
[0043] As shown in Figure 2, a typical BMC chip contains two types of processor cores: a high-performance processor core (such as the ARM Cortex-A (Advanced RISC Machine Cortex-A, an application processor for complex operating systems and user applications) series, which can be called the main core), and a lower-performance processor core (such as the ARM Cortex-M (Advanced RISC Machine Cortex Microcontroller, a processor core for microcontroller applications) series), which can be called the co-core. In this embodiment, the main core of the BMC runs a main core operating system (Linux system), while the co-core runs a faster boot-up co-core operating system (RTOS). Data transmission between the main core operating system and the co-core operating system can be achieved through an inter-core communication module.
[0044] When the main operating system's business processes need to use polling registers to wait for a certain hardware event to occur, a polling proxy command can be generated. After the co-operating system responds to the polling proxy command, it can perform the polling operation on behalf of the main operating system.
[0045] In step S102, at least one register to be polled is polled based on the polling agent command, and polling results of at least one register to be polled are generated.
[0046] Understandably, the co-core operating system primarily handles two tasks: processing polling proxy commands sent by the main core operating system and performing register polling operations. It's worth noting that after sending the polling proxy command, the main core operating system can also send an interrupt signal to the co-core operating system, indicating an event requiring immediate attention. Upon receiving this interrupt signal, the co-core operating system can process the polling proxy command within a dedicated interrupt handler. Register polling, on the other hand, is typically performed within a task (or thread) to avoid consuming excessive time in the interrupt handler.
[0047] Specifically, when the co-core operating system receives a polling agent command, it can perform polling operations on one or more specified registers to be polled according to the polling agent command. This process involves checking each register to be polled one by one to obtain its current status or value. Subsequently, the co-core operating system will organize and generate detailed polling results for each register to be polled. These results can reflect the specific status or data of each register to be polled at the polling time.
[0048] To facilitate understanding, the following details how to poll at least one register to be polled based on the polling agent command, and generate the polling result for each register to be polled.
[0049] As one possible implementation, in some embodiments, polling at least one register to be polled based on a polling proxy command to generate polling results for at least one register to be polled includes: storing the polling proxy command in a preset global variable group; traversing the preset global variable group, parsing the polling proxy command, and determining the target polling register information; and polling at least one register to be polled based on the target polling register information to generate polling results for at least one register to be polled.
[0050] As is understandable, global variables refer to variables that can be accessed from any part of the program. They are usually stored in the program's data segment and are used to store data that needs to be shared across functions or modules.
[0051] In other words, in the co-core operating system, there is a set of global variables (i.e., the preset global variable group) used to store the register information that needs to be checked (polled) (i.e., the target polling register information). These global variables constitute a specific data structure, as shown in Code 1. In Code 1, the register field represents the address of the register to be polled; the triggerPerChange field represents the trigger condition; the isPermanent field represents the resident flag; the target field represents the target value; and the mask field represents the bit of the register to be polled. `triggerPerChange` being 1 indicates that the host operating system needs to be notified every time the value of the register to be polled changes; `triggerPerChange` being 0 indicates that the host operating system is not notified only when the value of the register to be polled changes to the target value. `isPermanent` being 0 indicates that continuous polling is not required; `isPermanent` being 1 indicates that continuous polling is required. `target` indicates that the host operating system should be notified when the value of the register to be polled changes to the target value. This field is mutually exclusive with the `triggerPerChange` field; that is, if `triggerPerChange` is 1, this field is invalid. Bits with a `mask` value of 1 indicate the bits of the register to be polled that need to be polled; bits with a `mask` value of 0 indicate the bits that do not need to be polled. Based on the polling proxy commands sent by the host operating system, the co-core operating system can store these polling proxy commands in a preset global variable group, thereby facilitating the execution of the polling task. Then, by traversing the preset global variable group and parsing the polling proxy commands within it, the target polling register information can be determined, that is, the specific information that needs to be polled for each register to be polled. Finally, based on the target polling register information, a polling operation is performed on each register to be polled, and the corresponding polling results are generated.
[0052] Code 1:
[0053] Therefore, when the main core operating system sends polling requests for multiple registers, the co-core operating system can handle them uniformly by traversing the preset global variable group, avoiding frequent inter-core communication overhead and thus significantly improving task scheduling efficiency. In addition, the design of the preset global variable group realizes efficient proxying of high-frequency polling tasks through centralized data management, task isolation, dynamic updates and fast access mechanisms.
[0054] The register polling task process of the co-core operating system is described in detail below.
[0055] Further, in some embodiments, polling at least one register to be polled based on the target polling register information to generate polling results for at least one register to be polled includes: determining whether the information of the current register to be polled is empty; if the information of the current register to be polled is not empty, determining the value of the current register to be polled, performing a bitwise AND operation between the value of the current register to be polled and the mask in the target polling register information, and determining whether the result of the AND operation is consistent with the value of the current register to be polled; if the result of the AND operation is consistent with the value of the current register to be polled, then re-executing the step of determining whether the information of the current register to be polled is empty after a preset sleep time; otherwise, determining whether the triggering condition in the target polling register information meets a first preset condition; if the triggering condition in the target polling register information meets the first preset condition, generating the polling result of the current register to be polled based on the value of the current register to be polled.
[0056] Understandably, the purpose of a mask is to allow a register to read only 32 bits of data in a single operation. However, not all bits need to be considered. Therefore, a mask can be used to filter out the bits that truly need attention. The corresponding mask is also 32 bits long. For example, if the 10th bit of the mask is 1, it means that the 10th bit of the register needs to be considered; if the 11th bit of the mask is 0, it means that the 11th bit of the register does not need to be considered. In this way, data in the register can be flexibly and selectively read and processed, greatly improving the efficiency and flexibility of data processing.
[0057] Specifically, based on the information of each register to be polled, it can be determined whether the current register is empty. If it is not empty, its value can be read. After obtaining the value, the next step is to perform a bitwise AND operation between the current register value and the mask in the target register information, obtaining the result and comparing it with the current register value. It's important to note that the current register value is the result of the previous bitwise AND operation between the register value and the mask in the target register information. The purpose of performing the bitwise AND operation on the register value and the mask is to mask out any unimportant bits, preventing them from affecting subsequent operations.
[0058] If the result of the operation matches the value of the currently polled register, it means that the value of the currently polled register has not changed in the bits of interest. The co-core operating system will then enter a sleep state for a preset duration (e.g., 10ms). This preset duration can be pre-set and is not specifically limited here. After the sleep period, the co-core operating system can re-execute the step of checking if the information in the polled register is empty. If the result of the operation does not match the value of the currently polled register, it means that the value of the currently polled register has changed in the bits of interest. Next, it can be determined whether the triggering condition of the target polling register information meets the first preset condition. That is, combined with code 1, it can be determined whether the triggerPerChange value in the target polling register information is 1. If the triggerPerChange value in the target polling register information is 1 (i.e., the triggering condition in the target polling register information meets the first preset condition), it means that every change in the currently polled register needs to be reported to the main core operating system. Therefore, the corresponding polling result can be generated based on the value of the currently polled register.
[0059] Therefore, by using a mask and target value to determine the polling process, a report is only triggered when the bit of interest changes or when specific triggering conditions are met, thereby reducing unnecessary data transmission and processing.
[0060] Furthermore, in some embodiments, after determining whether the triggering condition in the target polling register information meets the first preset condition, the method further includes: if the triggering condition in the target polling register information does not meet the first preset condition, determining whether the value of the current polling register is consistent with the target value in the target polling register information; if the value of the current polling register is consistent with the target value in the target polling register information, generating the polling result of the current polling register based on the value of the current polling register.
[0061] Specifically, if the triggerPerChange value in the target polling register information is 0 (i.e., the trigger condition in the target polling register information does not meet the first preset condition), it means that the value of the current polling register will only be reported to the main kernel operating system when it changes to the target value. Therefore, it is possible to further determine whether the value of the current polling register is consistent with the target value in the target polling register information. If the value of the current polling register is consistent with the target value in the target polling register information, then the corresponding polling result can be generated based on the value of the current polling register.
[0062] Therefore, by using a mask and target value to make judgments during the polling process, a report is only triggered when the bit of interest changes or when specific triggering conditions are met, thereby reducing unnecessary data transmission and processing.
[0063] Furthermore, in some embodiments, after determining whether the value of the current register to be polled is consistent with the target value in the target polling register information, the method further includes: if the value of the current register to be polled is inconsistent with the target value in the target polling register information, then determining whether the resident flag in the target polling register information meets the second preset condition; if the resident flag in the target polling register information meets the second preset condition, then clearing the information of the current register to be polled and polling the next register to be polled; otherwise, directly polling the next register to be polled.
[0064] Specifically, if the triggerPerChange value in the target polling register information is 0 (i.e., the trigger condition in the target polling register information does not meet the first preset condition), and the value of the currently polled register is inconsistent with the target value in the target polling register information, then in this case, it can be further determined whether the resident flag of the target polling register information meets the second preset condition. That is, combined with code 1, it can be determined whether the isPermanent value in the target polling register information is 0. If the isPermanent value in the target polling register information is 0 (i.e., the resident flag of the target polling register information meets the second preset condition), it means that the currently polled register does not need to be polled resident, so the information of the currently polled register can be cleared, and the next polled register can continue to be polled. If the isPermanent value in the target polling register information is 1 (i.e., the resident flag of the target polling register information does not meet the second preset condition), it means that the currently polled register needs to be polled resident, so the next polled register can be polled directly.
[0065] It should be noted that, in the embodiments of this application, the so-called resident polling mechanism actually refers to the co-core operating system performing a polling check on all registers to be polled once in each polling cycle. During this process, if it is found that a register to be polled no longer meets the predetermined resident polling conditions, then the co-core operating system will no longer poll that register in the following polling cycle.
[0066] Therefore, this mechanism ensures the efficiency of the polling process, avoids unnecessary checks on registers that no longer need continuous monitoring, thereby saving system resources and improving polling efficiency.
[0067] In step S103, at least one polling result of a pending register and an interrupt signal are sent to the main core operating system to wake up the current business process of the main core operating system through the interrupt signal. Before the co-core operating system responds to the polling agent command, the main core operating system controls the current business process to enter a sleep state.
[0068] In other words, if the polling result of at least one register to be polled is obtained and the corresponding triggering condition is met, the polling result of each register to be polled can be sent to the main operating system. In addition, an interrupt signal can be sent, and the main operating system can wake up the currently dormant business process through the received interrupt signal.
[0069] It should be noted that after the main core operating system sends a polling agent command to the co-core operating system, it can control the current business process to enter a sleep state, so that the current business process releases the core resources of the processor, thereby using the core resources to execute other tasks or enter a low-power state, thereby improving the overall efficiency and resource utilization of the system.
[0070] In some embodiments, the polling result includes at least one of the address of the register to be polled, the value of the register to be polled, and a mask value for a specific bit of the register to be polled.
[0071] Specifically, the data structure of the polling results sent by the co-core operating system to the main core operating system can be as shown in Code 2, where register represents the address of the register to be polled, value represents the value of the register to be polled, and mask represents the mask value of a specific bit of the register to be polled.
[0072] Code 2:
[0073] Therefore, by specifying a mask, the system can process only the necessary bits, improving processing efficiency; explicitly specifying register addresses and values can reduce errors and redundant lookups, improving system stability; in addition, structured data replies can make communication between systems more standardized, reduce coupling, and facilitate maintenance and expansion.
[0074] According to the proxy method for high-frequency polling of the operating system proposed in the embodiments of this application, the polling task is managed and executed by the co-core operating system based on a preset global variable group, which can reduce the burden on the main core operating system, improve task scheduling efficiency and reduce inter-core communication overhead.
[0075] Figure 3 is a flowchart illustrating a proxy method for high-frequency polling of an operating system provided in some other embodiments of this application.
[0076] As shown in Figure 3, the high-frequency polling proxy method of this operating system is applied to the main core operating system running on the main core of the baseboard management controller. The method includes the following steps:
[0077] In step S301, it is determined whether the current business process has a polling register requirement.
[0078] It is understandable that during the current business process, the values of certain registers can be read to determine whether specific conditions are met or to obtain data updates.
[0079] In step S302, if the current business process requires polling the register, a polling agent command is generated.
[0080] In other words, if the current business process requires polling the registers, the main operating system can automatically generate the corresponding polling agent command to ensure the smooth execution of the polling task.
[0081] In some embodiments, the polling agent command includes at least one of the following: the address of the register to be polled, the trigger condition, the resident flag, the target value, and the mask.
[0082] Specifically, as shown in Code 1, the polling agent command includes the address of the register to be polled (register), the trigger condition (triggerPerChange), the resident flag (isPermanent), the target value (target), and the mask (mask).
[0083] Therefore, through the design of this data structure, the address of the register to be polled can be explicitly specified, so that the co-core operating system does not need to traverse all registers and can directly locate the target hardware, thereby reducing the query range and reducing invalid polling; optimizing the event triggering mechanism to avoid high-frequency irrelevant state reporting; realizing dynamic resource management based on resident flags to prevent long-term occupation of co-core resources; and specifying specific bits of interest through a mask to reduce data processing volume and improve polling efficiency.
[0084] In step S303, a polling agent command is sent to the co-core operating system, and the polling result generated by the co-core operating system after polling the register to be polled is received.
[0085] In other words, when there is a need to poll the register in the current business process, the main core operating system can generate and send a polling agent command to the co-core operating system, so that the co-core operating system can perform the polling operation and receive the polling results generated by the co-core operating system for polling the register to be polled.
[0086] Furthermore, in some embodiments, before sending the polling agent command to the co-core operating system, the method further includes: creating a polling agent driver and an interface for the polling agent driver to send the polling agent command to the co-core operating system through the interface, and / or receiving the polling results generated by the co-core operating system.
[0087] It's understandable that the main operating system can be divided into a user layer (application layer) and a kernel layer. The user layer (application layer) refers to the layer within the main operating system that directly interacts with the user, including applications run by the user, such as text editors, browsers, and games. The kernel layer refers to the core part of the main operating system, responsible for managing system resources, such as the CPU (Central Processing Unit), memory, and device drivers. The kernel provides system call interfaces for user-level programs and is responsible for scheduling processes, managing the file system, and handling network communication. Therefore, to execute the task of polling registers, a polling agent driver can be built first. This polling agent driver is placed as a driver program within the kernel, and it can also provide program interfaces to other business drivers. The data structure of this interface is shown in Code 3. `pPollReq` refers to Code 1, the polling agent instruction; `pPollResp` refers to Code 2, the polling result; `daemonFun` is the function that runs when the value of the polling register changes, provided resident polling is enabled. This parameter is invalid if resident polling is not required. `pDaemonFunData` is the parameter of the function that runs when the value of the polling register changes, provided resident polling is enabled. Similarly, this parameter is invalid if resident polling is not required. The purpose is that other business drivers can request the polling service (i.e., send polling agent commands to the co-core operating system) or obtain polling results through the polling agent driver and its interface. The interface call and execution occur in other parts of the kernel, i.e., the area where the business driver resides. This process involves interaction between the main kernel operating system and the co-core operating system, ensuring the correct sending of polling agent commands and the accurate reception of polling results, thereby achieving real-time monitoring and management of the system status.
[0088] Code 3:
[0089] Therefore, by creating a polling agent driver directly at the kernel layer, the business driver can initiate polling requests directly through the kernel interface, avoiding data copying and context switching between the user layer and the kernel layer, and significantly reducing data transmission latency.
[0090] Next, we will explain in detail the process by which the main operating system sends polling agent commands and receives polling results.
[0091] As some possible implementation methods, in some embodiments, a polling agent command is sent to the co-core operating system, and the polling result generated by the co-core operating system after polling the register to be polled is received, including: creating a command reply message queue; sending the handles of the polling agent command and the command reply message queue to the polling agent driver based on the interface; determining whether the polling agent command meets the preset continuous polling conditions; if the polling agent command meets the preset continuous polling conditions, determining whether the command reply message queue has listened to the polling result; if the command reply message queue has listened to the polling result, running a preset function and re-executing the step of determining whether the command reply message queue has listened to the polling result.
[0092] Specifically, in this embodiment of the application, the main operating system can first create a command reply message queue, which is used to receive replies (i.e., polling results) from the polling agent driver. Next, based on the polling agent driver's interface, the polling agent command and the handle of the command reply message queue (in computer science, a handle refers to a reference or identifier used to access and manage resources, such as files, windows, or message queues) can be sent to the polling agent driver. Thus, the polling agent driver can know how to interact with the command reply message queue and can return the execution result of the command. After sending the handle, the polling agent command can be judged to determine whether it meets the preset continuous polling conditions (i.e., whether persistent polling is required). If the polling agent command meets the preset continuous polling conditions, it indicates that persistent polling is required. The polling agent driver will then enter a monitoring state, continuously listening to the command reply message queue to see if the polling result has been received. If a polling result is detected in the command reply message queue, the preset function (daemonFun) shown in Figure 5 can be run, and the command reply message queue can be listened to again to continue waiting for new polling results, thus forming a continuous polling and processing loop.
[0093] Therefore, by transmitting command reply message queue handles instead of directly transmitting data, the amount of data transmitted between cores is reduced. The handle, as a lightweight resource identifier, enables co-cores to directly access the shared queue, avoiding repeated transmission of large amounts of data. The judgment mechanism of preset continuous polling conditions realizes intelligent task management. When continuous polling is required, the system automatically enters the monitoring-processing loop and realizes continuous event response through the daemonFun function, ensuring real-time monitoring of the status of critical hardware.
[0094] Furthermore, in some other embodiments, after determining whether the command reply message queue meets the preset continuous polling conditions, the method further includes: if the command reply message queue does not meet the preset continuous polling conditions, determining whether the command reply message queue has detected a polling result; if the command reply message queue has detected a polling result, receiving the polling result through the preset reply data parameters in the interface, and deleting the command reply message queue.
[0095] In other words, if the polling agent command does not meet the preset continuous polling conditions, it means that persistent polling is not required. In this case, the polling agent driver can still enter the monitoring state, continuously listen to the command reply message queue, and when the polling result is heard in the command reply message queue, it directly returns the polling result through the preset reply data parameter (i.e., pPollResp) of the polling agent driver's interface and deletes the command reply message queue.
[0096] Therefore, since there is no need to maintain continuous listening to the message queue, the number of resident monitoring threads in the kernel is reduced, and the co-core can release the relevant resources after completing a single poll, avoiding the situation of occupying co-core processing resources for a long time.
[0097] Furthermore, in some embodiments, after sending the polling agent command to the co-core operating system, the method further includes: controlling the current business process to enter a sleep state, and determining whether an interrupt signal sent by the co-core operating system is received; if an interrupt signal is received, controlling the current business process to end the sleep state and resume the operation of the current business process based on the interrupt signal.
[0098] In other words, after the main core operating system sends a polling agent command to the co-core operating system, it immediately controls the current business process to enter a sleep state. During the sleep state, the main core operating system can continuously monitor whether an interrupt signal from the co-core operating system is received. Once an interrupt signal is detected, the main core operating system can take corresponding actions based on the interrupt signal, that is, wake up the current business process in the sleep state and restore it to the normal running state.
[0099] Thus, by suspending the current business process, the CPU of the main operating system is freed up to handle other tasks, achieving optimal resource allocation while ensuring real-time performance.
[0100] According to the proxy method for high-frequency polling of the operating system proposed in the embodiments of this application, the main core operating system issues a polling proxy instruction to enable the co-core operating system to perform polling operations, which can reduce the burden on the main core operating system, improve task scheduling efficiency and reduce inter-core communication overhead.
[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0102] Embodiments of this application also provide an agent device for high-frequency polling of the operating system.
[0103] Figure 4 is a block diagram of an operating system high-frequency polling agent device according to some embodiments of this application.
[0104] As shown in Figure 4, the high-frequency polling proxy device 10 of the operating system is applied to the co-core operating system running on the co-core end of the baseboard management controller. The high-frequency polling proxy device 10 of the operating system includes: a response module 100, a polling module 200 and a sending module 300.
[0105] The response module 100 is used to respond to the polling agent command, which is generated by the main core operating system running on the main core of the baseboard management controller.
[0106] The polling module 200 is used to poll at least one register to be polled based on a polling agent command, and generate polling results for at least one register to be polled.
[0107] The sending module 300 is used to send the polling result of at least one polling register and an interrupt signal to the main core operating system, so as to wake up the current business process of the main core operating system through the interrupt signal. Before the co-core operating system responds to the polling agent command, the main core operating system controls the current business process to enter a sleep state.
[0108] Furthermore, in some embodiments, the polling module 200 includes:
[0109] Storage unit, used to store polling agent commands to a preset global variable group;
[0110] The determination unit is used to traverse the preset global variable group, parse the polling agent command, and determine the target polling register information;
[0111] The polling unit is used to poll at least one register to be polled based on the target polling register information, and generate the polling result of at least one register to be polled.
[0112] Furthermore, in some embodiments, the polling unit is specifically used for:
[0113] Determine if the information in the register currently being polled is empty;
[0114] If the information of the current polling register is not empty, determine the value of the current polling register, perform a bitwise AND operation between the value of the current polling register and the mask in the target polling register information, and determine whether the result of the bitwise AND operation is consistent with the value of the current polling register.
[0115] If the operation result is consistent with the value of the current polling register, then after a preset sleep time, the step of judging whether the information of the current polling register is empty will be re-executed; otherwise, it will be judged whether the trigger condition in the target polling register information meets the first preset condition.
[0116] If the triggering condition in the target polling register information meets the first preset condition, the polling result of the current polling register is generated based on the value of the current polling register.
[0117] Furthermore, in some embodiments, after determining whether the triggering condition in the target polling register information meets the first preset condition, the polling unit is further configured to:
[0118] If the triggering condition in the target polling register information does not meet the first preset condition, then determine whether the value of the current polling register is consistent with the target value in the target polling register information;
[0119] If the value of the current register to be polled is consistent with the target value in the target polling register information, the polling result of the current register to be polled is generated based on the value of the current register to be polled.
[0120] Furthermore, in some embodiments, after determining whether the value of the currently polled register matches the target value in the information of the currently polled register, the polling unit is further configured to:
[0121] If the value of the current polling register is inconsistent with the target value in the target polling register information, determine whether the resident flag in the target polling register information meets the second preset condition.
[0122] If the resident flag in the target polling register information meets the second preset condition, then the information of the current polling register is cleared and the next polling register is polled; otherwise, the next polling register is polled directly.
[0123] Furthermore, in some embodiments, the polling result includes at least one of the address of the register to be polled, the value of the register to be polled, and a mask value for a specific bit of the register to be polled.
[0124] The high-frequency polling proxy device for the operating system proposed in the embodiments of this application can reduce the burden on the main operating system, improve task scheduling efficiency, and reduce inter-core communication overhead by managing and executing polling tasks based on a preset global variable group through the co-core operating system.
[0125] Figure 5 is a block diagram of an operating system high-frequency polling agent device according to some other embodiments of this application.
[0126] As shown in Figure 5, the high-frequency polling proxy device 20 of the operating system is applied to the main core operating system running on the main core of the baseboard management controller. The high-frequency polling proxy device 20 of the operating system includes: a judgment module 400, a generation module 500, and a transceiver module 600.
[0127] Among them, the judgment module 400 is used to determine whether the current business process has a polling register requirement;
[0128] The generation module 500 is used to generate polling agent commands when there is a need to poll the register in the current business process;
[0129] The transceiver module 600 is used to send polling agent commands to the co-core operating system and receive the polling results generated by the co-core operating system after polling the register to be polled.
[0130] Furthermore, in some embodiments, before sending the polling agent command to the co-core operating system, the transceiver module 600 is also used for:
[0131] Create a polling agent driver and its interface to send polling agent commands to the co-core operating system and / or receive polling results generated by the co-core operating system.
[0132] Furthermore, in some embodiments, the transceiver module 600 includes:
[0133] Create a unit for creating a command response message queue;
[0134] The sending unit is used to send the handles of the polling agent command and the command reply message queue to the polling agent driver based on the interface;
[0135] The first judgment unit is used to determine whether the polling agent command meets the preset continuous polling conditions;
[0136] The second judgment unit is used to determine whether the command reply message queue has listened to the polling result when the polling agent command meets the preset continuous polling conditions;
[0137] The execution unit is used to run a preset function and re-execute the step of determining whether the command reply message queue has received a polling result when the polling result is detected in the command reply message queue.
[0138] Furthermore, in some embodiments, after determining whether the command reply message queue meets the preset continuous polling conditions, the first determining unit is further configured to:
[0139] If the command reply message queue does not meet the preset continuous polling conditions, determine whether the command reply message queue has listened to the polling result;
[0140] If the polling result is detected in the command reply message queue, the polling result is received through the preset reply data parameters in the interface, and then the command reply message queue is deleted.
[0141] Furthermore, in some embodiments, the polling agent command includes at least one of the following: the address of the register to be polled, the triggering condition, the resident flag, the target value, and the mask.
[0142] Furthermore, in some embodiments, after sending the polling agent command to the co-core operating system, the transceiver module 600 is also used for:
[0143] Control the current business process to enter a sleep state and determine whether an interrupt signal has been received from the co-core operating system;
[0144] If an interrupt signal is received, the current business process will end its sleep state and resume operation based on the interrupt signal.
[0145] For a description of the features of the proxy device corresponding to the high-frequency polling of the operating system in the embodiment, please refer to the relevant description of the proxy method corresponding to the high-frequency polling of the operating system, which will not be repeated here.
[0146] According to the operating system high-frequency polling proxy device proposed in the embodiments of this application, the main core operating system issues polling proxy instructions to enable the co-core operating system to perform polling operations, which can reduce the burden on the main core operating system, improve task scheduling efficiency and reduce inter-core communication overhead.
[0147] Figure 6 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:
[0148] The memory 601, the processor 602, and the computer program stored on the memory 601 and capable of running on the processor 602.
[0149] When the processor 602 executes the program, it implements the steps in the proxy method embodiment of any of the above operating systems with high-frequency polling.
[0150] Furthermore, electronic devices also include:
[0151] Communication interface 603 is used for communication between memory 601 and processor 602.
[0152] The memory 601 is used to store computer programs that can run on the processor 602.
[0153] The memory 601 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage.
[0154] If the memory 601, processor 602, and communication interface 603 are implemented independently, they can be interconnected via a bus to communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in Figure 6, but this does not indicate that there is only one bus or one type of bus.
[0155] In a specific implementation, if the memory 601, processor 602, and communication interface 603 are integrated on a single chip, then the memory 601, processor 602, and communication interface 603 can communicate with each other through their internal interfaces.
[0156] The processor 602 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of this application.
[0157] Embodiments of this application also provide a non-volatile readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in the above embodiments of the high-frequency polling proxy method of any of the operating systems described above when running.
[0158] In one exemplary embodiment, the aforementioned non-volatile readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory, portable hard drives, magnetic disks, or optical disks.
[0159] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in the above embodiments of the high-frequency polling proxy method for any of the operating systems.
[0160] Embodiments of this application also provide another computer program product, including a non-volatile readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the above embodiments of the high-frequency polling proxy method of any of the operating systems.
[0161] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0162] The above provides a detailed description of a proxy method for high-frequency polling of an operating system provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A proxy method for high-frequency polling in an operating system, characterized in that, The method is applied to a co-core operating system running on the co-core side of the baseboard management controller, wherein the method includes: Responding to a polling agent command, wherein the polling agent command is generated by the main core operating system running on the main core of the baseboard management controller; Based on the polling proxy command, at least one register to be polled is polled, and the polling result of the at least one register to be polled is generated; The polling result of the at least one pending polling register and an interrupt signal are sent to the main core operating system to wake up the current business process of the main core operating system through the interrupt signal. Before the co-core operating system responds to the polling agent command, the main core operating system controls the current business process to enter a sleep state.
2. The proxy method for high-frequency polling of the operating system according to claim 1, characterized in that, The response polling agent command includes: Accept interrupt signals sent by the main operating system; The polling agent command is processed in the interrupt handler function based on the interrupt signal sent by the main operating system.
3. The proxy method for high-frequency polling of the operating system according to claim 1, characterized in that, The step of polling at least one register to be polled based on the polling agent command and generating polling results for at least one register to be polled includes: Store the polling agent command into a preset global variable group; Traverse the preset global variable group, parse the polling proxy command, and determine the target polling register information; Based on the target polling register information, the at least one register to be polled is polled to generate the polling result of the at least one register to be polled.
4. The proxy method for high-frequency polling of the operating system according to claim 3, characterized in that, The step of polling the at least one register to be polled based on the target polling register information, and generating the polling result of the at least one register to be polled, includes: Determine if the information in the register currently being polled is empty; If the information of the current polling register is not empty, determine the value of the current polling register, perform a bitwise AND operation between the value of the current polling register and the mask in the target polling register information, and determine whether the result of the bitwise AND operation is consistent with the value of the current polling register. If the result of the AND operation is consistent with the value of the current polling register, then after a preset sleep time, the step of determining whether the information of the current polling register is empty will be re-executed; otherwise, it will be determined whether the triggering condition in the target polling register information meets the first preset condition. If the triggering condition in the target polling register information satisfies the first preset condition, the polling result of the current polling register is generated based on the value of the current polling register.
5. The proxy method for high-frequency polling of the operating system according to claim 4, characterized in that, The preset global variable group includes the address of the register to be polled, the trigger condition, the resident flag, the target value, and the bits of the register to be polled.
6. The proxy method for high-frequency polling of the operating system according to claim 5, characterized in that, The step of determining whether the trigger condition in the target polling register information meets the first preset condition includes: Based on the preset global variable group, determine whether the value of the triggering condition is 1.
7. The proxy method for high-frequency polling of the operating system according to claim 4, characterized in that, After determining whether the triggering condition in the target polling register information meets the first preset condition, the method further includes: If the triggering condition in the target polling register information does not meet the first preset condition, then it is determined whether the value of the current polling register is consistent with the target value in the target polling register information; If the value of the current polling register matches the target value in the target polling register information, the polling result of the current polling register is generated based on the value of the current polling register.
8. The proxy method for high-frequency polling of an operating system according to claim 7, characterized in that, After determining whether the value of the currently polled register matches the target value in the target polling register information, the process further includes: If the value of the current polling register is inconsistent with the target value in the target polling register information, then it is determined whether the resident flag in the target polling register information satisfies the second preset condition; If the resident flag in the target polling register information meets the second preset condition, then the information of the current polling register is cleared and the next polling register is polled; otherwise, the next polling register is polled directly.
9. The proxy method for high-frequency polling of the operating system according to claim 1, characterized in that, The polling result includes at least one of the address of the register to be polled, the value of the register to be polled, and the mask value of a specific bit of the register to be polled.
10. A proxy method for high-frequency polling in an operating system, characterized in that, The method is applied to a main core operating system running on the main core of a baseboard management controller, wherein the method includes: Determine if the current business process requires polling the register; If the current business process requires the polling register, a polling agent command is generated; Send a polling agent command to the co-core operating system and receive the polling result generated by the co-core operating system after polling the register to be polled.
11. The proxy method for high-frequency polling of an operating system according to claim 10, characterized in that, Before sending the polling agent command to the co-core operating system, the following steps are also included: Create a polling agent driver and an interface for the polling agent driver to send the polling agent command to the co-core operating system through the interface, and / or receive the polling results generated by the co-core operating system.
12. The proxy method for high-frequency polling of an operating system according to claim 11, characterized in that, The main operating system is divided into a user layer and a kernel layer. The creation of the polling agent driver includes: The polling agent driver is created at the kernel layer.
13. The proxy method for high-frequency polling of an operating system according to claim 11, characterized in that, The step of sending the polling proxy command to the co-core operating system and receiving the polling result generated by the co-core operating system after polling the register to be polled includes: Create a command reply message queue; Based on the interface, the polling agent command and the handle of the command reply message queue are sent to the polling agent driver; Determine whether the polling proxy command meets the preset continuous polling conditions; If the polling proxy command meets the preset continuous polling condition, then determine whether the command reply message queue has listened to the polling result; If the polling result is detected in the command reply message queue, a preset function is run and the step of determining whether the polling result has been detected in the command reply message queue is re-executed.
14. The proxy method for high-frequency polling of an operating system according to claim 13, characterized in that, If the polling proxy command satisfies the preset continuous polling condition, then determining whether the command reply message queue has detected a polling result includes: If the polling agent command meets the preset continuous polling conditions, the polling agent driver enters the monitoring state and continuously listens to the command reply message queue to see if the polling result has been received.
15. The proxy method for high-frequency polling of an operating system according to claim 13, characterized in that, After determining whether the command reply message queue meets the preset continuous polling condition, the method further includes: If the command reply message queue does not meet the preset continuous polling condition, then it is determined whether the command reply message queue has listened to the polling result; If the polling result is detected in the command reply message queue, the polling result is received through the preset reply data parameters in the interface, and the command reply message queue is deleted.
16. The proxy method for high-frequency polling of an operating system according to claim 10, characterized in that, The polling proxy command includes at least one of the following: the address of the register to be polled, the trigger condition, the resident flag, the target value, and the mask.
17. The proxy method for high-frequency polling of an operating system according to claim 10, characterized in that, After sending the polling agent command to the co-core operating system, the following is also included: The current business process is controlled to enter a sleep state, and it is determined whether an interrupt signal sent by the co-core operating system is received; If the interrupt signal is received, the current business process is controlled to end the sleep state and resume operation based on the interrupt signal.
18. An electronic device, characterized in that, include: Memory, configured to store computer programs; The processor, when configured to execute the computer program, implements the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 1 to 9, or the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 10 to 17.
19. A non-volatile readable storage medium, characterized in that, The non-volatile readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 1 to 9, or the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 10 to 17.
20. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 1 to 9, or the steps of the high-frequency polling proxy method of the operating system as described in any one of claims 10 to 17.