Access control method and device, equipment and medium

By introducing semaphore register sets and preset release management rules into the hardware semaphore, the access conflict problem when multiprocessors compete with multicores is solved, ensuring the correctness of unique access and request processing of peripherals.

CN119065845APending Publication Date: 2024-12-03SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411157554.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Traditional hardware semaphore solutions cannot solve the conflict problem between multi-processors and multi-cores when accessing peripheral competition, resulting in limited application scenarios.

Method used

By setting up a semaphore register group, including a semaphore request register, a semaphore release register and a semaphore interrupt clear register, recording the lock semaphore information, and processing lock requests according to preset release management rules, setting inter-process priority and process priority level, ensuring unique access and correct processing of semaphores.

Benefits of technology

Effectively solve the problem of multi-processors and multi-core competing for accessing peripherals, ensure that peripherals are uniquely accessed, and the lock requests of processors and processes are correctly processed, and avoid requests nested and lost subsequent requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065845A_ABST
    Figure CN119065845A_ABST
Patent Text Reader

Abstract

The invention discloses an access control method and device, equipment and a medium, and relates to the technical field of integrated circuits. The method comprises the following steps: setting a corresponding number of semaphore register groups for peripherals needing access management; determining a currently accessed target peripheral and acquiring a lock request initiated for the target peripheral; recording the information of locking the semaphore by using a semaphore register group; triggering a preset release management rule according to the information to sequentially process the lock request; the preset release management rule is used for setting a first priority among the processors, recording different processes of the processors by setting a request queue, and setting a second priority; and sequentially clearing interrupts according to the sequence of the first priority and / or the second priority by utilizing a semaphore interrupt clearing register. According to the technical scheme, the problem that a traditional hardware semaphore scheme cannot process when multiple processors and multiple cores access peripheral competition at the same time can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of integrated circuit technology, and in particular to an access control method, device, equipment and medium. Background Art

[0002] The current hardware semaphore (HWSEM) mechanism is often used to resolve access conflicts between multiple processors or multiple cores. However, some application scenarios may have both multi-processor and multi-core contention, such as when the system uses multiple processors and each processor is multi-core. Currently, there is a lack of solutions that can resolve both conflict issues at the same time through a single mechanism, which limits the application scenarios of hardware semaphores. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide an access control method, device, equipment and medium, which can solve the problem that traditional hardware semaphore solutions cannot handle when multiple processors and multiple cores compete for access to peripherals. The specific solution is as follows:

[0004] In a first aspect, the present application discloses an access control method, comprising:

[0005] A corresponding number of semaphore register groups are set for peripherals that need access management; wherein the semaphore register groups include a semaphore request register, a semaphore release register, and a semaphore interrupt clear register;

[0006] Determine the target peripheral device currently being accessed, and obtain a lock request initiated for the target peripheral device;

[0007] The semaphore register group is used to record information of a locked semaphore; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore recording position in the semaphore request register is in a locked state according to the lock request;

[0008] A preset release management rule is triggered according to the information of the locked semaphore so that the lock request is processed in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore is released by the semaphore release register, the semaphore interrupt clear register is used to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

[0009] Optionally, the semaphore request register includes the binary semaphore record bit, a flag bit used to indicate whether to use the process identifier, a processor identifier record bit, and a process identifier record bit; the information of the locked semaphore includes the first processor identifier, the first process identifier, and the locking state corresponding to the binary semaphore record bit;

[0010] After determining the target peripheral device currently being accessed and obtaining a lock request initiated for the target peripheral device, the method further includes:

[0011] Determining the initiation type of the lock request;

[0012] If the initiation type is a first initiation type that requires using a process identifier to initiate the lock request, a process identifier flag is written into the flag bit through the target bus, and the first process identifier is written into the process identifier record bit, and then the binary semaphore record bit is set from an idle state to the locked state, and the first processor identifier is written into the processor identifier record bit to obtain the locked semaphore;

[0013] If the initiation type is a second initiation type that does not require the use of a process identifier to initiate the lock request, a flag that does not use a process identifier is written to the flag bit through the target bus, and then the binary semaphore record bit is set from an idle state to the locked state, and the first processor identifier is written into the processor identifier record bit to obtain the locked semaphore.

[0014] Optionally, when the lock request is initiated for the target peripheral device through multiple processes in the current processor, the initiation type is determined to be the first initiation type; when the lock request is initiated for the target peripheral device through multiple processors, the initiation type is determined to be the second initiation type;

[0015] The preset release management rule is triggered according to the information of the locked semaphore, including:

[0016] Determine a target process or a target processor currently accessing the locked semaphore;

[0017] If the initiation type is the first initiation type, when the target process ends the current access, obtaining the second process identifier of the target process and the second processor identifier of the corresponding processor; when the second process identifier is consistent with the first process identifier, and the second processor identifier is consistent with the first processor identifier, using the semaphore release register to release the semaphore corresponding to the target process;

[0018] If the initiation type is the second initiation type, when the target processor ends the current access, the target processor writes a use process identification flag into the semaphore release register to release the semaphore corresponding to the target processor.

[0019] Optionally, triggering a preset release management rule according to the information of the locked semaphore includes:

[0020] Determine a currently corresponding first lock request according to the lock semaphore, and acquire a second lock request synchronously initiated for the target peripheral device based on the first lock request;

[0021] triggering a release interrupt according to the second lock request, and determining a corresponding release interrupt type;

[0022] If the release interrupt type is a processor release interrupt, the interrupt request signal is pulled high according to the second lock request, and when the first lock request is processed, the semaphore release signal is pulled high, and then an interrupt is issued to the processor whose request failed;

