Real-time scheduling method and system based on Wayland protocol

By introducing the priority keyword and the wlr_scheduler protocol into the Wayland protocol, scheduling policies are dynamically assigned to clients and high- and low-priority queues are created. This solves the problem of clients being unable to automatically request priority adjustments, and achieves efficient real-time response and system compatibility.

CN120743484AActive Publication Date: 2025-10-03成都菁蓉联创科技有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511255305.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-10-03
Estimated Expiration
2045-09-04

AI Technical Summary

Technical Problem

In the existing Wayland protocol, the client cannot communicate with the server through the protocol to request or trigger priority policy adjustments. As a result, clients with high real-time response requirements may be delayed due to event processing queues, affecting the user experience. In addition, the existing solution relies on manual operations, which is cumbersome and inefficient, and lacks automation and scalability.

Method used

The priority keyword is introduced into the Wayland protocol to mark the weight of client events. The wlr_scheduler protocol is constructed. Different scheduling policies are assigned to clients through this protocol binding. High and low priority queues are created on the server side. They are sorted and scheduled according to the priority keyword to achieve priority control of client events.

Benefits of technology

Clients can independently request resource priorities without manual intervention. High-priority events are always processed first to avoid delays, improve system automation and compatibility, and are suitable for various server-side architectures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743484A_ABST
    Figure CN120743484A_ABST
Patent Text Reader

Abstract

The invention discloses a real-time scheduling method and system based on a Wayland protocol, and relates to the field of graphic display based on the Wayland protocol, and the method comprises the following steps: adding prioritization keywords to all client end event structures in a server end; the method comprises the following steps of: constructing a wlrscheduler protocol; different scheduling strategies are distributed to the client side on the basis of the wlrscheduler protocol binding condition; when the server side processes an epoll event, the client side events are put into a high-priority queue or a low-priority queue according to different scheduling strategies, and the client side events in the same queue are sorted according to prioritization keywords; and scheduling the client end events in a manner of preferentially processing the client end events in the high-priority queue and post-processing the client end events in the low-priority queue. And the client can request to start real-time scheduling only by registering a wlrscheduler protocol without modifying a system configuration file or executing a complex command, so that the deployment efficiency and the use convenience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graphic display based on the Wayland protocol, and in particular to a real-time scheduling method and system based on the Wayland protocol. Background Art

[0002] Wayland is a modern graphics display protocol widely used in Linux systems. Traditionally, the Wayland server coordinates the display content of the client and handles events from the client through mechanisms such as epoll. However, in the current implementation, communication between the Wayland client and server, event handling, and scheduling priorities within the operating system all use a default, universal policy, failing to prioritize critical clients.

[0003] In graphics applications that require high real-time response, clients may experience response delays due to default scheduling policies or event processing queues, impacting the user experience. Existing solutions cannot flexibly and dynamically control the client's priority at the kernel scheduling layer through the standard Wayland protocol, nor can they differentiate event processing priorities. To address this issue, existing technologies have made the following improvements: 1. If Figure 2 As shown in the figure, the administrator manually changes the scheduling policy of the specified process to SCHED_RR (real-time scheduling policy) by using the chrt command or writing a script.

[0004] 2. In the Wayland architecture, the server primarily monitors socket events from all clients through the epoll mechanism. When multiple clients generate input or output events simultaneously, the server processes these events in the order in which epoll events are ready. There is no concept of event-level priority. All events are treated as equal, and the order in which they are processed depends primarily on the order and speed of kernel-level readiness notifications.

[0005] The above improvements have the following disadvantages: 1. It relies heavily on manual user operations and cannot automatically determine the importance and set priorities based on client type at runtime. For large-scale system deployments or frequently changing client scenarios, this method is cumbersome and inefficient, and it is difficult to ensure consistency and security.

[0006] 2. Lack of linkage mechanism with the Wayland protocol. The client cannot request or indicate the need for scheduling policy improvement through the standard protocol mechanism, and can only rely on external manual identification and operation, which reduces the system's automation and scalability.

