Operating system lock-free cross-core communication method in task binding scheduling mode

By adopting a lock-free cross-core communication method in the task-bound scheduling mode, and using an independent queue structure to achieve lock-free cross-core communication in a multi-core operating system, the deadlock and task hunger caused by the traditional lock mechanism are solved, and the reliability and certainty of the system are improved.

CN119883682AActive Publication Date: 2025-04-25XIAN AVIATION COMPUTING TECH RES INST OF AVIATION IND CORP OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411957010.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-29
Publication Date
2025-04-25
Estimated Expiration
2044-12-29

AI Technical Summary

Technical Problem

Traditional locking mechanisms may lead to deadlocks or task hunger in parallel execution of multi-cores, making it difficult to ensure the certainty and reliability of the operating system.

Method used

The lock-free cross-core communication method is adopted in the task-bound scheduling mode. By establishing an independent queue on each core, the sending processor core is responsible for operating the independent queue, and the receiving processor core only checks and processes the flags of queue elements, achieving cross-core communication without spin locks or mutexes.

Benefits of technology

In the task-bound scheduling mode, lock-free cross-core communication between multiple cores is realized, which improves the reliability and certainty of the system and avoids the problems of deadlock and task hunger.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883682A_ABST
    Figure CN119883682A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of computer system software, and particularly relates to a lock-free cross-core communication method for an operating system in a task binding scheduling mode, which comprises the following steps of: establishing a special independent queue structure of a queue matrix in the task binding scheduling mode; the sending processor core and the receiving processor core operate the independent queues based on a lock-free mode at the same time; the invention provides a lock-free cross-core communication mechanism of an operating system in a task binding scheduling mode, which can realize cross-core communication without spin lock or mutual exclusion among multiple cores of the operating system in the task binding scheduling mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer system software, and in particular relates to a lock-free cross-core communication method for an operating system in a task binding scheduling mode. Background Art

[0002] With the development of virtualized operating systems, mixed-key embedded operating systems are gradually being promoted and used on a large scale in the embedded field. However, the real-time operating system in the embedded field faces the deterministic problem of multi-core parallel execution, and the traditional locking mechanism may lead to deadlock or task starvation. Summary of the invention

[0003] In view of this, the present invention provides a method for lock-free cross-core communication of an operating system under a task binding scheduling mode, and provides a lock-free cross-core communication mechanism for an operating system under a task binding scheduling mode, which can enable cross-core communication without spin locks or mutexes between multiple cores of an operating system under the task binding scheduling mode.

[0004] The technical solution of the present invention:

[0005] A lock-free cross-core communication method for operating system in task binding scheduling mode: establishing a special queue matrix independent queue structure in task binding mode scheduling;

[0006] The sending processor core and the receiving processor core operate the independent queue in a lock-free manner;

[0007] Wherein: the structure of the independent queue can only be operated by the sending processor core, and the receiving processor core only operates the flag in the element information in the received independent queue.

[0008] Furthermore, a special queue matrix independent queue structure is established under the task binding mode scheduling based on the following methods: the operating system running under the task binding scheduling mode is set to bind the running of tasks to each physical core; the cross-core call request element information is set to be stored in the task control block on each core; when each core is initialized, the cross-core call request element information is initialized;

[0009] In the system architecture where the sending processor core and the receiving processor core are located, each core uses a one-way queue with other cores to process cross-core call requests, specifically: each sending processor core has a set of independent queues connected to other processor cores.

[0010] Furthermore, the specific operations in each unidirectional queue of communication are only changed by the tasks on the sending processor core. Under task binding scheduling, cross-core operation is not performed during task operation. When operating independent queues, the scheduling of the local core is turned off to ensure the atomicity of critical section operations.

[0011] Furthermore, the lock-free cross-core communication method adopts unidirectional independent queues of two processor cores in the queue matrix. The object of each independent queue is the task running on each core. The critical section is protected by closing scheduling to prevent the switching of the task of the core from interrupting the operation of adding and removing the request element information from the independent queue.