[0023] If the release interrupt type is a process release interrupt, after the first lock request is processed, interrupts are issued to the processes in the request queue in sequence according to the second priority order, and an interrupt is issued to the processor whose request failed when the request queue is empty.

[0024] Optionally, the issuing of interrupts to the processes in the request queue in sequence according to the order of the second priority includes:

[0025] Determine the first process in the request queue, and read out the first process identifier of the first process using a preset interrupt processing function;

[0026] An interrupt is sent to the first process according to the first process identifier. When the first process is processed, the interrupt of the first process is cleared and the first process is removed from the queue. The next process is then used as the first process, and the step of using a preset interrupt processing function to read out the first process identifier of the first process is triggered until the request queue is empty.

[0027] Optionally, triggering a preset release management rule according to the information of the locked semaphore includes:

[0028] Determine a current priority access mode; the priority access mode includes a priority fixed mode and a priority polling mode;

[0029] When the priority access mode is the priority fixed mode, processing the lock requests initiated by each processor based on the order of the first priority according to the information of the lock semaphore;

[0030] When the priority access mode is the priority polling mode, according to the information of the lock semaphore, the first processor is determined based on the order of the first priority and the target priority corresponding to the first processor is obtained; when the lock request initiated by the first processor is processed, the target priority is switched to the second processor, so that when the lock request is initiated again, the second processor is given priority according to the target priority.

[0031] Optionally, after setting a corresponding number of semaphore register groups for peripherals that require access management, the method further includes:

[0032] The semaphore register groups are respectively hung on the network interface controllers so as to access the semaphore register groups based on the arbitration function of the network interface controller.

[0033] In a second aspect, the present application discloses an access control device, comprising:

[0034] A register group setting module, used for setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register;

[0035] A lock request acquisition module, used to determine the target peripheral device currently being accessed, and acquire a lock request initiated for the target peripheral device;

[0036] An information recording module, used to record information of a locked semaphore using the semaphore register group; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore recording position in the semaphore request register is in a locked state according to the lock request;

[0037] A lock request processing module, used to trigger a preset release management rule according to the information of the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore release register releases the semaphore, the semaphore interrupt clear register is used to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

[0038] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the access control method as described above.

[0039] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program implements the access control method as described above when executed by a processor.

[0040] The present application provides an access control method, comprising: setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register; determining the target peripheral currently being accessed, and obtaining a lock request initiated for the target peripheral; using the semaphore register group to record information about a locked semaphore; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore record position in the semaphore request register is in a locked state according to the lock request; triggering a preset release management rule according to the information about the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore is released by the semaphore release register, using the semaphore interrupt clear register to clear interrupts in sequence according to the order of the first priority and / or the second priority.

[0041] The beneficial technical effects of the present application are as follows: by improving the traditional hardware semaphore method, a corresponding number of semaphore register groups are set for peripherals that need access management, which are used for software request and release management of hardware semaphores and interrupt control. The semaphore register group is used to record the information of the locked semaphore, and the corresponding preset release management rules are used to trigger the lock request. It is ensured that all multiple lock requests initiated by different processors and different processes of the same processor can be processed correctly; and it is ensured that when the semaphore is in a locked state, all lock requests initiated by different processors and different processes of the same processor can be fully recorded and not lost, and are notified in sequence through interrupts according to the set priority, so as to realize the sequential processing of all peripheral access requests, and subsequent requests will not be lost due to nested requests. In this way, the problem of multiple processors and multiple cores competing for access to peripherals is effectively solved, and the peripherals are guaranteed to be uniquely accessed.

[0042] In addition, the present application provides an access control device, equipment and storage medium, which correspond to the above-mentioned access control method and have the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0044] Figure 1 A schematic diagram of a traditional hardware semaphore structure for resolving multi-processor access conflicts;

[0045] Figure 2 A flow chart of an access control method disclosed in this application;

[0046] Figure 3 A schematic diagram of a hardware semaphore structure disclosed in this application;

[0047] Figure 4 A schematic diagram of a semaphore request and release management module disclosed in this application;

[0048] Figure 5 This is a schematic diagram of the structure of an interrupt generation module disclosed in this application;

[0049] Figure 6 A block diagram of the overall connection between a processor and a hardware semaphore module disclosed in this application;

[0050] Figure 7 A schematic diagram of the bit structure of a semaphore request register disclosed in this application;

[0051] Figure 8 A flowchart of software usage under multiple processes disclosed in this application;

[0052] Fig. 9 A flowchart of software usage under a multi-processor disclosed in this application;

[0053] Fig.10 A schematic diagram of the structure of an access control device disclosed in this application;

[0054] Fig.11 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] Hardware semaphores can be used to solve the conflict problem of simultaneous access between master and slave processors and shared peripherals between processes in multi-processors and multi-core SOC chips (System-on-a-Chip), ensuring that resources are accessed uniquely. They have a wide range of application scenarios in many fields, including operating system kernels, parallel computing, real-time systems, etc. Compared with software semaphores, hardware semaphores can provide a more efficient synchronization mechanism, make it easier to implement the atomic operations required by semaphores, avoid software-level overhead, and achieve higher concurrency and throughput.

[0057] The currently widely used hardware semaphore solution is that multiple processors access the hardware semaphore registers in the semaphore request and release management module through different buses. The hardware semaphore register is used to record the current state of the binary semaphore as locked or idle. The software locks and unlocks the hardware semaphore through the bus write register, and only the object that is successfully locked can obtain access rights; only after the processor unlocks the semaphore can other processors continue to lock it, thereby ensuring that the resource is uniquely accessed. If a processor attempts to lock a semaphore, but the semaphore is already locked, the lock will fail. After the semaphore is unlocked, an interrupt will be generated to the processor that failed to obtain the semaphore, which serves as a notification. For example Figure 1 The figure shows a schematic diagram of a traditional hardware semaphore structure used to resolve multi-processor access conflicts.

