Method and device for controlling access to shared resources, storage medium and electronic device
By using a designated operating system in multi-system devices for shared resource access control and allocating access permissions based on priority policies, the problem of low access control flexibility caused by hardware circuits is solved, and flexible priority adjustment and efficient resource utilization are achieved. .
Patent Information
- Application Number
- CN202411372929.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The access control method of shared resources in the prior art uses hardware circuits, resulting in low flexibility in access control and cannot adjust the priority policy according to actual operation.
By specifying the operating system to obtain shared resource access requests for multiple systems, allocate access permissions based on the set priority policy, and send notification messages to other systems to realize mutually exclusive access control of shared resources.
No need for single-board hardware changes, priority strategies can be flexible and changeable, and appropriate priority strategies can be dynamically selected according to the runtime scenario to improve the efficiency of shared resources.
Smart Images

Figure CN118885307B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and more specifically, to a method and device for controlling access to shared resources, a storage medium, and an electronic device. Background Art
[0002] A multi-system is a system that combines multiple processors and / or computing units. A multi-system can be heterogeneous, which means a system that combines multiple different types of processors and / or computing units. A multi-system has many shared resources, such as shared peripherals.
[0003] Currently, mutually exclusive access to shared resources between multiple systems is implemented based on a bus arbiter. However, the bus arbiter is a hardware circuit, and once the arbitration algorithm of the bus arbiter is designed, it cannot be changed, nor can the priority strategy be adjusted according to actual operating conditions.
[0004] It can be seen that the access control method for shared resources in the related art has the problem of low flexibility of access control due to the use of hardware circuits for access control. Summary of the invention
[0005] The embodiments of the present application provide a method and device for access control of shared resources, a storage medium and an electronic device, so as to at least solve the problem that the access control method of shared resources in the related art has low flexibility of access control due to the use of hardware circuits for access control.
[0006] According to one embodiment of the present application, a method for controlling access to shared resources is provided, which is applied to a multi-system device, and includes: obtaining resource access requests of target shared resources of multiple first systems through a specified operating system, wherein the systems running on the multi-system device include the specified operating system and the multiple first systems, the target shared resource is a resource mutually exclusively accessed by the systems running on the multi-system device, and the resource access request of the target shared resource is used to request access rights to the target shared resource; when the target shared resource is in an idle state, based on a specified priority policy, assigning access rights to the target shared resource to a first target system with the highest priority among the multiple first systems through the specified operating system, wherein the specified priority policy is used to limit the priority of the systems running on the multi-system device; and sending a first notification message to other first systems among the multiple first systems except the first target system through the specified operating system, wherein the first notification message is used to notify the other first systems that requests for access rights to the target shared resource have failed.
[0007] According to another embodiment of the present application, there is provided an access control device for a shared resource, which is applied to a multi-system device, and includes: a first acquisition unit, which is used to acquire resource access requests of target shared resources of multiple first systems through a specified operating system, wherein the systems running on the multi-system device include the specified operating system and the multiple first systems, the target shared resource is a resource mutually exclusively accessed by the systems running on the multi-system device, and the resource access request of the target shared resource is used to request access rights to the target shared resource; a first allocation unit, which is used to allocate access rights to the target shared resource to a first target system with the highest priority among the multiple first systems through the specified operating system based on a specified priority policy when the target shared resource is in an idle state, wherein the specified priority policy is used to limit the priority of the system running on the multi-system device; a first sending unit, which is used to send a first notification message to other first systems among the multiple first systems except the first target system through the specified operating system, wherein the first notification message is used to notify the other first systems that their requests for access rights to the target shared resource have failed.
[0008] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0009] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0010] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0011] Through the present application, a method of mutually exclusive access to shared resources is adopted based on a designated operating system on a multi-system device. The designated operating system monitors resource access requests for shared resources issued by each system, and responds to the corresponding system according to a set arbitration algorithm (i.e., a designated priority policy). Since the arbitration of shared resources is implemented in the form of software, there is no need to change the hardware of the single board, and the priority policy can be flexible and changeable. The appropriate priority policy can be dynamically selected according to the runtime scenario, thereby solving the problem of low flexibility of access control in the access control method of shared resources in the related art due to the use of hardware circuits for access control. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a hardware structure block diagram of a server device of a shared resource access control method according to an embodiment of the present application.
[0013] Figure 2 It is a flow chart of a method for controlling access to shared resources according to an embodiment of the present application.
[0014] Figure 3 It is a schematic diagram of a method for controlling access to shared resources in the related art.
[0015] Figure 4 It is a schematic diagram of a method for controlling access to shared resources according to an embodiment of the present application.
[0016] Figure 5 It is a flowchart of another method for controlling access to shared resources according to an embodiment of the present application.
[0017] Figure 6 It is a flowchart of another method for controlling access to shared resources according to an embodiment of the present application.
[0018] Figure 7 This is a structural block diagram of an optional shared resource access control device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0022] The method embodiments provided in the embodiments of the present application can be executed in a multi-system device (for example, a server device or a similar computing device). Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a shared resource access control method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0023] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the access control method for shared resources in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0024] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a NIC (Network Interface Controller), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be an RF (Radio Frequency) module, which is used to communicate with the Internet wirelessly.
[0025] In this embodiment, a method for controlling access to a shared resource is provided. Figure 2 is a flow chart of a method for controlling access to a shared resource according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0026] Step S202, obtaining resource access requests for target shared resources of multiple first systems through a specified operating system, wherein the system running on the multi-system device includes a specified operating system and multiple first systems, the target shared resource is a resource that is mutually exclusively accessed by the systems running on the multi-system device, and the resource access request for the target shared resource is used to request access rights to the target shared resource.
[0027] The shared resource access control method in this embodiment can be applied to the scenario where multiple system devices access shared resources. At least some embodiments in this application take the multiple system devices as heterogeneous systems and the shared resources as peripherals as examples. It should be noted that the shared resource access control method in this embodiment can be applied to not limited to heterogeneous systems, but also to other types of devices, and is also applicable to multiple systems with the same architecture; the shared resources arbitrated by the shared resource access control method in this embodiment include but are not limited to peripherals, and can be all devices that need to solve problems such as shared mutual exclusion.
[0028] Alternatively, a heterogeneous system refers to a system that combines systems of multiple different types of architectures. For example, the BMC (Board Management Controller, a controller based on the IPMI technical design specification that provides intelligent management for the server motherboard) on a server product generally runs the Linux operating system (full name GNU / Linux, a free-to-use and freely disseminated Unix-like operating system, a multi-user, multi-tasking, multi-threaded and multi-CPU operating system based on POSIX), in addition to CPLD (Complex Programmable Logic Device) and FPGA (Field-Programmable Gate Array) responsible for different functions, which is a typical heterogeneous system. Compared with traditional single-architecture systems, heterogeneous systems have the advantages of diversity, flexibility, and high efficiency. Since heterogeneous systems have many shared peripherals, the problem of mutually exclusive access to peripherals by different systems determines the overall performance of the heterogeneous system.
[0029] The server product technical solution in the related art realizes resource mutual exclusion between heterogeneous systems mainly based on bus arbitrator. Figure 3 ,The technical solution based on the bus arbiter is that multiple heterogeneous systems are connected to the bus arbiter, and the bus arbiter arbitrates the system applications and ,decides which system can occupy the bus.
[0030] However, the technical solutions in the related art have the following disadvantages and problems: (1) the bus arbitrator is a hardware circuit; (2) the arbitration algorithm of the bus arbitrator cannot be changed once it is designed, and the priority algorithm cannot be adjusted according to the actual operation situation. In addition, for server products that do not have a bus arbitrator in hardware design, how to achieve resource mutual exclusion between heterogeneous systems and improve the utilization rate of the bus by multiple heterogeneous systems on the server product is a problem that engineering and technical personnel need to solve.
[0031] In order to at least partially solve the above problems, in this embodiment, arbitration of shared resources is implemented based on a specified operating system, which is essentially a software implementation solution. No single-board hardware changes are required, and the priority algorithm is flexible and changeable. According to the scenario at run time, the appropriate priority algorithm is dynamically selected to improve the utilization efficiency of shared resources without additional overhead.
[0032] In this embodiment, the systems running on the multi-system device include a designated operating system and a plurality of first systems, and the target shared resource is a resource that is mutually exclusively accessed by the systems running on the multi-system device.
[0033] In order to request access rights to a target shared resource, the first system may send a resource access request for the target shared resource to a designated operating system. Correspondingly, the designated operating system may obtain resource access requests for one or more target shared resources of the first system.
[0034] It should be noted that the target shared resource is a resource that is mutually exclusively accessed by systems running on a multi-system device, that is, at most only one system can access the target shared resource at any one time.
[0035] The resource access request of the target shared resource is used to request the access permission of the target shared resource.
[0036] Combination Figure 4 , the connection relationship between multiple systems running on a multi-system device and shared resources can be as follows Figure 4 Optionally, in this embodiment, the system running on the multi-system device includes at least one of the following: an advanced reduced instruction set machine ARM system, a digital signal processing DSP system, a complex programmable logic device CPLD system, a field programmable gate array FPGA system, an X86 system, and a reduced instruction set fifth generation RISC-V system.
[0037] Step S204, when the target shared resource is in an idle state, based on a specified priority policy, the access rights to the target shared resource are allocated to the first target system with the highest priority among multiple first systems through a specified operating system, wherein the specified priority policy is used to limit the priority of the system running on the multi-system device.
[0038] The target shared resource can be in the following states: idle state, or occupied state. When the designated operating system determines that the target shared resource is in the idle state, the designated operating system allocates access rights to the target shared resource to the first target system with the highest priority among multiple first systems based on the designated priority policy.
[0039] Priority policies can be either static or dynamic. A static priority policy means that the priority of a task is set at the beginning and does not change during execution. A dynamic priority policy allows the priority of a task to be adjusted based on new information or changing conditions, which is not limited in this embodiment.
[0040] Optionally, in this embodiment, the designated priority policy may be a priority policy determined based on designated conditions. When different preset designated conditions are met, different designated priority policies may be matched accordingly.
[0041] The specified priority policy is used to limit the priority of the system running on the multi-system device. For example, the specified priority policy can limit the priorities to Linux priority 2, CPLD priority 1, and FPGA priority 3. The smaller the priority number, the higher the priority.
[0042] In this embodiment, the one who requests first is responded first. If multiple master devices (first system) send requests at the same time, they are responded to in order of priority based on the corresponding designated priority policy.
[0043] For example, system A can be a Linux system based on ARM-A architecture, system B can be a Windows system based on x86 architecture, and peripheral bus C can be an I2C bus, such as Figure 5 In the flowchart of multiple systems accessing shared resources, system A (Linux system) applies to the specified operating system for access rights to peripheral C (I2C bus). The specified operating system queries the status of peripheral C and finds that peripheral C is idle, so system A successfully applies for permission to use peripheral C. Subsequently, system A continues to interact with peripheral C through reading and writing.
[0044] Step S206: Send a first notification message to other first systems among the multiple first systems except the first target system through a designated operating system, wherein the first notification message is used to notify other first systems that requests for access rights to the target shared resource have failed.
[0045] When multiple first systems send resource access requests for a target shared resource to a designated operating system, a first notification message is sent to other first systems except the first target system among the multiple first systems through the designated operating system, wherein the first notification message is used to notify other first systems that requests for access rights to the target shared resource have failed.
[0046] Through the above steps, resource access requests for target shared resources of multiple first systems are obtained through the designated operating system, wherein the system running on the multi-system device includes the designated operating system and multiple first systems, the target shared resource is a resource mutually exclusively accessed by the systems running on the multi-system device, and the resource access request for the target shared resource is used to request access rights to the target shared resource; when the target shared resource is in an idle state, based on the designated priority policy, the access rights to the target shared resource are allocated to the first target system with the highest priority among the multiple first systems through the designated operating system, wherein the designated priority policy is used to limit the priority of the system running on the multi-system device; a first notification message is sent to other first systems except the first target system among the multiple first systems through the designated operating system, wherein the first notification message is used to notify other first systems that their requests for access rights to the target shared resource have failed, thereby solving the problem of low flexibility of access control due to the use of hardware circuits for access control in the access control method for shared resources in the related art.
[0047] In an exemplary embodiment, after obtaining resource access requests of target shared resources of multiple first systems by specifying an operating system, the method further includes:
[0048] S11, reading a register value of a status register of a target shared resource, wherein the status register of the target shared resource includes a specified status flag bit, and the specified status flag bit is used to identify whether the target shared resource is being occupied;
[0049] S12, determining the current running state of the target shared resource based on the value of a specified state flag bit in the register value of the state register of the target shared resource.
[0050] The designated operating system queries the state of the target shared resource by actively reading a state register of the target shared resource through the designated operating system to check its running state.
[0051] For example, the target shared resource is an I2C (Inter-Integrated Circuit) bus, and the specified status flag is a busy flag. I2C is a bidirectional two-wire bus used to connect a microcontroller and its peripherals. In the hardware that implements the I2C protocol, one or more status registers are usually included to indicate the current state of the I2C bus, error conditions, and control the operation of the I2C interface.
[0052] The I2C status register usually contains the following information: Busy Flag: Indicates whether the I2C interface is processing a transmission. If this flag is set, it means that the bus is busy and a new transmission cannot be started.
[0053] Through this embodiment, after reading the value of the status register of the shared resource, each status flag can be parsed according to the bit definition of the register, thereby determining the current running status of the shared resource.
[0054] In an exemplary embodiment, after sending the first notification message to other first systems except the first target system in the plurality of first systems by specifying the operating system, the method further includes:
[0055] S21, receiving a first interrupt signal triggered by a target shared resource through a designated operating system, wherein the first interrupt signal is used to indicate that the target shared resource is in an idle state;
[0056] S22, based on the specified priority policy, allocates access rights to the target shared resource to the second target system with the highest priority among multiple second systems through the specified operating system, wherein the multiple second systems include: other first systems; and a system that sends a resource access request for the target shared resource to the specified operating system after sending the first notification message.
[0057] Optionally, in this embodiment, when the target shared resource is in an idle state, an interrupt signal can be triggered to the specified operating system, based on which the specified operating system can monitor in real time whether the system currently occupying the target shared resource (for example, the first target system) has finished using the target shared resource.
[0058] Optionally, after sending the first notification message, there may be a new system that sends a resource access request for the target shared resource to the specified operating system. At this time, based on the specified priority policy, the access rights to the target shared resource can be allocated to the second target system with the highest priority among multiple second systems through the specified operating system.
[0059] The plurality of second systems include: other first systems; and a system that sends a resource access request for a target shared resource to a designated operating system after sending the first notification message.
[0060] Optionally, the designated priority policy for assigning access rights to the target shared resource to the second target system with the highest priority among the multiple second systems may be different from the designated priority policy for assigning access rights to the target shared resource to the first target system with the highest priority among the multiple first systems.
[0061] For example, at a first moment, a first notification message is sent to other first systems except the first target system among multiple first systems through a designated operating system. At a second moment after the first moment, a first interrupt signal triggered by the target shared resource is received. If between the first moment and the second moment, there are other systems except the multiple first systems on the multi-system device that send a resource access request to the designated operating system to request access rights to the target shared resource, when the first target system finishes using the target shared resource, the access rights to the target shared resource are allocated to other first systems based on the current designated priority policy, and after sending the first notification message, the second target system with the highest priority among the systems that sends a resource access request for the target shared resource to the designated operating system.
[0062] Through this embodiment, when the target shared resource is in an idle state, based on the specified priority policy at the corresponding moment, the access rights to the target shared resource are allocated to the system with the highest priority among the systems that have requested access rights to the target shared resource and have not yet obtained access rights to the target shared resource, thereby achieving mutually exclusive access to shared resources by multiple systems.
[0063] In an exemplary embodiment, based on a specified priority policy, the access rights of the target shared resource are allocated to the second target system with the highest priority among the plurality of second systems by specifying an operating system, including:
[0064] S31, based on the specified priority strategy, determine the second system with the highest priority among the multiple second systems by specifying the operating system, and obtain the second target system;
[0065] S32: Send a second interrupt signal to the second target system through the designated operating system, wherein the second interrupt signal is used to notify the second target system that the request for access rights to the target shared resource is successful.
[0066] Optionally, in this embodiment, the designated operating system can notify the system that has suspended the resource access request for the target shared resource that the request for access rights to the target shared resource is successful based on the interrupt signal. The system that has suspended the resource access request for the target shared resource can be a system that has requested access rights to the target shared resource, but the target shared resource was occupied when the target shared resource access rights were requested.
[0067] For example, in this embodiment, system A can be a Linux system running based on the ARM-A architecture, system B can be a Windows system based on the x86 architecture, and the shared resource peripheral bus C can be an I2C bus. When the designated operating system detects that system A has finished using peripheral C, the designated operating system can notify system B through an interrupt that the application for peripheral C is successful. From then on, system B can interact with peripheral C normally.
[0068] Through this embodiment, the multi-system device can achieve communication and cooperation between different processors or computing units through interrupt signals.
[0069] In an exemplary embodiment, before sending the second interrupt signal to the second target system by specifying the operating system, the method further includes:
[0070] S41, sending a resource access request for a target shared resource to a designated operating system through a second target system;
[0071] S42, when receiving a notification message returned by the designated operating system for notifying the second target system that the request for access rights to the target shared resource has failed, suspending the resource access request to the target shared resource through the second target system;
[0072] After sending the second interrupt signal to the second target system through the designated operating system, the method further includes:
[0073] S43, in response to the received second interrupt signal, access the target shared resource through the second target system to use the target shared resource.
[0074] Similar to the aforementioned embodiment, the system (eg, the second target system) sends a resource access request for a target shared resource to a designated operating system. When the designated operating system determines that the target shared resource is occupied, it may send a notification message to the system indicating that the request for access rights to the target shared resource has failed.
[0075] When receiving a notification message returned by a designated operating system and used to notify that the access permission to the target shared resource has failed, the system may suspend the resource access request to the target shared resource.
[0076] When the target shared resource resumes an idle state, the target shared resource can send an interrupt signal to the specified operating system to indicate that the target shared resource is in an idle state. Based on this, when it is determined that the second target system has the highest priority based on the current specified priority policy, the specified operating system can send an interrupt signal to the second target system to indicate that the second target system has successfully requested access rights to the target shared resource.
[0077] The second target system may access the target shared resource in response to the received interrupt signal.
[0078] For example, in this embodiment, system B (Windows system) also needs to access peripheral C. System B applies to the designated operating system for access rights to peripheral C. The designated operating system queries the status of peripheral C and finds that peripheral C is still occupied by system A, so the designated operating system returns a failure to system B. At this time, system B can suspend the application and run other tasks. When the designated operating system detects that system A has finished using peripheral C, the designated operating system notifies system B through an interrupt that the application for peripheral C is successful. From then on, system B can interact with peripheral C normally.
[0079] Through this embodiment, when a shared resource is occupied, a resource access request for the shared resource can be suspended, so as to improve access efficiency when the access permission of the target shared resource is successfully requested.
[0080] In an exemplary embodiment, after obtaining resource access requests of target shared resources of multiple first systems by specifying an operating system, the method further includes:
[0081] S51, when the target shared resource is in an occupied state, sending a second notification message to all first systems in the multiple first systems through a designated operating system, wherein the second notification is used to notify all first systems in the multiple first systems that requests for access rights to the target shared resource have failed.
[0082] Similar to the above embodiment, when the target shared resource is in an occupied state, the designated operating system may send a notification message of failure to obtain access rights to the target shared resource to all systems requesting access rights to the target shared resource.
[0083] In an exemplary embodiment, after sending the second notification message to all first systems among the plurality of first systems by specifying the operating system, the method further includes:
[0084] S61, receiving a third interrupt signal triggered by a target shared resource through a designated operating system, wherein the third interrupt signal is used to indicate that the target shared resource is in an idle state;
[0085] S62, based on the specified priority policy, allocates access rights to the target shared resource to a third target system with the highest priority among multiple third systems through a specified operating system, wherein the multiple third systems include: multiple first systems, and a system that sends a resource access request for the target shared resource to the specified operating system after sending the second notification message.
[0086] Similar to the aforementioned embodiment, based on the interrupt signal triggered by the target shared resource to the designated operating system, when the target shared resource in the occupied state resumes the idle state, the designated operating system can, based on the current designated priority policy, allocate the access rights of the target shared resource to the third target system with the highest priority among multiple third systems through the designated operating system. Here, the multiple third systems include: multiple first systems, and a system that sends a resource access request for the target shared resource to the designated operating system after sending the second notification message. The third system can be similar to the second system in the aforementioned embodiment and will not be elaborated here.
[0087] In an exemplary embodiment, based on a specified priority policy, the access rights of the target shared resource are allocated to a third target system with the highest priority among multiple third systems by specifying an operating system, including:
[0088] S71, based on the specified priority policy, determine the third system with the highest priority among the multiple third systems by specifying the operating system, and obtain a third target system;
[0089] S72: Send a fourth interrupt signal to the third target system through the designated operating system, wherein the fourth interrupt signal is used to notify the third target system that the request for access rights to the target shared resource is successful.
[0090] Similar to the aforementioned embodiment, the designated operating system may notify the system with the highest priority in a group of systems that have suspended the resource access request for the target shared resource through an interrupt signal that the system has successfully requested the access right to the target shared resource.
[0091] In an exemplary embodiment, before allocating the access rights of the target shared resource to the first target system with the highest priority among the multiple first systems by specifying the operating system based on the specified priority policy, the method further includes:
[0092] S81, determining the default priority policy corresponding to the resource type of the target shared resource recorded in the priority configuration table as the designated priority policy, wherein the priority configuration table is used to record the correspondence between the resource type of the shared resource and the default priority policy.
[0093] Common priority algorithms (priority strategies) include fixed priority, dynamic priority, short job priority, etc. Each single priority algorithm has its own advantages and disadvantages.
[0094] Fixed priority means that the priority of each heterogeneous system is fixed and unchanged. When multiple systems request the bus at the same time, the RTOS assigns the bus to the system with the highest priority. The advantage of this algorithm is that the system with the highest priority can get a response in a timely and fast manner. However, the disadvantage is that when the master device with the highest priority keeps occupying the bus resources, the master device with the lowest priority cannot get a response.
[0095] Round-robin priority means that the priority of each heterogeneous system changes with the access request process, and changes according to the law of rotation. As the current system ends its access to the bus, its priority becomes the lowest, and the priority of the subsequent system requesting the bus becomes the highest. This algorithm focuses on ensuring fairness, but when a system needs to make multiple access requests to the bus, the access delay will increase due to the reduction in priority, reducing the real-time performance of the system.
[0096] Short job priority means that the RTOS will count the time each heterogeneous system occupies the bus within a period of time. For each subsequent request, the RTOS will give priority to allocating the bus to the system with the shortest occupancy time. The advantage of this algorithm is the pursuit of the shortest average waiting time and the shortest average turnaround time; the disadvantage is that it is unfair and very unfavorable to long jobs, which may not be executed for a long time.
[0097] In this embodiment, a default priority algorithm may be configured according to the characteristics of shared resources, an initial priority of each system (applicant) may be configured according to a usage scenario, and a core parameter index of each shared resource may be configured according to performance requirements.
[0098] Take the I2C bus in the server field as an example. The I2C bus usually connects multiple sensor devices, so it is necessary to respond to applicant requests as quickly as possible, and the bus occupancy rate is not very concerned. Therefore, a fixed priority scheme is used for the I2C bus. As shown in Table 1, the initial priorities of each applicant are Linux priority 2, CPLD priority 1, and FPGA priority 3. The smaller the priority number, the higher the priority.
[0099] Table 1 Priority algorithm configuration table
[0100]
[0101] Through this embodiment, the preset default priority policy is configured based on the type of shared resources, so that the utilization rate of shared resources can be improved.
[0102] In an exemplary embodiment, after determining the default priority policy corresponding to the resource type of the target shared resource recorded in the priority configuration table as the specified priority policy, the method further includes:
[0103] S91, obtaining a parameter value of a designated resource parameter corresponding to each fourth system among a plurality of fourth systems, wherein the plurality of fourth systems are systems running on a multi-system device and waiting to access a target shared resource, and the designated resource parameter is used to describe a process in which the systems running on the multi-system device wait to access the target shared resource;
[0104] S92, when the policy switching condition is met, perform at least one policy switching operation on the specified priority policy until the policy switching condition is not met, wherein the policy switching operation is used to switch the specified priority policy to a set of priority policies other than a default priority policy corresponding to the resource type of the target shared resource, and the policy switching condition includes: among the systems waiting to access the target shared resource, there exists a system in which the parameter value of the corresponding specified resource parameter is greater than or equal to the specified parameter threshold.
[0105] This embodiment proposes a method of dynamically selecting a priority algorithm based on the statistical data of the current multi-system device system during operation and the characteristics of shared resources, making full use of the advantages of each priority algorithm to achieve the effect of leveraging strengths and avoiding weaknesses, thereby improving the overall operating efficiency of the system.
[0106] The priority algorithm flow chart is as follows Figure 6 As shown, similar to the aforementioned embodiment, in the initial stage, a default priority algorithm is configured according to the characteristics of the shared resources, an initial priority of each applicant is configured according to the usage scenario, and a core indicator of each shared resource is configured according to the performance requirements. After the entire system is running, the designated operating system can collect statistical information of each applicant (system) on each system resource. When the statistical information does not meet the set core parameters, the designated operating system can change the priority algorithm (i.e., specify the priority strategy), and the system continues to run. If the designated operating system finds that the core parameter indicators are improving through statistics, it continues to run normally. If the core parameter indicators deteriorate (for example, the parameter value of the designated resource parameter is greater than or equal to the designated parameter threshold), the designated operating system will adjust the priority of the applicant and continue to run. If the core parameters subsequently counted have improved, it will continue to run. If the indicators continue to deteriorate, the priority algorithm will be modified again, and the previous steps will be repeated until the indicators gradually improve and the adjustment ends.
[0107] For example, in this embodiment, the specific process is described by taking the I2C bus in the server field as an example. The I2C bus usually connects multiple sensor devices, so it is necessary to respond to the applicant's request as soon as possible, and the bus occupancy rate is not paid much attention to. Therefore, a fixed priority scheme is selected for the I2C bus, and the initial priority of each applicant is Linux priority 2, CPLD priority 1, and FPGA priority 3, respectively, wherein the smaller the priority number, the higher the priority. During the system operation, the designated operating system will count the average waiting time of each applicant. When the average waiting time of an applicant exceeds the set threshold, the designated operating system can switch the priority algorithm to the circular priority algorithm to ensure the relative fairness of each applicant and obtain the right to use the bus. After a period of operation, the designated operating system counts the waiting time index and determines whether the waiting time index is developing in a good direction or continuing to deteriorate. If the average waiting time continues to deteriorate, the designated operating system will adjust the task priority to improve the average waiting time of the applicant so that it can obtain the right to use the bus faster.
[0108] Here, adjusting the task priority may refer to adjusting the priority of the applicant. When the priority is increased, the specified operating system will preferentially assign peripheral access rights to the applicant.
[0109] In an exemplary embodiment, the designated operating system runs on a coprocessor of a multi-core processor of a multi-system device, and the designated operating system is a real-time operating system; the target shared resources include at least one of the following: an integrated circuit bus, a serial peripheral interface bus, and a universal serial bus.
[0110] A coprocessor is a processor that is specifically designed to assist the central processing unit (CPU) in performing specific tasks.
[0111] RTOS (Real Time Operating System) refers to an operating system that can accept and process external events or data at a sufficiently fast speed, and its processing results can control the production process or respond quickly to the processing system within a specified time, dispatch all available resources to complete real-time tasks, and control all real-time tasks to run in a coordinated manner. Providing timely response and high reliability are its main features;
[0112] RTOS is an operating system designed specifically for real-time computing. It must be able to ensure that specific tasks are processed within a specific time limit, which places strict requirements on the system's response time. The core features of the RTOS system include:
[0113] Real-time: The key characteristic of an RTOS is real-time, which means the system is able to respond to external events within a given time limit. This is usually divided into hard real-time and soft real-time systems.
[0114] Hard real-time: The task must be completed within the specified time, otherwise there will be serious consequences.
[0115] Soft real-time: Although there are time limits, occasional timeouts will not cause serious consequences.
[0116] Determinism: RTOS provides deterministic operation, and the execution time of tasks and system response time are predictable.
[0117] Task Scheduling: RTOS usually uses a priority-based preemptive scheduling algorithm to ensure that high-priority tasks can be executed in a timely manner.
[0118] The key components of an RTOS system include:
[0119] Task Manager: Responsible for creating, deleting, suspending, resuming tasks, and scheduling tasks.
[0120] Interrupt Management: Quickly respond to external events and handle them through Interrupt Service Routines (ISRs).
[0121] Clock management: Provides precise time management for task timing and scheduling.
[0122] Memory management: usually includes memory allocation and deallocation, as well as possible memory protection mechanisms.
[0123] Communication mechanism: including message queues, semaphores, event groups, mutexes, etc., used for synchronization and communication between tasks.
[0124] I2C (Inter-Integrated Circuit) bus is a serial communication protocol used to connect microcontrollers (MCU) and other low-speed devices such as sensors, memory, etc. I2C: IIC (Inter-Integrated Circuit) is actually the abbreviation of IICBus, so it is called integrated circuit bus in Chinese. It is a serial communication bus that uses a multi-master-slave architecture. It was developed by Philips in the 1980s to allow motherboards, embedded systems or mobile phones to connect low-speed peripheral devices.
[0125] SPI (Serial Peripheral Interface) bus is a high-speed synchronous serial communication protocol used to connect microcontrollers and other high-speed devices such as ADC, DAC, flash memory, etc. SPI: Serial Peripheral Interface, Serial Peripheral Interface is a high-speed, full-duplex, synchronous communication bus. It is a full-duplex synchronous serial bus developed by Motorola. It is a synchronous serial port for communication between microprocessor control units (MCUs) and peripheral devices. It is mainly used in EEPROM, Flash, real-time clock (RTC), digital-to-analog converter (ADC), network controller, MCU, digital signal processor (DSP) and digital signal decoder.
[0126] USB (Universal Serial Bus) is a universal serial communication standard used to connect computers and peripheral devices such as keyboards, mice, printers, external storage devices, etc.
[0127] UART: Universal Asynchronous Receiver / Transmitter, a universal asynchronous receiver / transmitter is a universal serial data bus used for asynchronous communication. The bus communicates bidirectionally and can achieve full-duplex transmission and reception. In embedded design, UART is used to communicate with the PC, including monitoring debuggers and other devices such as EEPROM.
[0128] As an optional exemplary embodiment of the present application, taking the specified operating system as an RTOS system as an example, the access control method for shared resources in the embodiment of the present application is explained.
[0129] In this embodiment, a method for time-sharing shared resources of heterogeneous systems is proposed. This method can solve the problem of mutually exclusive access to shared resources by heterogeneous systems without modifying the hardware of a single board.
[0130] By using the coprocessor in the multi-core processor (a heterogeneous system generally has multiple processor cores, divided into large and small cores, and the coprocessor here is the small core) to run the RTOS system, the RTOS can realize the bus arbitration function. Taking advantage of the rapid startup of the RTOS, it can work normally and perform bus arbitration in a very short time after the server is powered on.
[0131] RTOS can respond to external events within a strictly defined time to ensure real-time execution of tasks. RTOS provides an efficient interrupt management mechanism that allows interrupt service routines to execute and resume quickly, while supporting task switching or resource notifications in interrupts. This mechanism ensures that the system remains efficient and responsive even under high interrupt loads. RTOS implements bus arbitration functions in terms of response time and interrupt management, which can achieve more efficient results.
[0132] RTOS responds to interrupts very quickly, which makes bus arbitration more efficient. Therefore, using RTOS for bus arbitration can achieve performance comparable to that of hardware while retaining the flexibility of the arbitration algorithm. It does not require hardware changes and can be used on existing server products.
[0133] This application proposes to use the coprocessor in the multi-core processor to run the RTOS system, and take advantage of the characteristics of the RTOS system that it starts quickly and responds to interrupts in a timely manner, so that the RTOS can realize the bus arbitration function without hardware modification.
[0134] In the server system, bus resources can be regarded as shared resources, and the requests of multiple heterogeneous systems for the bus can be regarded as competition for resources. RTOS is a management agency that monitors the requests issued by each master device and responds to the corresponding system according to the arbitration algorithm it sets. All arbitration mechanisms should also meet the following requirements: at most one system can access the bus at any time; each access cannot be interrupted; the first requester responds first. If multiple master devices issue requests at the same time, they will respond in order of priority; the algorithm should be relatively fair to ensure that each master device has the same probability of accessing the bus.
[0135] In this embodiment, the system includes but is not limited to an ARM system, a DSP system, a CPLD system, an FPGA system, an X86 system, a RISC-V system, etc. The peripherals include but are not limited to an I2C bus, an SPI bus, and a USB bus.
[0136] For example, system A may be a Linux system based on the ARM-A architecture, system B may be a Windows system based on the x86 architecture, and peripheral bus C may be an I2C bus.
[0137] The flowchart of heterogeneous systems accessing shared resources can be as follows: Figure 5As shown. At the beginning, system A (Linux system) applied for access rights to peripheral C (I2C bus) from the RTOS system. The RTOS system queried the status of peripheral C and found that peripheral C was in an idle state, so system A successfully applied for access rights to peripheral C. Subsequently, system A continued to interact with peripheral C through reading and writing. Then, system B (Windows system) also needed to access peripheral C. System B applied for access rights to peripheral C from the RTOS system. The RTOS system queried the status of peripheral C and found that peripheral C was still occupied by system A, so the RTOS system returned a failure to system B. At this time, system B can suspend the application and run other tasks. When the RTOS system detects that system A has finished using peripheral C, the RTOS system notifies system B through an interrupt that the application for peripheral C is successful. From then on, system B can interact with peripheral C normally.
[0138] Considering that each single bus arbitration priority algorithm has its own advantages and disadvantages. This application utilizes the flexibility of the RTOS system and proposes a method of dynamically selecting a priority algorithm based on the statistical data of the current multi-system devices (such as servers) during operation and the characteristics of shared resources (such as peripheral buses), making full use of the advantages of each priority algorithm to achieve the effect of leveraging strengths and avoiding weaknesses, thereby improving the overall operating efficiency of the system.
[0139] It should be noted that the present application proposes a technical method for realizing bus arbitration function based on RTOS system, wherein the objects for arbitration are not limited to heterogeneous systems, but can also be other types of devices, and are also applicable to multiple systems of the same architecture. The shared resources for arbitration in the present application include but are not limited to peripherals, and can be all devices that need to solve the problem of shared mutual exclusion.
[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0141] According to another aspect of the embodiment of the present application, there is also provided a device for controlling access to shared resources, which is used to implement the method for controlling access to shared resources provided in the above-mentioned embodiment, and will not be described in detail herein. As used below, the term "module" may be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and contemplated.
[0142] Figure 7 is a structural block diagram of an optional shared resource access control device provided in an embodiment of the present application, which is applied to multi-system devices; Figure 7 As shown, the device comprises:
[0143] A first acquisition unit 702 is configured to acquire resource access requests of target shared resources of multiple first systems through a specified operating system, wherein the system running on the multi-system device includes the specified operating system and the multiple first systems, the target shared resource is a resource mutually exclusively accessed by the systems running on the multi-system device, and the resource access request of the target shared resource is used to request access rights to the target shared resource;
[0144] A first allocation unit 704 is configured to allocate access rights of the target shared resource to a first target system with the highest priority among the multiple first systems based on a specified priority policy and through a specified operating system when the target shared resource is in an idle state, wherein the specified priority policy is used to limit the priority of the system running on the multi-system device;
[0145] The first sending unit 706 is configured to send a first notification message to other first systems except the first target system among the multiple first systems through a designated operating system, wherein the first notification message is used to notify other first systems that a request for access rights to a target shared resource fails.
[0146] It should be noted that the first acquisition unit 702 in this embodiment can be used to execute the above step S202, the first allocation unit 704 in this embodiment can be used to execute the above step S204, and the first sending unit 706 in this embodiment can be used to execute the above step S206.
[0147] Through the embodiments of the present application, resource access requests for target shared resources of multiple first systems are obtained through a designated operating system, wherein the system running on the multi-system device includes a designated operating system and multiple first systems, the target shared resource is a resource mutually exclusively accessed by the systems running on the multi-system device, and the resource access request for the target shared resource is used to request access rights to the target shared resource; when the target shared resource is in an idle state, based on a designated priority policy, access rights to the target shared resource are allocated to a first target system with the highest priority among multiple first systems through a designated operating system, wherein the designated priority policy is used to limit the priority of the system running on the multi-system device; a first notification message is sent to other first systems except the first target system among the multiple first systems through a designated operating system, wherein the first notification message is used to notify other first systems that their requests for access rights to the target shared resource have failed, thereby solving the problem of low flexibility of access control due to the use of hardware circuits for access control in the access control method for shared resources in the related art.
[0148] In an exemplary embodiment, the above device further comprises:
[0149] a reading unit, configured to read a register value of a status register of a target shared resource after obtaining resource access requests of a plurality of target shared resources of the first system through a designated operating system, wherein the status register of the target shared resource includes a designated status flag bit, and the designated status flag bit is used to identify whether the target shared resource is being occupied;
[0150] The first determining unit is configured to determine the current running state of the target shared resource based on the value of a specified state flag bit in the register value of the state register of the target shared resource.
[0151] In an exemplary embodiment, the above device further comprises:
[0152] A first receiving unit is configured to receive a first interrupt signal triggered by a target shared resource through the designated operating system after sending a first notification message to other first systems except the first target system among the plurality of first systems through the designated operating system, wherein the first interrupt signal is used to indicate that the target shared resource is in an idle state;
[0153] A second allocation unit is used to allocate access rights of the target shared resource to a second target system with the highest priority among multiple second systems through a specified operating system based on a specified priority policy, wherein the multiple second systems include: other first systems; and a system that sends a resource access request for the target shared resource to the specified operating system after sending the first notification message.
[0154] In an exemplary embodiment, the second allocation unit comprises:
[0155] A first determination module is used to determine the second system with the highest priority among the plurality of second systems through the specified operating system based on the specified priority policy, and obtain the second target system;
[0156] The first sending module is used to send a second interrupt signal to the second target system through a specified operating system, wherein the second interrupt signal is used to notify the second target system that the request for access rights to the target shared resource is successful.
[0157] In an exemplary embodiment, the above device further comprises:
[0158] A second sending unit, configured to send a resource access request for a target shared resource to the designated operating system through the second target system before sending a second interrupt signal to the second target system through the designated operating system;
[0159] a suspending unit, configured to suspend the resource access request of the target shared resource through the second target system when receiving a notification message returned by the designated operating system for notifying the second target system that the request for the access right to the target shared resource has failed;
[0160] The above device also includes:
[0161] The access unit is used for accessing the target shared resource through the second target system in response to the received second interrupt signal after sending the second interrupt signal to the second target system through the designated operating system, so as to use the target shared resource.
[0162] In an exemplary embodiment, the above device further comprises:
[0163] A third sending unit is used for, after obtaining resource access requests of target shared resources of multiple first systems through a designated operating system, sending a second notification message to all first systems in the multiple first systems through the designated operating system when the target shared resources are in an occupied state, wherein the second notification is used to notify all first systems in the multiple first systems that requests for access rights to the target shared resources have failed.
[0164] In an exemplary embodiment, the above device further comprises:
[0165] A second receiving unit is configured to receive a third interrupt signal triggered by a target shared resource through the designated operating system after sending a second notification message to all first systems among the plurality of first systems through the designated operating system, wherein the third interrupt signal is used to indicate that the target shared resource is in an idle state;
[0166] A third allocation unit is used to allocate access rights of the target shared resource to a third target system with the highest priority among multiple third systems through a designated operating system based on a designated priority policy, wherein the multiple third systems include: multiple first systems, and a system that sends a resource access request for the target shared resource to the designated operating system after sending the second notification message.
[0167] In an exemplary embodiment, the third allocation unit includes:
[0168] A second determination module is used to determine, based on a specified priority policy, a third system with the highest priority among the plurality of third systems by specifying an operating system, and obtain a third target system;
[0169] The second sending module is used to send a fourth interrupt signal to the third target system through a designated operating system, wherein the fourth interrupt signal is used to notify the third target system that the request for access rights to the target shared resource is successful.
[0170] In an exemplary embodiment, the above device further comprises:
[0171] The second determination unit is used to determine the default priority policy recorded in the priority configuration table and corresponding to the resource type of the target shared resource as the designated priority policy before allocating the access rights of the target shared resource to the first target system with the highest priority among multiple first systems through the designated operating system based on the designated priority policy, wherein the priority configuration table is used to record the correspondence between the resource type of the shared resource and the default priority policy.
[0172] In an exemplary embodiment, the above device further comprises:
[0173] A second acquisition unit is used to acquire a parameter value of a designated resource parameter corresponding to each fourth system of a plurality of fourth systems after determining the default priority policy recorded in the priority configuration table and corresponding to the resource type of the target shared resource as the designated priority policy, wherein the plurality of fourth systems are systems running on the multi-system device and waiting to access the target shared resource, and the designated resource parameter is used to describe a process in which the systems running on the multi-system device are waiting to access the target shared resource;
[0174] An execution unit is used to perform at least one policy switching operation on a specified priority policy when a policy switching condition is met, until the policy switching condition is not met, wherein the policy switching operation is used to switch the specified priority policy to a group of priority policies other than a default priority policy corresponding to the resource type of a target shared resource, and the policy switching condition includes: among the systems waiting to access the target shared resource, there is a system whose parameter value of the corresponding specified resource parameter is greater than or equal to a specified parameter threshold.
[0175] In an exemplary embodiment, the designated operating system runs on a coprocessor of a multi-core processor of a multi-system device, and the designated operating system is a real-time operating system; the target shared resources include at least one of the following: an integrated circuit bus, a serial peripheral interface bus, and a universal serial bus.
[0176] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0177] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0178] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a ROM (Read-Only Memory), a RAM (Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk.
[0179] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0180] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0181] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0182] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0183] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0184] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in any one of the above method embodiments.
[0185] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0186] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for controlling access to shared resources, applied to multi-system devices, characterized in that: include: Obtaining resource access requests of target shared resources of multiple first systems through a designated operating system, wherein the systems running on the multi-system device include the designated operating system and the multiple first systems, the target shared resource is a resource that is mutually exclusively accessed by the systems running on the multi-system device, and the resource access request of the target shared resource is used to request access rights to the target shared resource; When the target shared resource is in an idle state, based on a specified priority policy, the specified operating system allocates access rights to the target shared resource to a first target system with the highest priority among the multiple first systems, wherein the specified priority policy is used to define the priority of the system running on the multi-system device; Sending a first notification message to other first systems among the multiple first systems except the first target system through the designated operating system, wherein the first notification message is used to notify the other first systems that a request for access permission to the target shared resource fails; Before allocating the access rights of the target shared resource to the first target system with the highest priority among the multiple first systems through the designated operating system based on the designated priority policy, the method further comprises: determining the default priority policy corresponding to the resource type of the target shared resource recorded in the priority configuration table as the designated priority policy, wherein the priority configuration table is used to record the correspondence between the resource type of the shared resource and the default priority policy; Wherein, after determining the default priority policy recorded in the priority configuration table and corresponding to the resource type of the target shared resource as the designated priority policy, the method further includes: obtaining the parameter value of the designated resource parameter corresponding to each fourth system among a plurality of fourth systems, wherein the plurality of fourth systems are systems running on the multi-system device and waiting to access the target shared resource, and the designated resource parameter is used to describe the process of the system running on the multi-system device waiting to access the target shared resource; when a policy switching condition is met, performing at least one policy switching operation on the designated priority policy until the policy switching condition is not met, wherein the policy switching operation is used to switch the designated priority policy to other priority policies in a group of priority policies except the default priority policy corresponding to the resource type of the target shared resource, and the policy switching condition includes: among the systems waiting to access the target shared resource, there is a system whose corresponding parameter value of the designated resource parameter is greater than or equal to a designated parameter threshold.
2. The method according to claim 1, characterized in that: After acquiring resource access requests of target shared resources of multiple first systems by specifying the operating system, the method further includes: Reading a register value of a status register of the target shared resource, wherein the status register of the target shared resource includes a specified status flag bit, and the specified status flag bit is used to identify whether the target shared resource is being occupied; The current running state of the target shared resource is determined based on the value of the specified state flag bit in the register value of the state register of the target shared resource.
3. The method according to claim 1, characterized in that: After sending the first notification message to other first systems of the plurality of first systems except the first target system through the designated operating system, the method further includes: Receiving, through the designated operating system, a first interrupt signal triggered by the target shared resource, wherein the first interrupt signal is used to indicate that the target shared resource is in an idle state; Based on the specified priority policy, the access rights of the target shared resource are allocated to the second target system with the highest priority among multiple second systems through the specified operating system, wherein the multiple second systems include: the other first systems, and the system that sends a resource access request for the target shared resource to the specified operating system after sending the first notification message.
4. The method according to claim 3, characterized in that The allocating the access rights of the target shared resource to the second target system with the highest priority among the plurality of second systems through the designated operating system based on the designated priority policy comprises: Based on the specified priority policy, determining, through the specified operating system, a second system with the highest priority among the multiple second systems, to obtain the second target system; A second interrupt signal is sent to the second target system through the designated operating system, wherein the second interrupt signal is used to notify the second target system that a request for access rights to the target shared resource is successful.
5. The method according to claim 3, characterized in that: Before sending the second interrupt signal to the second target system through the designated operating system, the method further includes: sending a resource access request for the target shared resource to the designated operating system through the second target system; upon receiving a notification message returned by the designated operating system for notifying the second target system that the request for access rights to the target shared resource has failed, suspending the resource access request for the target shared resource through the second target system; After sending the second interrupt signal to the second target system through the designated operating system, the method further includes: in response to the received second interrupt signal, accessing the target shared resource through the second target system to use the target shared resource.
6. The method according to claim 1, characterized in that After acquiring resource access requests of target shared resources of multiple first systems by specifying the operating system, the method further includes: When the target shared resource is in an occupied state, a second notification message is sent to all the first systems in the multiple first systems through the designated operating system, wherein the second notification is used to notify all the first systems in the multiple first systems that requests for access rights to the target shared resource have failed.
7. The method according to claim 6, characterized in that After sending the second notification message to all the first systems of the plurality of first systems through the designated operating system, the method further includes: Receiving, through the designated operating system, a third interrupt signal triggered by the target shared resource, wherein the third interrupt signal is used to indicate that the target shared resource is in an idle state; Based on the specified priority policy, access rights to the target shared resource are allocated to a third target system with the highest priority among multiple third systems through the specified operating system, wherein the multiple third systems include: the multiple first systems, and a system that sends a resource access request for the target shared resource to the specified operating system after sending the second notification message.
8. The method according to claim 7, characterized in that The allocating the access rights of the target shared resource to the third target system with the highest priority among the plurality of third systems through the designated operating system based on the designated priority policy comprises: Based on the designated priority policy, determining, through the designated operating system, a third system with the highest priority among the plurality of third systems, to obtain the third target system; A fourth interrupt signal is sent to the third target system through the designated operating system, wherein the fourth interrupt signal is used to notify the third target system that the request for access rights to the target shared resource is successful.
9. The method according to any one of claims 1 to 8, characterized in that The designated operating system runs on a coprocessor of a multi-core processor of the multi-system device, and the designated operating system is a real-time operating system; the target shared resources include at least one of the following: an integrated circuit bus, a serial peripheral interface bus, and a universal serial bus.
10. A shared resource access control device, applied to multi-system equipment, characterized in that: include: A first acquisition unit is configured to acquire resource access requests of target shared resources of multiple first systems through a specified operating system, wherein the systems running on the multi-system device include the specified operating system and the multiple first systems, the target shared resources are resources mutually exclusively accessed by the systems running on the multi-system device, and the resource access requests of the target shared resources are used to request access rights to the target shared resources; a first allocation unit, configured to allocate access rights of the target shared resource to a first target system with the highest priority among the multiple first systems based on a specified priority policy through the specified operating system when the target shared resource is in an idle state, wherein the specified priority policy is used to limit the priority of the system running on the multi-system device; A first sending unit, configured to send a first notification message to other first systems among the multiple first systems except the first target system through the designated operating system, wherein the first notification message is used to notify the other first systems that a request for access permission to the target shared resource fails; A second determining unit is used to determine the default priority policy recorded in the priority configuration table and corresponding to the resource type of the target shared resource as the designated priority policy before allocating the access rights of the target shared resource to the first target system with the highest priority among the multiple first systems through the designated operating system based on the designated priority policy, wherein the priority configuration table is used to record the correspondence between the resource type of the shared resource and the default priority policy; A second acquisition unit is used to obtain the parameter value of the designated resource parameter corresponding to each fourth system in a plurality of fourth systems after determining the default priority policy corresponding to the resource type of the target shared resource recorded in the priority configuration table as the designated priority policy, wherein the plurality of fourth systems are systems running on the multi-system device and waiting to access the target shared resource, and the designated resource parameter is used to describe the process of the system running on the multi-system device waiting to access the target shared resource; an execution unit is used to perform at least one policy switching operation on the designated priority policy when a policy switching condition is met until the policy switching condition is not met, wherein the policy switching operation is used to switch the designated priority policy to other priority policies in a group of priority policies except the default priority policy corresponding to the resource type of the target shared resource, and the policy switching condition includes: among the systems waiting to access the target shared resource, there is a system whose corresponding parameter value of the designated resource parameter is greater than or equal to a designated parameter threshold.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method according to any one of claims 1 to 9 when executed by a processor.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
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 method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
A shared resource scheduling method and system for distributed parallel processing
CN102298539A
Access method and device of hardware controller, storage medium and electronic equipment
CN116244229A