[0012] Further, the receiving processor core only checks the independent queue to determine whether there are elements that need to be processed on the independent queue;

[0013] Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, the flag bit of the request element information is changed to indicate that the receiving processor core needs to process it;

[0014] The current task of the sending processor core puts the request element information that the receiving processor core needs to process into an independent queue, and uses the inter-core asynchronous method provided by the operating system to notify the receiving processor core, triggering the processing of the independent queue in the queue matrix.

[0015] Furthermore, the processing method of inter-core asynchronous notification adopts inter-core interrupt notification processing or each core starts task polling reception processing of its own core: on the receiving processor core, when the notification of the arrival of element information is received, the independent queue corresponding to the sending processor core is checked, and then the element information of the independent queue is processed. When each element information is processed, the flag of the element is set to the request completion flag; when the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core; when the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses the independent queue of the processor core and processes all completed element information, and dequeues the processed element information from the independent queue; if it is found that there is still unprocessed element information in the independent queue, the inter-core asynchronous notification is sent to the receiving processor core again.

[0016] Furthermore, the lock-free cross-core communication method of the operating system implements cross-core communication based on the following steps:

[0017] Step 1: Initialize each core of the system, perform cross-core call request element information and allocate queue matrix during initialization.

[0018] Step 2: Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, it clearly marks that the receiving processor core needs to process it;

[0019] Step 3: Use inter-core interrupt notification processing or each core starts task polling reception processing of the core; on the receiving processor core, check the independent queue corresponding to the sending processor core, the element information of the independent queue is processed, and set as the request completion flag;

[0020] Step 4: When the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core;

[0021] Step 5: When the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses and processes all completed element information in the independent queue.

[0022] Beneficial effects of the present invention:

[0023] The present invention realizes a lock-free cross-core communication mechanism of an operating system in a task binding scheduling mode, which can enable lock-free cross-core communication between multiple cores of an operating system in the task binding scheduling mode, thereby improving system reliability and certainty. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0025] Figure 1 This is the overall architecture diagram of the lock-free cross-core communication mechanism. DETAILED DESCRIPTION

[0026] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0027] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0028] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.

[0029] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The illustrations only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0030] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0031] In one embodiment of the present invention, a lock-free cross-core communication method for an operating system in a task binding scheduling mode is proposed: a special queue matrix independent queue structure is established in the task binding mode scheduling;

[0032] The sending processor core and the receiving processor core operate the independent queue in a lock-free manner;

[0033] Wherein: the structure of the independent queue can only be operated by the sending processor core, and the receiving processor core only operates the flag in the element information in the received independent queue.

[0034] In this embodiment, a special queue matrix independent queue structure is established under the task binding mode scheduling based on the following method: the operating system running under the task binding scheduling mode is set to bind the running of tasks to each physical core; the cross-core call request element information is set to be stored in the task control block on each core; when each core is initialized, the cross-core call request element information is initialized;

[0035] In the system architecture where the sending processor core and the receiving processor core are located, each core uses a one-way queue with other cores to process cross-core call requests, specifically: each sending processor core has a set of independent queues connected to other processor cores.

[0036] In this embodiment, the specific operations within each communicating unidirectional queue are only changed by the tasks on the sending processor core. Under task binding scheduling, cross-core operation is not performed during the task operation process. When operating independent queues, the scheduling of the current core is turned off to ensure the atomicity of the critical section operation.

[0037] In this embodiment, the lock-free cross-core communication method adopts unidirectional independent queues of two processor cores in the queue matrix, and the object of operating each independent queue is the task running on each core. The critical section protection is performed using shutdown scheduling to prevent the switching of the task of the current core from interrupting the operation of adding and removing queues of the request element information of the independent queue.

[0038] In this embodiment, the receiving processor core only checks the independent queue to determine whether there is an element that needs to be processed on the independent queue;

[0039] Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, the flag bit of the request element information is changed to indicate that the receiving processor core needs to process it;