[0058] The current hardware semaphore mechanism is often used to solve the access conflict problem between multiple processors, or to solve the access conflict problem between multiple cores, but some application scenarios may have multi-processor and multi-core competition at the same time, such as the system uses multiple processors, and each processor is a multi-core situation. There is currently a lack of solutions that can solve both conflict problems at the same time through a mechanism, which makes the application scenarios of hardware semaphores relatively limited. To this end, the present application provides an access control solution that can solve the problem that the traditional hardware semaphore solution cannot handle when multiple processors and multiple cores compete for access to peripherals at the same time.

[0059] The embodiment of the present invention discloses an access control method, see Figure 2 As shown, the method includes:

[0060] Step S11: setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register groups include semaphore request registers, semaphore release registers and semaphore interrupt clear registers.

[0061] In the embodiment of the present application, a corresponding number of semaphore register groups are set for peripherals that need access management, which are used for software to request and release hardware semaphores and interrupt control. Figure 3The figure shows the overall hardware semaphore structure block diagram provided by the present invention. The master and slave processors access the semaphore register group inside the hardware semaphore module through different buses, that is, processor 0 and processor 1 access the semaphore register group inside the hardware semaphore module through peripheral bus 0 (Advanced Peripheral Bus, APB) and peripheral bus 1 respectively.

[0062] Among them, a semaphore register group is set in the semaphore request and release management module, and each group includes: a semaphore request register, a semaphore release register and a semaphore interrupt clear register. It should be pointed out that each register in the register group can be accessed by all processors.

[0063] Furthermore, in a feasible implementation, the semaphore register groups can be respectively hung on the NIC bus (Network Interface Controller). Specifically, the semaphore register groups are respectively hung on the network interface controller so as to access the semaphore register groups based on the arbitration function of the network interface controller. In this way, the arbitration function of the network interface controller itself can be used to ensure that there is no conflict when the processor accesses different semaphore registers, and the processor identification (Identity document, ID) accessing the semaphore register can be distinguished through the bus. It can be understood that when the semaphore register group is not hung on the NIC bus, arbitration can also be performed inside the hardware semaphore module.

[0064] In the embodiment of the present application, the correspondence between the peripherals and the semaphore register group is determined by software, and the hardware control logic of each peripheral does not affect each other. The peripherals also include memory, etc. The semaphore register group can realize the locking and unlocking control of the semaphore and the information recording, including but not limited to the binary semaphore state, processor identification and process identification.

[0065] Step S12: Determine the target peripheral device currently being accessed, and obtain a lock request initiated for the target peripheral device.

[0066] In the embodiment of the present application, for the target peripheral that needs to be currently accessed, a lock request initiated for the target peripheral is obtained. It can be understood that since the present invention solves the problem that the traditional hardware semaphore solution cannot handle when multiple processors and multiple cores (processes) compete to access peripherals at the same time, the corresponding processors that initiate the lock request can be different processors, different processes in the same processor, or different processes in different processors.

[0067] In addition, since the present invention can be used to solve the scenario where there may be competition in the access to internal resources of a multi-processor multi-core architecture Soc and unique access needs to be guaranteed, it can also be applied to the access management of resources such as memory and logic units in addition to peripherals.

[0068] Step S13: using the semaphore register group to record information of a locked semaphore; the locked semaphore is a semaphore corresponding to a state in which the binary semaphore recording position in the semaphore request register is in a locked state according to the lock request.

[0069] It is understandable that since the semaphore register group can lock and unlock the semaphore and record information, including but not limited to the binary semaphore state, processor identification and process identification. Therefore, the semaphore register group is used to record the information of the locked semaphore. Among them, the information of the locked semaphore includes the processor identification corresponding to the current lock request recorded by the semaphore request register, the process identification used by the processor, and the state corresponding to the binary semaphore record bit when the lock request is initiated.

[0070] When the state corresponding to the binary semaphore record bit is free, the current processor can lock it to change it to locked state, and determine the corresponding locked semaphore according to the locked state. After the semaphore has been locked, the lock requests initiated by other processors and processes will be distinguished, recorded and sorted, and the information of the locked semaphore will be used to trigger the preset release management rules of the semaphore to deal with multi-processor and multi-core (process) conflicts.

[0071] Step S14: triggering a preset release management rule according to the information of the locked semaphore so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore release register releases the semaphore, using the semaphore interrupt clear register to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

[0072] In an embodiment of the present application, the preset release management rules can ensure that all multiple lock requests initiated by different processors and different processes of the same processor can be correctly processed; and ensure that when the semaphore is locked, all lock requests initiated by different processors and different processes of the same processor can be fully recorded and will not be lost.

[0073] In a specific implementation, the preset release management rule is used to set the first priority between processors. Since the master and slave processors may initiate access to the same semaphore register through different buses at the same time, it is necessary to set the access priority between processors. Two modes, fixed priority and priority polling, are designed, and which mode is used is controlled by software.

[0074] Specifically, the triggering of the preset release management rule according to the information of the locked semaphore includes: determining the current priority access mode. The priority access mode includes a priority fixed mode and a priority polling mode; further, when the priority access mode is the priority fixed mode, the lock request initiated by each processor is processed based on the order of the first priority according to the information of the locked semaphore. That is, if the priority fixed mode is used, when two processors apply for semaphores at the same time, the high-priority processor will lock successfully, and the other processor will enter a waiting state. When the priority access mode is the priority polling mode, the first processor is determined based on the order of the first priority according to the information of the locked semaphore and the target priority corresponding to the first processor is obtained; after the lock request initiated by the first processor is processed, the target priority is switched to the second processor, so that the second processor is preferentially processed according to the target priority when the lock request is initiated again. That is, if the priority polling mode is adopted, each time the semaphore is successfully released by all processes of a processor, the priority is switched to another processor, and the access request of the processor is preferentially guaranteed next time.