[0007] Even if a client process uses the SCHED_RR scheduling policy, its events are still processed equally in epoll with other normal-priority clients. The Wayland server does not adjust the order of event processing based on a process's scheduling policy. Therefore, when multiple clients are processing concurrent events, critical clients may still experience response delays due to queuing, limiting the performance benefits of the scheduling policy.

[0008] 4. The epoll mechanism only provides a binary "ready" check and fails to introduce an event priority field. This prevents the server from flexibly scheduling based on the importance of the client. This makes it impossible to implement a mechanism similar to "preemptive event response," creating a significant bottleneck in improving user experience.

[0009] In summary, in existing technical solutions, setting scheduling policies relies entirely on manual execution by users or scripts, and is unrelated to the Wayland protocol itself. Clients cannot communicate with the server through the protocol to request or trigger priority policy adjustments, nor can they automatically control their own processing order within the graphics display system. Summary of the Invention

[0010] In response to the above-mentioned deficiencies in the prior art, the present invention provides a real-time scheduling method and system based on the Wayland protocol, which solves the problem in the prior art that the client cannot request or trigger priority policy adjustment by communicating with the server through the protocol, nor can it automatically control its own processing order in the graphics display system.

[0011] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is: A real-time scheduling method based on the Wayland protocol is provided, which includes the following steps: Add the priority keyword to all client-side event structures on the server side; the priority keyword is used to mark the weight of client-side events; Build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark scheduling priorities; Assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; When processing epoll events on the server side, client-side events are placed in a high-priority queue or a low-priority queue according to different scheduling strategies, and client-side events in the same queue are sorted according to the priority keyword; Client events are scheduled by processing client events in the high-priority queue first and processing client events in the low-priority queue later.

[0012] Furthermore, the specific method to add the priority keyword to all client-side event structures on the server side is: By extending the existing Wayland client event resource structure wl_event_source, the priority keyword is added.

[0013] Furthermore, the specific method of assigning different scheduling policies to the client based on the wlr_scheduler protocol binding status includes: Determine whether the current client is bound to the wlr_scheduler protocol. If so, set the client event scheduling policy to the real-time scheduling policy and set the priority keyword in the client event structure to the specified value in the real-time scheduling policy. Otherwise, set the client event scheduling policy to the normal scheduling policy and set the priority keyword in the client event structure to the specified value in the normal scheduling policy.

[0014] Furthermore, the client sends wl_scheduler_requesets() to request binding of the wlr_scheduler protocol, and binds the wlr_scheduler protocol through the wl_registry to complete the wlr_scheduler protocol binding, so that the client can actively request resource priorities in a "declarative" manner without the need for manual user intervention or modification of system parameters.

[0015] Furthermore, the wlr_scheduler protocol is deployed on the server side. The server side responds to the wlr_scheduler protocol binding request from the client side and sets the client-side event scheduling policy that requests binding to the wlr_scheduler protocol to the real-time scheduling policy through the set_self_rr_scheduling() call, and sets the priority keyword in the client-side event structure to the specified value in the real-time scheduling policy.

[0016] Furthermore, the specific methods for placing client events into a high-priority queue or a low-priority queue according to different scheduling strategies and sorting client events in the same queue according to the priority keyword include: After receiving all client events in the main loop of the server, client events using the real-time scheduling strategy will be placed in the high-priority queue in descending order of client event weight, and client events using the normal scheduling strategy will be placed in the low-priority queue in descending order of client event weight.

[0017] Furthermore, when different client-side events in the same queue have the same client-side event weight, they are sorted according to the order in which the events are triggered.

[0018] A system for a real-time scheduling method based on the Wayland protocol is provided, comprising: The protocol building module is used to build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark the scheduling priority; The protocol registration module is used to process the client's binding request for the wlr_scheduler protocol; The priority allocation module is used to add the priority keyword to all client-side event structures on the server side; the priority keyword is used to mark the weight of the client-side event; The scheduling control module is used to assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; The sorting processing module is used to put client events into high-priority queues or low-priority queues according to different scheduling strategies, and sort client events in the same queue according to the priority keyword; The resource scheduling module is used to schedule client-side events by giving priority to client-side events in the high-priority queue and processing client-side events in the low-priority queue later.