[0040] The current task of the sending processor core puts the request element information that the receiving processor core needs to process into an independent queue, and uses the inter-core asynchronous method provided by the operating system to notify the receiving processor core, triggering the processing of the independent queue in the queue matrix.

[0041] In this embodiment, the processing method of inter-core asynchronous notification adopts inter-core interrupt notification processing or each core starts task polling reception processing of this core: on the receiving processor core, when the notification of the arrival of element information is received, the independent queue corresponding to the sending processor core is checked, and then the element information of the independent queue is processed. When each element information is processed, the flag of the element is set to the flag of the request completion; when the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core; when the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses the independent queue of the processor core and processes all completed element information, and dequeues the processed element information from the independent queue; if it is found that there is still unprocessed element information in the independent queue, the inter-core asynchronous notification is sent to the receiving processor core again.

[0042] In this embodiment, the lock-free cross-core communication method of the operating system implements cross-core communication based on the following steps:

[0043] Step 1: Initialize each core of the system, perform cross-core call request element information and allocate queue matrix during initialization.

[0044] Step 2: Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, it clearly marks that the receiving processor core needs to process it;

[0045] Step 3: Use inter-core interrupt notification processing or each core starts task polling reception processing of the core; on the receiving processor core, check the independent queue corresponding to the sending processor core, the element information of the independent queue is processed, and set as the request completion flag;

[0046] Step 4: When the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core;

[0047] Step 5: When the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses and processes all completed element information in the independent queue.

[0048] See also Figure 1 In the operating system running in the task binding scheduling mode of this embodiment, the running of tasks is bound to each physical core. The cross-core call request element information is stored in the task control block on each core, and the cross-core call request element information is initialized when each core is initialized.

[0049] In the cross-core call architecture design of this embodiment, each core uses a separate one-way queue for communication between one core and another core to process cross-core call requests. Specifically, each sending processor core has a set of independent queues to connect to other processor cores. For example, a processor has N processor cores, and CPU0 prepares N-1 queues to connect other N-1 processor cores CPU1 to CPU N-1. For the entire processor, N*(N-1) queue matrices need to be allocated.

[0050] In order to design a lock-free system in this embodiment, the specific operations in each unidirectional queue of communication are only changed by the task on the sending processor core. Under task binding scheduling, cross-core operation is not performed during the task operation process. When operating independent queues, the scheduling of the core is turned off to ensure the atomicity of critical section operations. The queue matrix uses two processor core unidirectional independent queues. The object of operating each independent queue is the task running on each core, so the critical section protection is performed by closing the scheduling to avoid the switching of the core task interrupting the operation of the request element information of the independent queue.

[0051] In order to design a lock-free implementation in this embodiment, the receiving processor core only checks the independent queue to determine whether there are elements that need to be processed on it. Before the current task on the sending processor core connects the request element information in the control block of this task to the independent queue, it clearly marks that the receiving processor core needs to process it. The current task of the sending processor core puts the request element information in the control block of this task into the independent queue, and uses the inter-core asynchronous notification provided by the operating system to the receiving processor core to trigger the processing of the independent queue in the queue matrix.

[0052] The processing method of inter-core asynchronous notification is to use inter-core interrupt notification processing or each core starts the task polling reception processing of its own core. On the receiving processor core, when the notification of element information arrival is received, the independent queue corresponding to the sending processor core is checked, and the element information of the independent queue is processed. When each element information is processed, the flag of the element is set to the request completion flag. When the element information in an independent queue is processed, a completion inter-core asynchronous notification will be sent to the sending processor core.

[0053] When the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses the independent queue of the processor core and processes all completed element information, and dequeues the processed element information from the independent queue. If it is found that there is still unprocessed element information in the independent queue (probably because the information sent by the core task to the receiving processor core has not been processed in time), the inter-core asynchronous notification is sent to the receiving processor core again.