[0075] In another specific embodiment, the preset release management rules are used to record different processes of the processor by setting a request queue and set a corresponding second priority for the process. It is understandable that when the number of processes initiating lock requests is large, there may be a problem of nested lock requests from multiple processes in the processor. In order to solve this problem, priorities can be set according to the importance of peripheral access requirements between different processes, and request queues can be designed separately for each processor multi-core access request. When the semaphore has been locked, multiple process requests in the processor can be arranged according to priority and recorded in the queue. After the semaphore is released, a process release interrupt will be generated according to the queue order. In this way, all peripheral access requests can be processed in sequence according to priority, and subsequent requests will not be lost due to nested requests.

[0076] It should be noted that when the current processor or the current process ends accessing the target peripheral device, the semaphore release register will be used to record information, that is, the semaphore will be released. The preset release management rule is used to use the semaphore interrupt clearing register to clear interrupts in sequence according to the first priority and / or the second priority after the semaphore is released by the semaphore release register, until all access requests are processed.

[0077] The present application provides an access control method, comprising: setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register; determining the target peripheral currently being accessed, and obtaining a lock request initiated for the target peripheral; using the semaphore register group to record information about a locked semaphore; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore record position in the semaphore request register is in a locked state according to the lock request; triggering a preset release management rule according to the information about the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore is released by the semaphore release register, using the semaphore interrupt clear register to clear interrupts in sequence according to the order of the first priority and / or the second priority.

[0078] The beneficial technical effects of the present application are as follows: by improving the traditional hardware semaphore method, a corresponding number of semaphore register groups are set for peripherals that need access management, which are used for software request and release management of hardware semaphores and interrupt control. The semaphore register group is used to record the information of the locked semaphore, and the corresponding preset release management rules are used to trigger the lock request. It is ensured that all multiple lock requests initiated by different processors and different processes of the same processor can be processed correctly; and it is ensured that when the semaphore is in a locked state, all lock requests initiated by different processors and different processes of the same processor can be fully recorded and not lost, and are notified in sequence through interrupts according to the set priority, so as to realize the sequential processing of all peripheral access requests, and subsequent requests will not be lost due to nested requests. In this way, the problem of multiple processors and multiple cores competing for access to peripherals is effectively solved, and the peripherals are guaranteed to be uniquely accessed.

[0079] In combination with the above embodiments, Figure 3As shown, the hardware semaphore module mainly includes a semaphore request and release management module, a processor access priority arbitration module, and an interrupt generation module. The semaphore request and release management modules are respectively attached to a network interface controller such as NIC400, so that the processor access to different semaphore registers can be guaranteed not to conflict through the arbitration function of NIC400 itself, and the processor ID accessing the semaphore register can be distinguished through the bus. The processor access priority arbitration module sets a fixed priority or a priority polling mechanism to handle the competition that occurs when two internal processes of the processor access the same semaphore register at the same time. The interrupt generation module is responsible for generating processor release interrupts and process release interrupts. The interrupts are connected to the interrupt controller of the corresponding processor, for example, it can be connected to the processor through GIC600 (General Interrupt Controller) and VIC (Vector Interrupt Controller).

[0080] Furthermore, a semaphore request and release management module corresponding to the processor is set for each peripheral. Figure 4 The figure shows the internal structure diagram of the semaphore request and release management module for peripheral 0. It includes the semaphore request and release management module of processor 0 / 1, the process semaphore request recording module in processor 0 / 1, the process semaphore request priority arbitration module and the process request queue module. The process semaphore request recording module and the priority arbitration module are used to arrange the multiple process requests in the corresponding processor according to the priority. The requests are processed in sequence according to the priority arrangement order in each request queue until all the access requests of peripheral 0 are processed. Figure 5 The figure shows the schematic diagram of the structure of the interrupt generation module. For the two processors, the processor release interrupt mask register is set respectively to control the processor release interrupt generated by different peripherals to the processor in bit by bit. The process release interrupt mask register is also set for different processes in the processor to control the interrupt generated by different processes to the processor. Further, as Figure 6 Shown is a combination Figure 3 and Figure 4 The obtained overall connection block diagram of the processor and the hardware semaphore module is shown in the figure. For more specific working processes of the modules, please refer to the corresponding contents mentioned above, which will not be repeated here.

[0081] Based on the above embodiment, the following introduces in detail an access control method embodiment 2 provided by the present invention. The embodiment 2 is implemented based on the above embodiment and is expanded to a certain extent on the basis of the above embodiment. Figure 7The figure shows the bit structure of the semaphore request register. There are two bits: binary semaphore record bit, bit width 1; flag bit used to indicate whether to use process identification, bit width 1; processor identification record bit, bit width 2; process identification record bit, bit width 8. Since multi-processor and multi-core competition need to be solved at the same time, the flag bit of whether to use process identification needs to be set to 1.

[0082] In the embodiment of the present application, a semaphore register group is used to record information about the processor identification, process identification, and the state of the binary semaphore record bit, etc. The information about the locked semaphore includes the first processor identification, the first process identification, and the lock state corresponding to the binary semaphore record bit. After determining the currently accessed target peripheral and obtaining the lock request initiated for the target peripheral, the following steps are also included:

[0083] Step 1: Determine the initiation type of the lock request.

[0084] In the embodiment of the present application, you can choose whether to use the process ID to initiate a lock request, and whether to use the process ID is controlled by software. In a single-core scenario or when the Linux system has a conflict management mechanism for multi-core processors, you can choose not to use the process ID; similarly, if you only need to resolve conflicts between multiple processors, you also need to choose not to use the process ID. If you need to resolve multi-processor and multi-core competition through hardware semaphores at the same time, you need to use the process ID.