[0019] A computer device is provided, comprising a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes the steps of a real-time scheduling method based on the Wayland protocol.

[0020] A computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of a real-time scheduling method based on the Wayland protocol.

[0021] The beneficial effects of the present invention are: 1. The client only needs to register the wlr_scheduler protocol to request the activation of real-time scheduling, without modifying system configuration files or executing complex commands, which improves deployment efficiency and ease of use; 2. Centrally control scheduling and event processing sequence through the server to ensure reasonable allocation of system resources; 3. The introduction of the priority keyword weight mechanism supports multi-level priority control, rather than the crude "whether to register the agreement" dichotomy; 4. After using the dual-queue model, critical client events can be isolated from non-critical events, effectively avoiding performance bottlenecks caused by equal processing of all events on the server side; 5. It can ensure that events from high-priority clients always enter the high-priority queue first, and no longer compete fairly with ordinary events, thus avoiding the situation where "important tasks are blocked by low-priority tasks"; 6. Clients that are not registered with the wlr_scheduler protocol will still use the original scheduling and event processing process to ensure compatibility with old clients and systems; 7. The present invention requires little modification and has clear logic. It is applicable to various Wayland-based server architectures including wlroots, Weston, KWin, etc., and is easy to transplant and integrate. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 Schematic diagram of the process of this method; Figure 2 A schematic diagram of manually setting a scheduling strategy in the prior art; Figure 3 Schematic diagram of the real-time scheduling strategy based on the Wayland protocol on the server side of the embodiment; Figure 4 4 is a scheduling flowchart of the client in the embodiment. DETAILED DESCRIPTION

[0023] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.

[0024] Example 1: like Figure 1 As shown, the real-time scheduling method based on the Wayland protocol includes the following steps: S1. Add the priority keyword to all client-side event structures on the server side. The priority keyword is used to mark the weight of the client-side event. S2. Build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark scheduling priorities; S3. Assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; S4. When processing epoll events on the server side, the client-side events are placed in a high-priority queue or a low-priority queue according to different scheduling strategies, and the client-side events in the same queue are sorted according to the priority keyword; S5. Schedule client-side events by processing client-side events in a high-priority queue first and processing client-side events in a low-priority queue later.

[0025] In this embodiment, the client event registration function wl_event_loop_add_fd() provided by the Waylandy source code is overloaded, and a new event registration function wl_event_loop_add_fd_with_priority() is added to add the keyword priority to allow the client to declare its priority requirement during the connection or registration phase.

[0026] Specifically, the specific method to add the priority keyword to all client-side event structures on the server side is: By extending the existing Wayland client event resource structure wl_event_source, the priority keyword is added.

[0027] The above operations extend the client event data structure in the Wayland internal event loop, introduce the priority attribute field, and rewrite the event registration interface to allow the specification of priority when registering an event, thereby achieving event-level scheduling control.

[0028] In this embodiment, if Figure 3 As shown in the figure, the specific methods for assigning different scheduling policies to the client based on the wlr_scheduler protocol binding status include: Determine whether the current client is bound to the wlr_scheduler protocol. If so, set the client event scheduling policy to the real-time scheduling policy and set the priority keyword in the client event structure to the specified value in the real-time scheduling policy (such as 1 or other numerical values). Otherwise, set the client event scheduling policy to the normal scheduling policy (such as SCHED_OTHER) and set the priority keyword in the client event structure to the specified value in the normal scheduling policy (such as 0 or other numerical values).

[0029] In this embodiment, the client sends a wl_scheduler_requesets() request to bind the wlr_scheduler protocol, and the wlr_scheduler protocol is bound through the wl_registry to complete the wlr_scheduler protocol binding. This method allows the client to actively request resource priorities in a "declarative" manner without the need for manual user intervention or modification of system parameters.