[0054] This embodiment does not use a spin lock, does not allow the receiving processor core to operate the overall structure of the independent queue, and only sets the flag bit of the element information to mark the processing status of the element information. The structural operations of the independent queues of all matrix queues are performed by the sending processor core, and the task scheduling of this core is only turned off in the structure of the independent queue that uses the matrix queue.

[0055] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A lock-free cross-core communication method for an operating system in a task binding scheduling mode, characterized by: Establish a special queue matrix independent queue structure under task binding mode scheduling; The sending processor core and the receiving processor core operate the independent queue in a lock-free manner; Wherein: the structure of the independent queue can only be operated by the sending processor core, and the receiving processor core only operates the flag in the element information in the received independent queue.

2. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 1, characterized in that: A special queue matrix independent queue structure is established under the task binding mode scheduling based on the following method: the operating system running under the task binding scheduling mode is set to bind the running of tasks to each physical core; the cross-core call request element information is set to be stored in the task control block on each core; When each core is initialized, the cross-core call request element information is initialized; In the system architecture where the sending processor core and the receiving processor core are located, each core uses a one-way queue with other cores to process cross-core call requests, specifically: each sending processor core has a set of independent queues connected to other processor cores.

3. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 2, characterized in that: The specific operations in each unidirectional queue of communication are only changed by the tasks on the sending processor core. Under task binding scheduling, cross-core operation is not performed during task operation. When operating independent queues, the scheduling of the local core is turned off to ensure the atomicity of critical section operations.

4. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 3, characterized in that: The lock-free cross-core communication method uses unidirectional independent queues of two processor cores in the queue matrix. The object of each independent queue is the task running on each core. Close scheduling is used to protect the critical section to prevent the switching of the task of the core from interrupting the operation of adding and removing the request element information from the independent queue.

5. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 4, characterized in that: The receiving processor core only checks the independent queue to determine whether there is an element that needs to be processed on the independent queue; Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, the flag bit of the request element information is changed to indicate that the receiving processor core needs to process it; The current task of the sending processor core puts the request element information that the receiving processor core needs to process into an independent queue, and uses the inter-core asynchronous method provided by the operating system to notify the receiving processor core, triggering the processing of the independent queue in the queue matrix.

6. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 5, characterized in that: The processing method of inter-core asynchronous notification is to use inter-core interrupt notification processing or each core starts the task polling reception processing of its own core: on the receiving processor core, when the notification of the arrival of element information is received, the independent queue corresponding to the sending processor core is checked, and then the element information of the independent queue is processed. When each element information is processed, the flag of the element is set to the request completion flag; when the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core; when the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses the independent queue of the processor core and processes all completed element information, and dequeues the processed element information from the independent queue; if it is found that there is still unprocessed element information in the independent queue, the inter-core asynchronous notification is sent to the receiving processor core again.

7. The method for lock-free cross-core communication of an operating system in a task binding scheduling mode according to claim 6, characterized in that: The lock-free cross-core communication method of the operating system implements cross-core communication based on the following steps: Step 1: Initialize each core of the system, perform cross-core call request element information and allocate queue matrix during initialization; Step 2: Before the current task on the sending processor core connects the request element information in the task control block to the independent queue, it clearly marks that the receiving processor core needs to process it; Step 3: Use inter-core interrupt notification processing or each core starts task polling reception processing of the core; on the receiving processor core, check the independent queue corresponding to the sending processor core, the element information of the independent queue is processed, and set as the request completion flag; Step 4: When the element information in an independent queue is processed, a completion inter-core asynchronous notification is sent to the corresponding sending processor core; Step 5: When the sending processor core receives the inter-core asynchronous notification from the receiving processor core, it traverses and processes all completed element information in the independent queue.

Citation Information

Patent Citations

  • A heterogeneous multi-core CPU communication system and method without lock mechanism

    CN109542832A

  • Method and system for communication between lockless processors

    CN114356834A

  • Synchronization scheduling apparatus and method in real-time mult-core system

    US20120159501A1