[0085] Specifically, when the lock request is initiated for the target peripheral device through multiple processes in the current processor, the initiation type is determined to be the first initiation type; the first initiation type is a type that requires the use of a process identifier to initiate the lock request. When the lock request is initiated for the target peripheral device through multiple processors, the initiation type is determined to be the second initiation type; the second initiation type is a type that does not require the use of a process identifier to initiate the lock request.

[0086] Step 2: If the initiation type is the first initiation type that requires the use of a process identifier to initiate the lock request, write the process identifier flag in the flag bit through the target bus, and write the first process identifier in the process identifier record bit, then set the binary semaphore record bit from the idle state to the locked state, and write the first processor identifier into the processor identifier record bit to obtain the locked semaphore.

[0087] In a specific implementation, a process ID is required to simultaneously resolve contention between multiple processors and multiple cores. When a binary semaphore record bit of a semaphore request register is in an idle state, a processor needs to access a peripheral device. If a lock request is initiated using a process ID, the semaphore lock can be obtained by writing a process ID flag and a process ID number to the semaphore request register through the bus. At this time, the binary semaphore state of the semaphore request register is automatically set to a locked state.

[0088] Step three: If the initiation type is the second initiation type that does not require the use of a process identifier to initiate the lock request, a flag that does not use a process identifier is written into the flag bit through the target bus, and then the binary semaphore record bit is set from an idle state to the locked state, and the first processor identifier is written into the processor identifier record bit to obtain the locked semaphore.

[0089] In another specific implementation, if a processor does not need to use a process ID to initiate a lock request, it needs to write a flag that does not use a process ID to the semaphore request register through the bus to obtain a lock on the semaphore. When the lock is successful, the binary semaphore record position of the semaphore register is automatically set to a locked state.

[0090] It should be noted that after the binary semaphore record position is locked, the processor ID is automatically recorded in the processor ID record bit of the semaphore request register. When a binary semaphore record bit of a semaphore request register is locked, the lock of the semaphore by other systems (referring to other processes on the same processor or processes on other processors) is invalid.

[0091] In addition, after each lock request, the software needs to read the semaphore request register to determine whether the written information is as expected. When the binary semaphore flag is in the locked state, if the processor ID is the processor that initiated the request and the process ID is consistent, it means that the semaphore is locked successfully and the software can access the peripherals, otherwise the lock fails.

[0092] Furthermore, for different initiation types, the release process of the semaphore is specifically described. Among them, triggering a preset release management rule according to the information of the locked semaphore includes the following steps:

[0093] Determine a target process or a target processor currently accessing the locked semaphore;

[0094] If the initiation type is the first initiation type, when the target process ends the current access, obtaining the second process identifier of the target process and the second processor identifier of the corresponding processor; when the second process identifier is consistent with the first process identifier, and the second processor identifier is consistent with the first processor identifier, using the semaphore release register to release the semaphore corresponding to the target process;

[0095] If the initiation type is the second initiation type, when the target processor ends the current access, the target processor writes a use process identification flag into the semaphore release register to release the semaphore corresponding to the target processor.

[0096] For the convenience of description, the above steps are combined for explanation.

[0097] When the binary semaphore record bit of a semaphore request register is in a locked state, if the process ID is used, the corresponding initiation type is the first initiation type. At this time, only the object that is consistent with the processor ID and process ID recorded in the semaphore request register can release the semaphore, that is, only the system that currently locks the semaphore can release the semaphore, otherwise the semaphore will remain in its original state and will not be released. If the process ID is not used, the corresponding initiation type is the second initiation type. At this time, the processor that has locked the semaphore can release the semaphore by writing the flag bit in the semaphore release register to indicate whether the process ID is used.

[0098] Based on the above embodiment, this embodiment will specifically explain S14 in the above embodiment. The process of generating an interrupt may include the following steps:

[0099] Step 1: Determine the currently corresponding first lock request according to the lock semaphore, and acquire a second lock request synchronously initiated for the target peripheral device based on the first lock request.

[0100] In the embodiment of the present application, the corresponding first lock request can be determined according to the current lock semaphore, and the processor or process corresponding to the first lock request successfully locks the semaphore and has access rights. To ensure that the resource is uniquely accessed, all lock requests initiated synchronously by different processors and different processes of the same processor can be fully recorded and will not be lost. Therefore, based on the first lock request, a second lock request initiated synchronously for the target peripheral is obtained.

[0101] Step 2: triggering a release interrupt according to the second lock request, and determining a corresponding release interrupt type.

[0102] In the embodiment of the present application, interrupts are divided into two categories, one is a processor release interrupt; the other is a process release interrupt. Therefore, it is necessary to judge the release interrupt type when triggering the release interrupt.

[0103] Step three: If the release interrupt type is a processor release interrupt, the interrupt request signal is pulled high according to the second lock request. When the first lock request is processed, the semaphore release signal is pulled high, and then an interrupt is issued to the processor whose request failed.

[0104] In a specific implementation, if the release interrupt type is a processor release interrupt, when and only when a process in a processor issues a lock request for a semaphore, if the semaphore has been locked by a process of another processor, the interrupt request signal will be pulled high. Then, after all the peripheral access requests of the other processor are completed and the semaphore is released, the semaphore release signal will be pulled high. After both the interrupt request signal and the semaphore release signal are pulled high, the hardware semaphore module will give an interrupt to the processor whose request failed.

[0105] It should be pointed out that the interrupt release signal can only be pulled high after the request signal is pulled high, otherwise the interrupt will be abnormally generated under a certain semaphore request and release sequence.