[0030] In this embodiment, the wlr_scheduler protocol is deployed on the server side. In response to the wlr_scheduler protocol binding request from the client side, the server side extracts the PID of the client side process that requested the wlr_scheduler protocol binding, sets the client side event scheduling policy to the real-time scheduling policy (SCHED_RR) through the set_self_rr_scheduling() call, and sets the priority keyword in the client side event structure to the specified value in the real-time scheduling policy.

[0031] In this embodiment, if Figure 4 As shown in the figure, the specific methods for placing client events into high-priority queues or low-priority queues according to different scheduling strategies and sorting client events in the same queue according to the priority keyword include: After receiving all client events in the main loop of the server, client events using the real-time scheduling strategy will be placed in the high-priority queue in descending order of client event weight, and client events using the normal scheduling strategy will be placed in the low-priority queue in descending order of client event weight.

[0032] The above operations implement two queue processing mechanisms in the Wayland source code. The high-priority queue contains all events from clients registered with the wlr_scheduler protocol. The normal-priority queue contains events from clients not registered with the protocol. Events are processed in the order of their readiness. When a large number of events are generated by the client, events captured by epoll_wait() in the event processing flow are categorized by whether the client is registered with the wlr_scheduler protocol. Events from clients registered with the protocol are placed in the high-priority queue, and all other events are placed in the normal-priority queue. When scheduling events, events in the high-priority queue are processed first, followed by events in the normal-priority queue. Events within the queue are sorted in descending order of priority, with events with higher priority being responded to first.

[0033] During implementation, the dual-queue processing mechanism implemented in the Wayland source code presupposes the presence of the priority keyword in the client event data structure, which identifies the event priority. During system initialization, a high-priority queue and a normal-priority queue are created, and queue scheduling parameters (starvation protection, and the maximum number of high-priority events to be processed per round) are set. The existing callback processing method, which invokes the callback upon return from epoll_wait(), has been modified to: 1. Enqueue events as they become available; 2. Schedule queue events uniformly. All received events are queued separately. Within a while loop, queue events are dispatched according to a first-in-first-out (FIFO) policy, prioritizing the high-priority queue. Furthermore, if the normal queue remains non-empty for an extended period, a starvation protection mechanism is triggered, forcing a switch to processing normal-priority events to ensure overall system fairness and responsiveness. If different client events in the same queue have the same client weight, they are sorted according to the order in which they were triggered.

[0034] Example 2: This embodiment is a further extension of the first embodiment. In this embodiment, a system for a real-time scheduling method based on the Wayland protocol is provided, including: The protocol building module is used to build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark the scheduling priority; The protocol registration module is used to process the client's binding request for the wlr_scheduler protocol; The priority allocation module is used to add the priority keyword to all client-side event structures on the server side; the priority keyword is used to mark the weight of the client-side event; The scheduling control module is used to assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; The sorting processing module is used to put client events into high-priority queues or low-priority queues according to different scheduling strategies, and sort client events in the same queue according to the priority keyword; The resource scheduling module is used to schedule client-side events by giving priority to client-side events in the high-priority queue and processing client-side events in the low-priority queue later.

[0035] A computer device is provided, comprising a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes the steps of a real-time scheduling method based on the Wayland protocol.

[0036] A computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of a real-time scheduling method based on the Wayland protocol.

[0037] In summary, this invention dynamically sets either a real-time or standard scheduling policy for the current process based on client-side registration of the wlr_scheduler protocol. Furthermore, because the wlr_scheduler protocol configures priority keywords (weights), the server's internal event response can respond to events promptly based on these weights. This design ensures that responses to critical client events are not blocked by other standard clients, effectively resolving the issue of delays in important events caused by the "first-come, first-served" nature of the traditional epoll model.

Claims

