Proxy Method for High-Frequency Polling of Operating System, Electronic Device, and Storage Medium
By running the co-core operating system on the co-core end of the substrate management controller and performing high-frequency polling instead of the main core operating system, the problem of high-frequency polling of the main core operating system causing the central processor to be occupied for a long time is solved, and the effect of reducing system resource consumption and improving task scheduling efficiency is achieved.
Patent Information
- Application Number
- CN202510386582.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-03-28
AI Technical Summary
The main core operating system performs high-frequency polling, resulting in the central processor being occupied for a long time and unable to handle other tasks, reducing the overall system efficiency.
By running the co-core operating system on the co-core end of the substrate management controller, performing high-frequency polling instead of the main core operating system, using the co-core operating system to respond to the polling proxy command, poll the polling register, and sending polling results and interrupt signals to the main core operating system.
It reduces the burden on the main core operating system, improves task scheduling efficiency, reduces system resource consumption, and avoids the problem of other tasks being unable to handle due to long-term occupation of the central processor.
Smart Images

Figure CN119883579B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a proxy method for high-frequency polling of an operating system, an electronic device, and a storage medium. Background Art
[0002] Currently, most BMC (Baseboard Management Controller) systems adopt a solution of running the Linux operating system on the main core. With its rich functions and good community support, Linux can meet various business requirements. Among them, polling is a common hardware event detection mechanism. Especially in scenarios without interrupt support, event information is obtained by periodically checking the status of hardware registers.
[0003] In related technologies, when a hardware event does not support interrupts, the Linux system cannot receive notifications passively and can only actively poll. However, this method causes resources of the core where the Linux operating system is located, such as the central processing unit, to be occupied for a long time and unable to process other tasks, thus reducing the overall system efficiency, which urgently needs to be solved. Summary of the Invention
[0004] The present invention provides a proxy method for high-frequency polling of an operating system, an electronic device, and a storage medium, so as to at least solve the problem that the central processing unit is occupied for a long time and unable to process other tasks due to high-frequency polling of the main-core operating system, and achieve the technical effect of reducing system resource consumption.
[0005] The present invention 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, and the method includes the following steps:
[0006] Respond to a polling proxy command, where the polling proxy command is generated by a main-core operating system running on the main-core side of the baseboard management controller;
[0007] Poll at least one register to be polled based on the polling proxy command, and generate a polling result of the at least one register to be polled;
[0008] Send the polling result of the at least one register to be polled and an interrupt signal to the main-core operating system to wake up the current service process of the main-core operating system through the interrupt signal. Before the co-core operating system responds to the polling proxy command, the main-core operating system controls the current service process to enter the sleep state.
[0009] The present invention 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, and wherein the method comprises the following steps:
[0010] Determine whether the current service process has a polling register requirement;
[0011] Generate a polling proxy command when the current service process has the polling register requirement;
[0012] Send the polling proxy command to the co-core operating system and receive the polling result generated after the co-core operating system polls the register to be polled.
[0013] The present invention 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 of a baseboard management controller, and wherein the device comprises:
[0014] A response module, configured to respond to a polling proxy command, wherein the polling proxy command is generated by a main-core operating system running on the main core of the baseboard management controller;
[0015] A polling module, configured to poll at least one register to be polled based on the polling proxy command and generate a polling result of the at least one register to be polled;
[0016] A sending module, configured to send the polling result of the at least one register to be polled and an interrupt signal to the main-core operating system to wake up the current service process of the main-core operating system through the interrupt signal, wherein before the co-core operating system responds to the polling proxy command, the main-core operating system controls the current service process to enter a sleep state.
[0017] The present invention 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, and wherein the device comprises:
[0018] A judgment module, configured to judge whether the current service process has a polling register requirement;
[0019] A generation module, configured to generate a polling proxy command when the current service process has the polling register requirement;
[0020] A transceiver module, configured to send the polling proxy command to the co-core operating system and receive the polling result generated after the co-core operating system polls the register to be polled.
[0021] The present invention also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any one of the above-mentioned proxy methods for high-frequency polling of an operating system when executing the computer program.
[0022] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of any one of the above-mentioned proxy methods for high-frequency polling of an operating system when executed by a processor.
[0023] The present invention also provides a computer program product including a computer program, and the computer program implements the steps of any one of the above-mentioned proxy methods for high-frequency polling of an operating system when executed by a processor.
[0024] Through the present invention, a polling proxy command generated by a main-core operating system running on a main core of a baseboard management controller is responded to, and at least one register to be polled is polled based on the polling proxy command, and the polling result of each register to be polled and an interrupt signal are sent to the main-core operating system to wake up the current service process of the main-core operating system through the interrupt signal, wherein, before the co-core operating system responds to the polling proxy command, the main-core operating system controls the current service process to enter a sleep state. Thus, by using the co-core operating system to replace the main-core operating system for high-frequency polling work, the problem that the central processing unit is occupied for a long time by the main-core operating system for high-frequency polling and cannot process other tasks is solved, and the technical effect of reducing system resource consumption is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
[0026] Figure 1 It is a flowchart of a proxy method for high-frequency polling of an operating system provided by an embodiment of the present invention;
[0027] Figure 2 It is a schematic diagram of the architecture of a proxy system for high-frequency polling of an operating system provided by an embodiment of the present invention;
[0028] Figure 3 It is a flowchart of another proxy method for high-frequency polling of an operating system provided by an embodiment of the present invention;
[0029] Figure 4 It is a block diagram of a proxy device for high-frequency polling of an operating system provided by an embodiment of the present invention;
[0030] Figure 5Schematic block diagram of another proxy device for high-frequency polling of an operating system provided by an embodiment of the present invention;
[0031] Figure 6 Schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0032] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
[0033] It should be noted that in the description of the present invention, the terms "including", "comprising" or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present invention are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0034] To enable those skilled in the art of the present technology to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0035] An embodiment of the present invention provides a proxy method for high-frequency polling of an operating system. In combination with the execution process of the proxy method for high-frequency polling of the operating system, the method will be described in detail.
[0036] Figure 1 It is a flowchart of a proxy method for high-frequency polling of an operating system according to an embodiment of the present invention.
[0037] Exemplarily, as Figure 1 shown, the proxy method for high-frequency polling of the operating system is applied to a co-kernel operating system running on the co-kernel side of a baseboard management controller. Among them, the method includes the following steps:
[0038] In step S101, a polling proxy command is responded to, where the polling proxy command is generated by a main-kernel operating system running on the main-kernel side of the baseboard management controller.
[0039] Among them, polling is a method of checking the hardware status, that is, checking whether a certain condition is met, such as checking whether the value of a certain register has changed. The polling agent command refers to an instruction generated by the main core operating system to instruct the co-core operating system to start the polling operation. The baseboard management controller is the BMC. The BMC is an embedded processor that can be used to monitor, report, and control the status of server hardware devices. The main core operating system can be a Linux system. The co-core operating system can be a Real Time Operation System (RTOS). The RTOS is an operating system specifically designed to handle real-time tasks. Its core feature is that it can ensure that tasks are completed within strict time limits and is suitable for application scenarios with very high time requirements. Compared with operating systems such as Linux, it has advantages such as low latency, lightweight, high real-time performance, and high reliability.
[0040] To solve the problem that in a scenario without interrupt support, the resources of the core where the main core operating system is located are occupied for a long time and cannot process other tasks due to the main core operating system actively polling the status of hardware registers, the embodiment of the present invention proposes to use the co-core operating system to undertake the high-frequency polling work of the main core operating system to reduce the burden on the core where the main core operating system is located.
[0041] As Figure 2 shown, generally, the BMC chip contains two types of processor cores. One is a processor core with better performance (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. The other is a processor core with general performance (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 the embodiment of the present invention, the main core of the BMC runs the main core operating system (Linux system), and the co-core of the BMC runs the co-core operating system (RTOS) with a faster startup speed. Data can be transmitted between the main core operating system and the co-core operating system through an inter-core communication module.
[0042] When the business process of the main core operating system needs to use the polling register to wait for a certain hardware event to occur, a polling agent command can be generated. After the co-core operating system responds to the polling agent command, it can proxy the main core operating system to perform the polling operation.
[0043] In step S102, at least one register to be polled is polled based on the polling agent command, and a polling result of at least one register to be polled is generated.
[0044] It can be understood that the co - core operating system mainly handles two aspects of work. One is to process the polling agent commands sent by the main - core operating system, and the other is to perform register polling operations. It should be noted that after the main - core operating system sends a polling agent command to the co - core operating system, it can also send an interrupt signal to the co - core operating system, indicating that there is an event that needs to be processed immediately. After receiving this interrupt signal, the co - core operating system can process the polling agent command in a dedicated interrupt - handling function. And "register polling" is usually carried out in a task (or thread) to avoid occupying too much time of the interrupt - handling function.
[0045] Specifically, when the co - core operating system receives a polling agent command, it can perform a polling operation 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 state or value. Subsequently, the co - core operating system will organize and generate detailed polling results for each register to be polled, and these results can reflect the specific state or data of each register to be polled at the polling moment.
[0046] For ease of understanding, the following details how to poll at least one register to be polled based on the polling agent command and generate the polling results for each register to be polled.
[0047] As a possible implementation method, in some embodiments, polling at least one register to be polled based on the polling agent command and generating the polling results for at least one register to be polled includes: storing the polling agent command in a preset global variable group; traversing the preset global variable group, parsing the polling agent command, and determining the target register polling information; polling at least one register to be polled based on the target register polling information and generating the polling results for at least one register to be polled.
[0048] It can be understood that global variables refer to variables that can be accessed anywhere in the program. They are usually stored in the data segment of the program and are used to save data that needs to be shared across functions or modules.
[0049] That is to say, 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 (i.e., the target polling register information) that needs to be checked (polled). These global variables form a specific data structure, and its structure is 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; the mask field represents the bits of the register to be polled. When triggerPerChange is 1, it means that every time the value of the register to be polled changes, it needs to report to the main-core operating system. When triggerPerChange is 0, it means that when the value of the register to be polled becomes the target value (target), it reports to the main-core operating system; when isPermanent is 0, it means that it does not need to be polled continuously. When isPermanent is 1, it means that it needs to be polled continuously; target means that when the value of the register to be polled becomes the target value, it reports to the main-core operating system. This field is mutually exclusive with the triggerPerChange field. That is, if triggerPerChange is 1, this field is invalid; the bits with a mask value of 1 represent the bits that need to be polled for the register to be polled, and the bits with a mask value of 0 represent the bits that do not need to be polled. Based on the polling agent command sent by the main-core operating system, the co-core operating system can store this polling agent command in the preset global variable group, thus facilitating the execution of the polling task. Then, by traversing the preset global variable group and parsing the polling agent commands in it, the target polling register information can be determined, that is, the specific information that each register to be polled needs to be polled. Finally, according to the target polling register information, a polling operation is performed on each register to be polled, and the corresponding polling result is generated.
[0050] Code 1:
[0051] typedef PollAgentReq
[0052] {
[0053] uint64_t register;
[0054] uint32_t triggerPerChange;
[0055] uint32_t isPermanent ;
[0056] uint64_t taget;
[0057] uint64_t mask;
[0058] }PollAgentReq_t;
[0059] Thus, when the main core operating system sends polling requests for multiple registers, the co-core operating system can uniformly process them by traversing a preset global variable group, avoiding frequent inter-core communication overhead, thereby significantly improving task scheduling efficiency. In addition, the design of the preset global variable group realizes efficient proxy for high-frequency polling tasks through centralized data management, task isolation, dynamic update, and fast access mechanisms.
[0060] The register polling task process of the co-core operating system is elaborated in detail below.
[0061] Further, in some embodiments, polling at least one register to be polled based on the target polling register information to generate polling results of the at least one register to be polled includes: determining whether the information of the current register to be polled is empty; when the information of the current register to be polled is not empty, determining the value of the current register to be polled, performing an AND operation on 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, re-executing the step of determining whether the information of the current register to be polled is empty after sleeping for a preset duration, otherwise determining whether the trigger condition in the target polling register information meets a first preset condition; when the trigger condition in the target polling register information meets the first preset condition, generating a polling result of the current register to be polled based on the value of the current register to be polled.
[0062] It can be understood that the role of the mask is that it allows the register to read only 32-bit data in a single operation. However, not all bits of data need to be concerned. Therefore, the mask can filter out the data of the bits that really need to be concerned. The corresponding mask is also 32 bits long. Assuming that the 10th bit of the mask is 1, it means that the 10th bit of the register needs to be concerned; if the 11th bit of the mask is 0, it means that the 11th bit of the register does not need to be concerned. In this way, the data in the register can be selectively read and processed flexibly, greatly improving the efficiency and flexibility of data processing.
[0063] Specifically, based on the information of each register to be polled, it can be determined 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, then the value of the current register to be polled can be read. After obtaining the value of the current register to be polled, the next judgment can be made, that is, the value of the current register to be polled is AND-operated with the mask in the target polling register information to obtain the corresponding AND-operation result, and the AND-operation result is compared with the value of the current register to be polled to check if they are consistent. It should be noted that the value of the current register to be polled is the AND-operation result of the value of the register in the previous time and the mask in the target polling register information. The purpose of the AND-operation between the register value and the mask is to mask all the bits that are not of concern to avoid affecting subsequent operations.
[0064] If the AND-operation result is consistent with the value of the current register to be polled, it indicates that the value of the current register to be polled has not changed in the bits of concern. Then the co-core operating system will enter the sleep state for a preset duration (such as 10 ms). Here, the preset duration can be set in advance and is not specifically limited here. After the sleep ends, the co-core operating system can execute the step of checking whether the information of the register to be polled is empty again. If the AND-operation result is not consistent with the value of the current register to be polled, it indicates that the value of the current register to be polled has changed in the bits of concern. Then, it can be judged whether the trigger condition of the target polling register information meets the first preset condition, that is, in combination with Code 1, it is judged whether the triggerPerChange value in the target polling register information is 1. If the triggerPerChange value in the target polling register information is 1 (that is, the trigger condition in the target polling register information meets the first preset condition), it means that each change of the current register to be polled needs to report to the main-core operating system. Therefore, a corresponding polling result can be generated based on the value of the current register to be polled.
[0065] Thus, during the polling process, by using the mask and the target value for judgment, reporting is only triggered when the bits of concern change and a specific trigger condition is met, thereby reducing unnecessary data transmission and processing.
[0066] Furthermore, in some embodiments, after judging whether the trigger condition in the target polling register information meets the first preset condition, it further includes: if the trigger condition in the target polling register information does not meet the first preset condition, then it is judged whether the value of the current register to be polled is consistent with the target value in the target polling register information; when the value of the current register to be polled is consistent with the target value in the target polling register information, a polling result of the current register to be polled is generated based on the value of the current register to be polled.
[0067] Specifically, if the value of triggerPerChange 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 indicates that the value of the current register to be polled is reported to the main core operating system only when it becomes the target value (target). Therefore, it is possible to further determine whether the value of the current register to be polled is consistent with the target value in the target polling register information. If the value of the current register to be polled 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 register to be polled.
[0068] Thus, during the polling process, by using a mask and a target value for judgment, a report is triggered only when the concerned bits change and a specific trigger condition is met, thereby reducing unnecessary data transmission and processing.
[0069] 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, it 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 determine whether the permanent flag in the target polling register information meets the second preset condition; if the permanent flag in the target polling register information meets the second preset condition, then clear the information of the current register to be polled and poll the next register to be polled, otherwise directly poll the next register to be polled.
[0070] Specifically, if the value of triggerPerChange 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 current register to be polled is inconsistent with the target value in the target polling register information, then in this case, it is possible to further determine whether the permanent flag in the target polling register information meets the second preset condition, that is, in combination with Code 1, determine whether the value of isPermanent in the target polling register information is 0. If the value of isPermanent in the target polling register information is 0 (i.e., the permanent flag in the target polling register information meets the second preset condition), it indicates that the current register to be polled does not need to be permanently polled, then the information of the current register to be polled can be cleared and the next register to be polled can be continued to be polled. If the value of isPermanent in the target polling register information is 1 (i.e., the permanent flag in the target polling register information does not meet the second preset condition), it indicates that the current register to be polled needs to be permanently polled, then the next register to be polled can be directly polled.
[0071] It should be noted that in the embodiments of the present invention, the so-called resident polling mechanism actually means that in each polling cycle, the co-kernel operating system will perform a polling check on all registers to be polled. During this process, if it is found that a certain register to be polled no longer meets the established resident polling conditions, then in the next polling cycle, the co-kernel operating system will no longer perform a polling operation on this register to be polled.
[0072] Thus, through this mechanism, the efficiency of the polling process can be ensured, unnecessary checks on registers that no longer need continuous monitoring are avoided, thereby saving system resources and improving the efficiency of polling.
[0073] In step S103, send the polling results and interrupt signals of at least one register to be polled to the main-kernel operating system to wake up the current service process of the main-kernel operating system through the interrupt signal. Among them, before the co-kernel operating system responds to the polling agent command, the main-kernel operating system controls the current service process to enter the sleep state.
[0074] That is to say, when the polling results corresponding to at least one register to be polled are obtained and the corresponding trigger conditions are met, the polling results of each register to be polled obtained can be sent to the main-kernel operating system. In addition, an interrupt signal can also be sent, and the main-kernel operating system can wake up the currently dormant service process through the received interrupt signal.
[0075] It should be noted that after the main-kernel operating system sends a polling agent command to the co-kernel operating system, it can control the current service process to enter the sleep state, so that the current service process sleeps and releases the core resources of the processor, thereby using this core resource to execute other task processes or enter the low-power state to improve the overall efficiency and resource utilization rate of the system.
[0076] Optionally, 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 the mask value of specific bits of the register to be polled.
[0077] Specifically, the data structure of the polling result sent by the co-kernel operating system to the main-kernel 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 specific bits of the register to be polled.
[0078] Code 2:
[0079] typedef PollAgentResp
[0080] {
[0081] uint64_t register;
[0082] uint64_t value;
[0083] uint64_t mask;
[0084] }PollAgentResp_t;
[0085] Thus, by specifying the mask, the system can process only the required bits, improving processing efficiency; clarifying the register address and value can reduce errors and redundant queries, enhancing system stability; in addition, structured data responses can make communication between systems more standardized, reduce coupling, and facilitate maintenance and expansion.
[0086] According to the agent method for high-frequency polling of an operating system proposed in an embodiment of the present invention, by managing and executing polling tasks based on a preset global variable group by a co-kernel operating system, the burden on the main-kernel operating system can be reduced, task scheduling efficiency can be improved, and inter-core communication overhead can be reduced.
[0087] Figure 3 It is a schematic flowchart of an agent method for high-frequency polling of an operating system provided by another embodiment of the present invention.
[0088] As Figure 3 shown, this agent method for high-frequency polling of an operating system is applied to a main-kernel operating system running on the main-kernel side of a baseboard management controller, and the method includes the following steps:
[0089] In step S301, it is determined whether there is a polling register requirement for the current service process.
[0090] It can be understood that during the running of the current service process, the values of certain registers can be read to determine whether specific conditions are met or data updates are obtained.
[0091] In step S302, when there is a polling register requirement for the current service process, a polling agent command is generated.
[0092] That is to say, if there is a polling register requirement for the current service process, the main-kernel operating system can automatically generate a corresponding polling agent command to ensure the smooth progress of the polling task.
[0093] Optionally, in some embodiments, the polling agent command includes at least one of the address of the register to be polled, the trigger condition, the resident flag, the target value, and the mask.
[0094] Specifically, as shown in Code 1, the polling proxy command includes the address register of the register to be polled, the trigger condition triggerPerChange, the permanent flag isPermanent, the target value target, and the mask mask.
[0095] Thus, through the design of this data structure, the address of the register to be polled can be clearly specified, enabling the co-core operating system to directly locate the target hardware without traversing all registers, thereby reducing the query scope and ineffective polling; optimizing the event trigger mechanism to avoid high-frequency irrelevant status reports; implementing dynamic resource management based on the permanent flag to prevent long-term occupation of co-core resources; specifying the specific bits of interest through the mask to reduce the data processing volume and improve the polling efficiency.
[0096] In step S303, send the polling proxy command to the co-core operating system and receive the polling result generated after the co-core operating system polls the register to be polled.
[0097] That is to say, when there is a need to poll registers in the current service process, the main-core operating system can generate and send a polling proxy command to the co-core operating system to utilize the co-core operating system to perform the polling operation and receive the polling result generated by the co-core operating system polling the register to be polled.
[0098] Furthermore, in some embodiments, before sending the polling proxy command to the co-core operating system, it further includes: creating a polling proxy driver and an interface for the polling proxy driver to send the polling proxy command to the co-core operating system through the interface and / or receive the polling result generated by the co-core operating system.
[0099] It can be understood that the main-core operating system can be divided into a user layer (application layer) and a kernel layer. The user layer (application layer) refers to the layer in the main-core operating system that directly interacts with users, including the application programs run by users, such as text editors, browsers, games, etc. The kernel layer refers to the core part of the main-core operating system, which is responsible for managing system resources, such as the CPU (Central Processing Unit), memory, device drivers, etc. The kernel provides a system call interface for user-layer programs to use and is responsible for scheduling processes, managing the file system, handling network communications, etc. Therefore, in order to execute the task of polling registers, a polling agent driver can be constructed first. The polling agent driver is placed in the kernel as a driver program. At the same time, the register polling agent driver can provide a program interface to other service drivers. The data structure of this interface is shown in Code 3. pPollReq refers to Code 1, that is, the polling agent instruction; pPollResp refers to Code 2, that is, the polling result; daemonFun is a function that runs when the value of the register to be polled changes under the condition of persistent polling. If persistent polling is not required, this parameter is invalid; pDaemonFunData is the parameter of the function that runs when the value of the register to be polled changes under the condition of persistent polling. Similarly, if persistent polling is not required, this parameter is invalid. The purpose is that other service drivers can request polling services (that is, send polling agent commands to the co-core operating system) or obtain polling results through the polling agent driver and its interface. The call and execution of the interface occur in other parts of the kernel, that is, the area where the service driver is located. This process involves the interaction between the main-core operating system and the co-core operating system to ensure the correct sending of polling agent commands and the accurate reception of polling results, so as to achieve real-time monitoring and management of the system state.
[0100] Code 3:
[0101] int pollAgent(PollAgentReq_t *pPollReq,
[0102] PollAgentResp_t *pPollResp,
[0103] int(*)(void *)daemonFun
[0104] void *pDaemonFunData);
[0105] Thus, by directly creating a polling agent driver in the kernel layer, the service driver can directly initiate a polling request through the kernel interface, avoiding data copying and context switching between the user layer and the kernel layer, and significantly reducing data transmission latency.
[0106] Next, the process of the main core operating system sending a polling agent command and receiving a polling result will be described in detail.
[0107] As a possible implementation, in some embodiments, sending a polling agent command to the co - core operating system and receiving the polling result generated after the co - core operating system polls the register to be polled includes: creating a command reply message queue; sending the polling agent command and the handle of 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 condition; if the polling agent command meets the preset continuous polling condition, determining whether the command reply message queue has monitored the polling result; and when the command reply message queue has monitored the polling result, running a preset function and re - executing the step of determining whether the command reply message queue has monitored the polling result.
[0108] Specifically, the main core operating system of the embodiment of the present invention can first create a command reply message queue, which is used to receive the reply from the polling agent driver (i.e., the polling result). Next, based on the interface of the polling agent driver, 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, etc.) 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 condition (i.e., whether continuous polling is required). If the polling agent command meets the preset continuous polling condition, it means continuous polling is needed, then the polling agent driver will enter the monitoring state and continuously monitor the command reply message queue to check if the polling result has been received. If the polling result is monitored in the command reply message queue, then a preset function (i.e., daemonFun) as shown in Figure 5 can be run, and the command reply message queue can be re - monitored to continue waiting for a new polling result, thus forming a continuous loop of polling and processing.
[0109] Therefore, by passing the handle of the command reply message queue instead of directly passing data, the data transmission volume of inter - core communication is reduced. As a lightweight resource identifier, the handle enables the co - core to directly access the shared queue, avoiding repeated transmission of large amounts of data; the judgment mechanism of the preset continuous polling condition realizes intelligent task management. When continuous polling is required, the system automatically enters the monitoring - processing loop, and the daemonFun function is used to achieve continuous event response, ensuring real - time monitoring of key hardware states.
[0110] Further, in some other embodiments, 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, determining whether the command reply message queue monitors a polling result; in the case where the command reply message queue monitors a polling result, receiving the polling result through a preset reply data parameter in the interface, and deleting the command reply message queue.
[0111] That is to say, if the polling agent command does not meet the preset continuous polling condition, it means that persistent polling is not required. Then the polling agent driver can also enter the monitoring state, continuously monitor the command reply message queue, and when the command reply message queue monitors a polling result, directly return the polling result through the preset reply data parameter (i.e., pPollResp) of the interface of the polling agent driver, and delete the command reply message queue.
[0112] Thus, since there is no need to maintain continuous monitoring of the message queue, the number of persistent monitoring threads in the kernel is reduced, and the co-core can release relevant resources after completing a single poll, avoiding the situation of long-term occupation of co-core processing resources.
[0113] Further, in some embodiments, after sending a polling agent command to the co-core operating system, the method further includes: controlling the current service process to enter the 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 service process to end the sleep state and resume the operation of the current service process based on the interrupt signal.
[0114] That is to say, after the main-core operating system sends a polling agent command to the co-core operating system, it immediately controls the current service process to enter the sleep state. During the period when the current service process is in the sleep state, the main-core operating system can continuously monitor whether an interrupt signal from the co-core operating system is received. Once the presence of the interrupt signal is detected, the main-core operating system can take corresponding actions based on the interrupt signal, that is, wake up the current service process in the sleep state and make it resume to the normal operating state.
[0115] Thus, by putting the current service process to sleep, the CPU of the main-core operating system is released to process other tasks, achieving optimal resource allocation on the premise of ensuring real-time performance.
[0116] According to the proxy method for high-frequency polling of an operating system proposed by the embodiments of the present invention, by the main-core operating system issuing a polling agent instruction to enable the co-core operating system to perform a polling operation, the burden on the main-core operating system can be reduced, the task scheduling efficiency can be improved, and the inter-core communication overhead can be reduced.
[0117] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method.
[0118] An embodiment of the present invention further provides an agent device for high-frequency polling of an operating system.
[0119] Figure 4 It is a block diagram of an agent device for high-frequency polling of an operating system according to an embodiment of the present invention.
[0120] As Figure 4 shown, the agent device 10 for high-frequency polling of the operating system is applied to a co-kernel operating system running on the co-kernel side of a baseboard management controller. Among them, the agent device 10 for high-frequency polling of the operating system includes: a response module 100, a polling module 200, and a sending module 300.
[0121] Among them, the response module 100 is used to respond to a polling agent command, where the polling agent command is generated by a main-kernel operating system running on the main-kernel side of the baseboard management controller;
[0122] The polling module 200 is used to poll at least one register to be polled based on the polling agent command, and generate a polling result of at least one register to be polled;
[0123] The sending module 300 is used to send the polling result of at least one register to be polled and an interrupt signal to the main-kernel operating system, so as to wake up the current service process of the main-kernel operating system through the interrupt signal. Among them, before the co-kernel operating system responds to the polling agent command, the main-kernel operating system controls the current service process to enter the sleep state.
[0124] Further, in some embodiments, the polling module 200 includes:
[0125] A storage unit for storing the polling agent command into a preset global variable group;
[0126] A determination unit for traversing the preset global variable group, parsing the polling agent command, and determining the target polling register information;
[0127] A polling unit for polling at least one register to be polled based on the target polling register information, and generating a polling result of at least one register to be polled.
[0128] Further, in some embodiments, the polling unit is specifically used for:
[0129] Judging whether the information of the currently polled register is empty;
[0130] When the information of the currently polled register is not empty, determine the value of the currently polled register, perform an AND operation on the value of the currently polled register and the mask in the target polled register information, and determine whether the result of the AND operation is consistent with the value of the currently polled register;
[0131] If the result of the AND operation is consistent with the value of the currently polled register, after sleeping for a preset duration, re - execute the step of determining whether the information of the currently polled register is empty, otherwise determine whether the trigger condition in the target polled register information meets the first preset condition;
[0132] When the trigger condition in the target polled register information meets the first preset condition, generate a polling result of the currently polled register based on the value of the currently polled register.
[0133] Further, in some embodiments, after determining whether the trigger condition in the target polled register information meets the first preset condition, the polling unit is further configured to:
[0134] If the trigger condition in the target polled register information does not meet the first preset condition, determine whether the value of the currently polled register is consistent with the target value in the target polled register information;
[0135] When the value of the currently polled register is consistent with the target value in the target polled register information, generate a polling result of the currently polled register based on the value of the currently polled register.
[0136] Further, in some embodiments, after determining whether the value of the currently polled register is consistent with the target value in the information of the currently polled register, the polling unit is further configured to:
[0137] When the value of the currently polled register is not consistent with the target value in the target polled register information, determine whether the resident flag in the target polled register information meets the second preset condition;
[0138] If the resident flag in the target polled register information meets the second preset condition, clear the information of the currently polled register and poll the next polled register, otherwise directly poll the next polled register.
[0139] Further, in some embodiments, the polling result includes at least one of the address of the polled register, the value of the polled register, and the mask value of the specific bit of the polled register.
[0140] According to the proxy device for high - frequency polling of the operating system proposed by the embodiments of the present invention, by managing and executing polling tasks based on a preset global variable group through the co - core operating system, the burden on the main - core operating system can be reduced, the task scheduling efficiency can be improved, and the inter - core communication overhead can be reduced.
[0141] Figure 5 It is a block diagram of an agent device for high-frequency polling of an operating system according to another embodiment of the present invention.
[0142] As Figure 5 shown, the agent device 20 for high-frequency polling of the operating system is applied to the main-core operating system running on the main core side of the baseboard management controller. Among them, the agent device 20 for high-frequency polling of the operating system includes: a judgment module 400, a generation module 500, and a transceiver module 600.
[0143] Among them, the judgment module 400 is used to judge whether there is a polling register requirement for the current service process;
[0144] The generation module 500 is used to generate a polling agent command when there is a polling register requirement for the current service process;
[0145] The transceiver module 600 is used to send the polling agent command to the co-core operating system and receive the polling result generated after the co-core operating system polls the register to be polled.
[0146] Further, in some embodiments, before sending the polling agent command to the co-core operating system, the transceiver module 600 is further used for:
[0147] Create a polling agent driver and an interface of the polling agent driver to send the polling agent command to the co-core operating system through the interface and / or receive the polling result generated by the co-core operating system.
[0148] Further, in some embodiments, the transceiver module 600 includes:
[0149] A creation unit for creating a command reply message queue;
[0150] A sending unit for sending the polling agent command and the handle of the command reply message queue to the polling agent driver based on the interface;
[0151] A first judgment unit for judging whether the polling agent command meets the preset continuous polling condition;
[0152] A second judgment unit for judging whether the polling result is monitored in the command reply message queue when the polling agent command meets the preset continuous polling condition;
[0153] An operation unit for running a preset function and re-executing the step of judging whether the polling result is monitored in the command reply message queue when the polling result is monitored in the command reply message queue.
[0154] Further, in some embodiments, after determining whether the command reply message queue meets the preset continuous polling condition, the first determination unit is further configured to:
[0155] In the case where the command reply message queue does not meet the preset continuous polling condition, determine whether the command reply message queue monitors a polling result;
[0156] In the case where the command reply message queue monitors a polling result, receive the polling result through a preset reply data parameter in the interface, and delete the command reply message queue.
[0157] Further, in some embodiments, the polling proxy command includes at least one of the address of the register to be polled, the trigger condition, the resident flag, the target value, and the mask.
[0158] Further, in some embodiments, after sending the polling proxy command to the co-core operating system, the transceiver module 600 is further configured to:
[0159] Control the current service process to enter the sleep state, and determine whether an interrupt signal sent by the co-core operating system is received;
[0160] If an interrupt signal is received, control the current service process to end the sleep state based on the interrupt signal and resume the operation of the current service process.
[0161] For the description of the features in the corresponding embodiments of the proxy device for high-frequency polling of the operating system, reference can be made to the relevant descriptions in the corresponding embodiments of the proxy method for high-frequency polling of the operating system, which will not be elaborated here one by one.
[0162] According to the proxy device for high-frequency polling of the operating system proposed in the embodiments of the present invention, by the main-core operating system issuing a polling proxy instruction to make the co-core operating system perform a polling operation, the burden on the main-core operating system can be reduced, the task scheduling efficiency can be improved, and the inter-core communication overhead can be reduced.
[0163] Figure 6 The structural schematic diagram of the electronic device provided by the embodiments of the present invention. The electronic device may include:
[0164] A memory 601, a processor 602, and a computer program stored on the memory 601 and executable on the processor 602.
[0165] When the processor 602 executes the program, it implements the steps in any of the above-mentioned embodiments of the proxy method for high-frequency polling of the operating system.
[0166] Further, the electronic device further includes:
[0167] A communication interface 603 for communication between the memory 601 and the processor 602.
[0168] A memory 601 for storing a computer program that can run on a processor 602.
[0169] The memory 601 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.
[0170] If the memory 601, the processor 602, and the communication interface 603 are implemented independently, the communication interface 603, the memory 601, and the processor 602 can be interconnected through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.
[0171] Optionally, in a specific implementation, if the memory 601, the processor 602, and the communication interface 603 are integrated on a single chip, the memory 601, the processor 602, and the communication interface 603 can communicate with each other through an internal interface.
[0172] The processor 602 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0173] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, where the computer program is configured to execute the steps in any of the above embodiments of the proxy method for high-frequency polling of an operating system when running.
[0174] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM), a random access memory, a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.
[0175] An embodiment of the present invention further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-described embodiments of the proxy method for high-frequency polling of an operating system.
[0176] An embodiment of the present invention further provides another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-described embodiments of the proxy method for high-frequency polling of an operating system.
[0177] Those skilled in the art can further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present invention.
[0178] The above has introduced in detail a proxy method for high-frequency polling of an operating system provided by the present invention. Specific examples are used herein to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims
1. 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 a co-core end of a baseboard management controller, wherein the method comprises: Responding to a polling proxy command, wherein the polling proxy command is generated by a main core operating system running on a main core end of the baseboard management controller; The polling proxy command is stored in a preset global variable group, the preset global variable group is traversed, the polling proxy command is parsed, target polling register information is determined, at least one register to be polled is polled based on the target polling register information, and a polling result of the at least one register to be polled is generated; Send the polling result of at least one register to be polled and the interrupt signal to the main core operating system to wake up the current business process of the main core operating system through the interrupt signal, wherein before the auxiliary 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 agent method for high-frequency polling of an operating system according to claim 1, characterized in that: The polling the at least one register to be polled based on the target polling register information to generate a polling result of the at least one register to be polled includes: Determine whether the information of the register to be polled is empty; If the information of the current register to be polled is not empty, determine the value of the current register to be polled, perform an AND operation on the value of the current register to be polled and the mask in the target polling register information, and determine whether the AND operation result 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 the step of determining whether the information of the current register to be polled is empty is re-executed after a preset sleep time, otherwise, determining whether the trigger condition in the target polling register information satisfies a first preset condition; When the trigger condition in the target polling register information satisfies the first preset condition, a polling result of the current register to be polled is generated based on the value of the current register to be polled.
3. The agent method for high-frequency polling of an operating system according to claim 2, characterized in that: After determining whether the trigger condition in the target polling register information meets the first preset condition, the method further includes: If the trigger condition in the target polling register information does not meet the first preset condition, determining whether the value of the current register to be polled is consistent with the target value in the target polling register information; When the value of the current register to be polled is consistent with the target value in the target polling register information, a polling result of the current register to be polled is generated based on the value of the current register to be polled.
4. The agent method for high-frequency polling of an operating system according to claim 3, characterized in that: 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, determining whether the resident flag in the target polling register information satisfies a second preset condition; If the resident flag in the target polling register information meets the second preset condition, the information of the current register to be polled is cleared and the next register to be polled is polled; otherwise, the next register to be polled is directly polled.
5. The agent method for high-frequency polling of an operating system according to claim 1, characterized in that: The polling result includes at least one of an address of the register to be polled, a value of the register to be polled, and a mask value of a specific bit of the register to be polled.
6. A 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 a main core end of a baseboard management controller, wherein the method comprises: Determine whether the current business process has a polling register requirement; In the case that the current service process has the polling register requirement, generating a polling proxy command; Sending a polling proxy command to the co-core operating system, and receiving a polling result generated by the co-core operating system after polling the register to be polled; Among them, the sending of the polling proxy command to the co-core operating system and the receiving of the polling result generated by the co-core operating system after polling the register to be polled include: creating a command reply message queue, sending the polling proxy command and the handle of the command reply message queue to the polling proxy driver based on the interface of the polling proxy driver, judging whether the polling proxy command satisfies the preset continuous polling condition, if the polling proxy command satisfies the preset continuous polling condition, judging whether the command reply message queue has listened to the polling result, and if the command reply message queue has listened to the polling result, running the preset function and re-executing the step of judging whether the command reply message queue has listened to the polling result.
7. The agent method for high-frequency polling of an operating system according to claim 6, characterized in that: Before sending the polling proxy command to the cooperative core operating system, the method further includes: A polling proxy driver and an interface of the polling proxy driver are created to send the polling proxy command to the co-core operating system through the interface of the polling proxy driver, and / or receive a polling result generated by the co-core operating system.
8. The agent method for high-frequency polling of an operating system according to claim 6, 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, determining whether the command reply message queue monitors the polling result; When the command reply message queue monitors the polling result, the polling result is received through the preset reply data parameter in the interface driven by the polling agent, and the command reply message queue is deleted.
9. The agent method for high-frequency polling of an operating system according to claim 6, characterized in that: The polling proxy command includes at least one of an address of a register to be polled, a trigger condition, a resident flag, a target value, and a mask.
10. The agent method for high-frequency polling of an operating system according to claim 6, characterized in that: After sending the polling agent command to the co-core operating system, it also includes: Controlling the current service process to enter a sleep state, and determining whether an interrupt signal sent by the cooperative core operating system is received; If the interrupt signal is received, the current business process is controlled to end the sleep state based on the interrupt signal and resume the operation of the current business process.
11. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the proxy method for high-frequency polling of the operating system as described in any one of claims 1 to 5, or the steps of the proxy method for high-frequency polling of the operating system as described in any one of claims 6 to 10 when executing the computer program.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the proxy method for high-frequency polling of the operating system as described in any one of claims 1 to 5, or the steps of the proxy method for high-frequency polling of the operating system as described in any one of claims 6 to 10.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the proxy method for high-frequency polling of an operating system as described in any one of claims 1 to 5 are implemented, or the steps of the proxy method for high-frequency polling of an operating system as described in any one of claims 6 to 10 are implemented.
Citation Information
Patent Citations
Task scheduling method in heterogeneous multi-core architecture
CN104899089A