[0106] Step 4: If the release interrupt type is a process release interrupt, after the first lock request is processed, interrupts are issued to the processes in the request queue in order of the second priority, and an interrupt is issued to the processor whose request failed when the request queue is empty.

[0107] In another specific implementation, if the release interrupt type is a process release interrupt, it is used to fail the lock request initiated by other processes of a processor after the semaphore has been locked by the process of a processor. After the semaphore is released, a process release interrupt is generated to the processor, and the software reads the next process ID that can initiate access in the interrupt handler, and then re-initiates the lock request for the semaphore.

[0108] Specifically, the sending of interrupts to the processes in the request queue in sequence according to the order of the second priority comprises the following steps:

[0109] Determine the first process in the request queue, and read out the first process identifier of the first process using a preset interrupt processing function;

[0110] An interrupt is sent to the first process according to the first process identifier. When the first process is processed, the interrupt of the first process is cleared and the first process is removed from the queue. The next process is then used as the first process, and the step of using a preset interrupt processing function to read out the first process identifier of the first process is triggered until the request queue is empty.

[0111] In the embodiment of the present application, in the process of sequentially processing the processes in the request queue, the process ID of the first process in the queue is read in the interrupt processing function, and then a lock request is initiated in the process corresponding to the first process ID. If the queue is empty, it is considered that all requests in the processor have been processed. At this time, if the request queue of another processor is not empty, a processor release interrupt will be generated to notify the process of the other processor that an application can be initiated, and the above process will be repeated.

[0112] Combine the following Figure 8 , Fig. 9 The software usage process under multiple processes and the software usage process under multiple processors are described in detail. Figure 3 Take the specific implementation scenario as an example. There are two processors in the system, processor 0 and processor 1. Process 0, process 1 and process 4 in processor 0 may access peripheral 0 (process priority 0>1>4), and process 2 and process 3 may access peripheral 1 (process priority 2>3); process 0, process 2 and process 3 in processor 1 may access peripheral 0 (process priority 0>2>3), and process 1 and process 4 may access peripheral 1 (process priority 1>4). Processor 0 and processor 1 access the registers inside the hardware semaphore module through peripheral bus apb0 and peripheral bus apb1 respectively, and the buses are respectively connected to the NIC400 network interface controller. Among them, semaphore 0 is responsible for managing peripheral 0, and semaphore 1 is responsible for managing peripheral 1. Let the ID of processor 0 be 2'b01 and the ID of processor 1 be 2'b10.

[0113] exist Figure 8In the software usage process under multiple processes, when Process 0 of Processor 0 needs to access Peripheral 0 and Semaphore 0 is currently in free idle state, the software of Processor 0 writes the ID of Process 0 into Semaphore 0 request register to obtain the lock of the semaphore. The software reads the value of the semaphore request register at this time and judges that if the processor ID and process ID are consistent with the process and the semaphore is in locked state, it is considered that the lock is successful, that is, Peripheral 0 can be accessed normally. At this time, if Process 1 and Process 4 of Processor 0, Process 0 and Process 2 of Processor 1 initiate requests for Semaphore 0 in turn, the request will fail. At the same time, Process 1 and Process 4 of Processor 0, Process 0 and Process 2 of Processor 1 will be recorded in their respective request queues and arranged according to priority. If Process 1 of Processor 0 ends accessing the peripheral, it needs to release it by writing the process ID into the corresponding semaphore release register. After Process 1 of Processor 0 releases Semaphore 0, since there are still processes in the queue, the hardware semaphore module will send an interrupt to Processor 0. In the interrupt handler, the ID of Process 1 at the head of the list will be read, and after writing the interrupt clear register to clear the interrupt, the semaphore request will be re-initiated in Process 1. Repeat the above steps until the request queue of Processor 0 is empty. After the queue is empty, since there is a request process in the queue of Processor 1, an interrupt will be generated to Processor 1, notifying the process in Processor 1 that it can continue to initiate requests, and then processing them in sequence according to the request queue until all access requests of Peripheral 1 are processed.

[0114] Similarly, in Fig. 9 In the software usage process under multiple processors, it is only necessary to resolve the multi-processor conflict. At this time, it is necessary to choose not to use the process ID. When processor 0 needs to access peripheral 0 and semaphore 0 is currently in the free idle state, the processor 0 software writes the ID of processor 0 to the semaphore 0 request register to obtain the lock of the semaphore. After the lock request, the software needs to read the semaphore request register to determine whether the written information meets expectations. If the semaphore is locked successfully, the software can access peripheral 0 normally. Since the process ID is not used, if processor 0 ends accessing the peripheral, it needs to release the semaphore by writing the semaphore release register using the process ID flag through the processor that has locked the semaphore. When all interrupts in the semaphore interrupt register are cleared, all access requests are processed.

[0115] Correspondingly, the present application also discloses an access control device, see Fig.10 As shown, the device comprises:

[0116] The register group setting module 11 is used to set a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register;

[0117] A lock request acquisition module 12, used to determine the target peripheral device currently being accessed, and to acquire a lock request initiated for the target peripheral device;

[0118] An information recording module 13 is used to record information of a locked semaphore by using the semaphore register group; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore recording position in the semaphore request register is in a locked state according to the lock request;

[0119] A lock request processing module 14 is used to trigger a preset release management rule according to the information of the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore release register releases the semaphore, the semaphore interrupt clear register is used to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

[0120] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0121] It can be seen that the above scheme of this embodiment includes: setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register; determining the target peripheral currently being accessed, and obtaining a lock request initiated for the target peripheral; using the semaphore register group to record information about the locked semaphore; the locked semaphore is a semaphore corresponding to the state in which the binary semaphore record position in the semaphore request register is locked according to the lock request; triggering a preset release management rule according to the information of the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore release register releases the semaphore, using the semaphore interrupt clear register to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