1. A real-time scheduling method based on the Wayland protocol, characterized in that: The following steps are involved: Add the priority keyword to all client-side event structures on the server side; the priority keyword is used to mark the weight of client-side events; Build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark scheduling priorities; Assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; When processing epoll events on the server side, client-side events are placed in a high-priority queue or a low-priority queue according to different scheduling strategies, and client-side events in the same queue are sorted according to the priority keyword; Client events are scheduled by processing client events in the high-priority queue first and processing client events in the low-priority queue later.

2. The real-time scheduling method based on the Wayland protocol according to claim 1, characterized in that: The specific method to add the priority keyword to all client-side event structures on the server side is: By extending the existing Wayland client event resource structure wl_event_source, the priority keyword is added.

3. The real-time scheduling method based on the Wayland protocol according to claim 1, characterized in that: The specific methods for assigning different scheduling policies to the client based on the wlr_scheduler protocol binding status include: Determine whether the current client is bound to the wlr_scheduler protocol. If so, set the client event scheduling policy to the real-time scheduling policy and set the priority keyword in the client event structure to the specified value in the real-time scheduling policy. Otherwise, set the client event scheduling policy to the normal scheduling policy and set the priority keyword in the client event structure to the specified value in the normal scheduling policy.

4. The real-time scheduling method based on the Wayland protocol according to claim 3, characterized in that: The client sends wl_scheduler_requesets() to request the wlr_scheduler protocol to be bound, and then binds the wlr_scheduler protocol through the wl_registry to complete the wlr_scheduler protocol binding. This allows the client to actively request resource priorities in a "declarative" manner without manual user intervention or modification of system parameters.

5. The real-time scheduling method based on the Wayland protocol according to claim 4, characterized in that: The wlr_scheduler protocol is deployed on the server side. The server responds to the client's wlr_scheduler protocol binding request and sets the client's event scheduling policy to the real-time scheduling policy through the set_self_rr_scheduling() call. It also sets the priority keyword in the client's event structure to the value specified in the real-time scheduling policy.

6. The real-time scheduling method based on the Wayland protocol according to claim 1, characterized in that: The specific methods for placing client events into high-priority queues or low-priority queues according to different scheduling strategies and sorting client events in the same queue according to the priority keyword include: After receiving all client events in the main loop of the server, client events using the real-time scheduling strategy will be placed in the high-priority queue in descending order of client event weight, and client events using the normal scheduling strategy will be placed in the low-priority queue in descending order of client event weight.

7. The real-time scheduling method based on the Wayland protocol according to claim 1, characterized in that: When different client events in the same queue have the same client event weight, they are sorted in the order in which the events are triggered.

8. A system based on the real-time scheduling method based on the Wayland protocol according to any one of claims 1 to 7, characterized in that: include: The protocol building module is used to build the wlr_scheduler protocol; the wlr_scheduler protocol is used to mark the scheduling priority; The protocol registration module is used to process the client's binding request for the wlr_scheduler protocol; The priority allocation module is used to add the priority keyword to all client-side event structures on the server side; the priority keyword is used to mark the weight of the client-side event; The scheduling control module is used to assign different scheduling policies to the client based on the wlr_scheduler protocol binding status; The sorting processing module is used to put client events into high-priority queues or low-priority queues according to different scheduling strategies, and sort client events in the same queue according to the priority keyword; The resource scheduling module is used to schedule client-side events by giving priority to client-side events in the high-priority queue and processing client-side events in the low-priority queue later.

9. A computer device, characterized in that: The system comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the real-time scheduling method based on the Wayland protocol as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that A computer program is stored, and when the computer program is executed by a processor, the processor executes the steps of the real-time scheduling method based on the Wayland protocol according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing method, system and equipment based on Internet of Things terminal and medium

    CN117608822A

  • System supporting qt4 to adapt to wayland and wayland interaction method

    CN119248268A

  • Task scheduling method and device, electronic equipment and computer readable storage medium

    CN119440778A

  • Priority based scheduling

    US20180210756A1