[0122] The beneficial technical effects of the present application are as follows: by improving the traditional hardware semaphore method, a corresponding number of semaphore register groups are set for peripherals that need access management, which are used for software request and release management of hardware semaphores and interrupt control. The semaphore register group is used to record the information of the locked semaphore, and the corresponding preset release management rules are used to trigger the lock request. It is ensured that all multiple lock requests initiated by different processors and different processes of the same processor can be processed correctly; and it is ensured that when the semaphore is in a locked state, all lock requests initiated by different processors and different processes of the same processor can be fully recorded and not lost, and are notified in sequence through interrupts according to the set priority, so as to realize the sequential processing of all peripheral access requests, and subsequent requests will not be lost due to nested requests. In this way, the problem of multiple processors and multiple cores competing for access to peripherals is effectively solved, and the peripherals are guaranteed to be uniquely accessed.

[0123] In a specific implementation, the lock request acquisition module 12 further includes:

[0124] An initiation type determination module, used to determine the initiation type of the lock request;

[0125] A first lock semaphore determination module is used for, if the initiation type is a first initiation type that requires using a process identifier to initiate the lock request, writing a process identifier flag into the flag bit through a target bus, and writing the first process identifier into the process identifier record bit, and then setting the binary semaphore record bit from an idle state to the locked state, and writing the first processor identifier into the processor identifier record bit, so as to obtain the lock semaphore;

[0126] A second lock semaphore determination module is used to write a non-process identification flag in the flag bit through the target bus if the initiation type is a second initiation type that does not require the use of a process identification to initiate the lock request, and then set the binary semaphore record bit from an idle state to the locked state, and write the first processor identification into the processor identification record bit to obtain the lock semaphore.

[0127] In a specific implementation, the lock request processing module 14 includes:

[0128] An access object determination module, used to determine a target process or a target processor currently accessing the lock semaphore;

[0129] A first semaphore release module is used for, if the initiation type is the first initiation type, obtaining a second process identifier of the target process and a second processor identifier of the corresponding processor when the target process ends the current access; when the second process identifier is consistent with the first process identifier, and the second processor identifier is consistent with the first processor identifier, releasing the semaphore corresponding to the target process by using the semaphore release register;

[0130] The second semaphore release module is used to write a process identification flag in the semaphore release register through the target processor to release the semaphore corresponding to the target processor if the initiation type is the second initiation type when the target processor ends the current access.

[0131] In a specific implementation, the lock request processing module 14 includes:

[0132] A synchronous lock request acquisition module, configured to determine a currently corresponding first lock request according to the lock semaphore, and acquire a second lock request synchronously initiated for the target peripheral device based on the first lock request;

[0133] A release interrupt type determination module, configured to trigger a release interrupt according to the second lock request, and determine a corresponding release interrupt type;

[0134] A first release interrupt module, configured to, if the release interrupt type is a processor release interrupt, pull up an interrupt request signal according to the second lock request, and after the first lock request is processed, pull up a semaphore release signal, and then send an interrupt to the processor whose request failed;

[0135] The second release interrupt module is used to send interrupts to the processes in the request queue in sequence according to the second priority order after the first lock request is processed if the release interrupt type is a process release interrupt, and to send an interrupt to the processor whose request failed when the request queue is empty.

[0136] In a specific implementation, the second release interrupt module includes:

[0137] A first process determination module, used to determine the first process in the request queue, and read out the first process identifier of the first process using a preset interrupt processing function;

[0138] A loop processing module is used to send an interrupt to the first process according to the first process identifier. When the first process is processed, the interrupt of the first process is cleared and the first process is removed from the queue. The next process is then used as the first process, and the step of using a preset interrupt processing function to read the first process identifier of the first process is triggered until the request queue is empty.

[0139] In a specific implementation, the lock request processing module 14 includes:

[0140] A priority access mode determination module, used to determine a current priority access mode; the priority access mode includes a priority fixed mode and a priority polling mode;

[0141] a fixed mode processing module, configured to process lock requests initiated by each processor based on the first priority order according to information of the lock semaphore when the priority access mode is the fixed priority mode;

[0142] A polling mode processing module is used to determine the first processor and obtain the target priority corresponding to the first processor based on the order of the first priority according to the information of the lock semaphore when the priority access mode is the priority polling mode; when the lock request initiated by the first processor is processed, the target priority is switched to the second processor, so that the second processor is given priority according to the target priority when the lock request is initiated again.

[0143] In a specific implementation, the access control device further includes:

[0144] The register group mounting module is used to mount the semaphore register groups to the network interface controllers respectively, so as to access the semaphore register groups based on the arbitration function of the network interface controller.

[0145] Furthermore, the present application also discloses an electronic device. Fig.11 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be considered as any limitation on the scope of use of the present application.

[0146] Fig.11A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the access control method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be a server.

[0147] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0148] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The data 223 may include various data. The storage method may be temporary storage or permanent storage.

[0149] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs that can be used to complete the access control method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.

[0150] Furthermore, the embodiment of the present application also discloses a computer-readable storage medium, wherein the computer-readable storage medium mentioned here includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk, or any other form of storage medium known in the technical field. Wherein, the computer program implements the aforementioned access control method when executed by the processor. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the aforementioned embodiment, and no further description will be given here.

[0151] Furthermore, an embodiment of the present application also provides a computer program product, including a computer program / instruction, which implements any one of the above-mentioned access control methods when executed by a processor.

[0152] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0153] The steps of the access control method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0154] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0155] The access control method, device, equipment and medium provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. An access control method, characterized in that: include: A corresponding number of semaphore register groups are set for peripherals that need access management; wherein the semaphore register groups include a semaphore request register, a semaphore release register, and a semaphore interrupt clear register; Determine the target peripheral device currently being accessed, and obtain a lock request initiated for the target peripheral device; The semaphore register group is used to record information of a locked semaphore; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore recording position in the semaphore request register is in a locked state according to the lock request; A preset release management rule is triggered according to the information of the locked semaphore so that the lock request is processed in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore is released by the semaphore release register, the semaphore interrupt clear register is used to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

2. The access control method according to claim 1, characterized in that: The semaphore request register includes the binary semaphore record bit, a flag bit used to indicate whether to use the process identifier, a processor identifier record bit and a process identifier record bit; the information of the locked semaphore includes the first processor identifier, the first process identifier and the locking state corresponding to the binary semaphore record bit; After determining the target peripheral device currently being accessed and obtaining a lock request initiated for the target peripheral device, the method further includes: Determining the initiation type of the lock request; If the initiation type is a first initiation type that requires using a process identifier to initiate the lock request, a process identifier flag is written into the flag bit through the target bus, and the first process identifier is written into the process identifier record bit, and then the binary semaphore record bit is set from an idle state to the locked state, and the first processor identifier is written into the processor identifier record bit to obtain the locked semaphore; If the initiation type is a second initiation type that does not require the use of a process identifier to initiate the lock request, a flag that does not use a process identifier is written to the flag bit through the target bus, and then the binary semaphore record bit is set from an idle state to the locked state, and the first processor identifier is written into the processor identifier record bit to obtain the locked semaphore.

3. The access control method according to claim 2, characterized in that: When the lock request is initiated for the target peripheral device through multiple processes in the current processor, determining that the initiation type is the first initiation type; When the lock request is initiated for the target peripheral device through multiple processors, determining that the initiation type is the second initiation type; The preset release management rule is triggered according to the information of the locked semaphore, including: Determine a target process or a target processor currently accessing the locked semaphore; If the initiation type is the first initiation type, when the target process ends the current access, obtaining the second process identifier of the target process and the second processor identifier of the corresponding processor; when the second process identifier is consistent with the first process identifier, and the second processor identifier is consistent with the first processor identifier, using the semaphore release register to release the semaphore corresponding to the target process; If the initiation type is the second initiation type, when the target processor ends the current access, the target processor writes a use process identification flag into the semaphore release register to release the semaphore corresponding to the target processor.

4. The access control method according to claim 1, characterized in that: The triggering of a preset release management rule according to the information of the locked semaphore includes: Determine a currently corresponding first lock request according to the lock semaphore, and acquire a second lock request synchronously initiated for the target peripheral device based on the first lock request; triggering a release interrupt according to the second lock request, and determining a corresponding release interrupt type; If the release interrupt type is a processor release interrupt, the interrupt request signal is pulled high according to the second lock request, and when the first lock request is processed, the semaphore release signal is pulled high, and then an interrupt is issued to the processor whose request failed; If the release interrupt type is a process release interrupt, after the first lock request is processed, interrupts are issued to the processes in the request queue in sequence according to the second priority order, and an interrupt is issued to the processor whose request failed when the request queue is empty.

5. The access control method according to claim 4, characterized in that: The interrupting the processes in the request queue in sequence according to the order of the second priority comprises: Determine the first process in the request queue, and read out the first process identifier of the first process using a preset interrupt processing function; An interrupt is sent to the first process according to the first process identifier. When the first process is processed, the interrupt of the first process is cleared and the first process is removed from the queue. The next process is then used as the first process, and the step of using a preset interrupt processing function to read out the first process identifier of the first process is triggered until the request queue is empty.

6. The access control method according to claim 1, characterized in that: The triggering of a preset release management rule according to the information of the locked semaphore includes: Determine a current priority access mode; the priority access mode includes a priority fixed mode and a priority polling mode; When the priority access mode is the priority fixed mode, processing the lock requests initiated by each processor based on the order of the first priority according to the information of the lock semaphore; When the priority access mode is the priority polling mode, according to the information of the lock semaphore, the first processor is determined based on the order of the first priority and the target priority corresponding to the first processor is obtained; when the lock request initiated by the first processor is processed, the target priority is switched to the second processor, so that when the lock request is initiated again, the second processor is given priority according to the target priority.

7. The access control method according to any one of claims 1 to 6, characterized in that: After the corresponding number of semaphore register groups are set for the peripherals that need access management, the method further includes: The semaphore register groups are respectively hung on the network interface controllers so as to access the semaphore register groups based on the arbitration function of the network interface controller.

8. An access control device, characterized in that: include: A register group setting module, used for setting a corresponding number of semaphore register groups for peripherals that need access management; wherein the semaphore register group includes a semaphore request register, a semaphore release register and a semaphore interrupt clear register; A lock request acquisition module, used to determine the target peripheral device currently being accessed, and acquire a lock request initiated for the target peripheral device; An information recording module, used to record information of a locked semaphore using the semaphore register group; the locked semaphore is a semaphore corresponding to a state in which a binary semaphore recording position in the semaphore request register is in a locked state according to the lock request; A lock request processing module, used to trigger a preset release management rule according to the information of the locked semaphore, so as to process the lock request in sequence based on the preset release management rule; the preset release management rule is used to set a first priority between processors, and to record different processes of the processor by setting a request queue and set a corresponding second priority for the process, and after the semaphore release register releases the semaphore, the semaphore interrupt clear register is used to clear the interrupt in sequence according to the order of the first priority and / or the second priority.

9. An electronic device, characterized in that: The electronic device comprises a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the access control method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein the computer program, when executed by a processor, implements the access control method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Process management system, method and equipment and storage medium

    CN121900979A

  • Method and system for directionally improving priority of specified process lock

    CN122132199A