Multi-task automatic mutual exclusion lock management middleware
Through the lock management middleware that matches resource classification and dynamic lock strategy, lock nesting errors and deadlock problems in traditional multi-task systems are solved, efficient lock resource management is achieved, and the real-time and reliability of the system are improved.
Patent Information
- Application Number
- CN202510661014.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-07-25
AI Technical Summary
In traditional multitasking systems, shared resource management relies on developers to manually design lock mechanisms, and there are problems such as lock nesting errors, inversion of priority and poor scalability. The existing lock management middleware cannot adapt to differentiated scenarios and is difficult to solve dynamic priority preemption and deadlock.
It provides a multi-task automatic mutually exclusive lock management middleware, which identifies task resource attributes through the resource classification module, combines the lock policy library and priority module, dynamically matches the optimal lock strategy, and integrates a ring deadlock detection module to realize fully automatic lock management.
It significantly reduces the risks of lock conflict and deadlock, improves the real-time and reliability of multi-task systems, reduces the risk of lock conflict by 90%, improves resource utilization by 75%, and meets the real-time requirements of embedded and industrial control scenarios.
Smart Images

Figure CN120371558A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a lock management middleware with multi-task automatic mutual exclusion, an electronic device, and a readable storage medium. Background Art
[0002] In the development of traditional multi-task systems, the management of shared resources highly depends on developers to manually design lock mechanisms (such as mutex locks and semaphores). It is necessary to independently implement the locking logic for each resource, and there are problems such as lock nesting errors and priority inversion (high-priority tasks are blocked by low-priority locks). Existing lock management middleware usually adopts a single lock strategy (such as a global mutex lock), which cannot adapt to differentiated scenarios such as high-frequency read-write counters and hardware peripherals, and has poor scalability - adding new hardware or services requires reconstructing the lock logic, and it is easy to trigger deadlocks due to circular waiting in dynamic task scheduling. Although traditional solutions can detect some lock conflicts through static code analysis tools, it is difficult to solve dynamic problems such as priority preemption and intelligent optimization of lock strategies in real-time systems. Summary of the Invention
[0003] In view of the above problems, the present invention is proposed to provide a lock management middleware with multi-task automatic mutual exclusion, an electronic device, and a readable storage medium that overcome the above problems or at least partially solve the above problems.
[0004] The present invention provides a lock management middleware with multi-task automatic mutual exclusion, including:
[0005] A resource classification module, configured to, when the middleware receives task information sent by the client, identify the resource attributes of each task in the current system and generate resource attribute data for each task;
[0006] A task priority module, configured to determine the priority of a task according to the task information;
[0007] A lock strategy library module, configured to collect system resource status data in real time, and determine the optimal lock for each task according to the system resource status data and the resource attribute data of each task, and sequentially bind the optimal lock of each task to the target resource of each task in the order of task priority to generate a lock handle;
[0008] An automatic execution module, configured to inject the lock handle into the task context and perform a locking operation.
[0009] Optionally, the resource classification module is further configured to identify the resource access modes of each task in the current system, count the read / write times per unit time, calculate the time consumption of a single operation, obtain the resource attribute data of each task, store the resource attribute data of each task in the multi-dimensional resource portrait database in the form of multi-dimensional vectors, and establish an index for real-time query; the resource attribute data includes resource access modes, read / write types, and operation time consumption types.
[0010] Optionally, the resource classification module is further configured to identify the resource access modes of system resources, count the read / write times per unit time, calculate the time consumption of a single operation, obtain the attribute data of system resources, store the attribute data of system resources in the multi-dimensional resource portrait database in the form of multi-dimensional vectors, and establish an index for real-time query; the attribute data includes resource access modes, read / write types, and operation time consumption types.
[0011] Optionally, the task priority module is further configured to:
[0012] Determine whether the task information contains task priority label information;
[0013] If the task information contains task priority label information, bind the corresponding priority to the task according to the task priority label information;
[0014] If the task information does not contain task priority label information, determine the priority of the task according to the priority mapping table and the task type of the task, and bind the corresponding priority to the task.
[0015] Optionally,
[0016] The task priority module is further configured to: when a high-priority task initiates a lock request, compare the priority levels of the requesting task and the current lock-holding task through the dynamic priority mapping table, and trigger the preemptive arbitration mechanism; for tasks with the same priority level, dynamically adjust the enhanced FIFO queue through the timestamp sliding window, and the tasks dequeue in timestamp order;
[0017] The lock policy library module is further configured to: forcibly recycle the locks held by low-priority tasks according to the preemptive arbitration mechanism, and roll back the transactions of low-priority tasks to the memory state at the safe point through the transaction log; for tasks with the same priority level, allocate lock resources in the order of task requests within the window period.
[0018] Optionally, the lock policy library module is further configured to dynamically load and parse the custom new lock description files added by the integrated user in a hot-pluggable manner; the custom new lock description files include lock type information, applicable scenario information, and resource dependency information.
[0019] Optionally, the multi-task automatic mutual exclusion lock management middleware further includes a circular deadlock detection module.
[0020] The circular deadlock detection module is used to: periodically scan the lock waiting relationship of tasks in the system, build and maintain a resource allocation directed graph; detect the loop structure in the resource allocation directed graph to identify deadlock; if a deadlock is detected and the deadlock duration exceeds a preset time threshold, trigger an early warning and record the lock stack information.
[0021] Optionally, the annular deadlock detection module is further used to:
[0022] In the deadlock handling process, the task priority and lock type information of the process involved in the deadlock are obtained, and the transaction is rolled back to release the lower priority lock-occupying task. If the rollback fails, an alarm message is sent to the system monitoring center to forcibly terminate the process and trigger the restart of the lower priority lock-occupying task.
[0023] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the electronic device executes the computer program, it loads the multi-task automatic mutual exclusion lock management middleware as described in any one of the embodiments of the present invention.
[0024] The present invention further provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the multi-task automatic mutual exclusion lock management middleware as described in any one of the embodiments of the present invention is loaded.
[0025] The present invention includes the following advantages:
[0026] The multi-task automatic mutual exclusion lock management middleware of the present invention realizes fully automatic lock management through intelligent resource classification, dynamic lock strategy matching and priority-sensitive scheduling. The middleware has a built-in resource feature analysis algorithm, which can automatically identify the read and write characteristics of resources such as hardware devices and memory queues, and combines preset atomic locks, read-write locks, spin locks and other policy libraries to allocate optimal lock mechanisms for different scenarios; the original priority preemptive scheduling algorithm allows high-priority tasks to break through the lock waiting queue limit and ensure the real-time task responsiveness; at the same time, the circular deadlock detection module is integrated to release the lower priority lock occupying tasks through transaction rollback to release the circular waiting. Developers only need to mark the task priority label to achieve zero manual lock coding and reduce the risk of lock conflict by more than 90%. These modules of the present invention work together to realize fully automatic lock management, which significantly reduces the risk of lock conflict and deadlock without manually coding the lock logic, and significantly improves the real-time performance and reliability of multi-task systems in embedded, industrial control and other scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1It is a structural block diagram of a lock management middleware with multi-task automatic mutual exclusion provided by an embodiment of the present invention;
[0028] Figure 2 It is a processing flow chart of multi-task automatic mutual exclusion lock management provided by an embodiment of the present invention. Specific embodiments
[0029] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0030] Refer to Figure 1 , which shows a structural block diagram of a lock management middleware with multi-task automatic mutual exclusion provided by an embodiment of the present invention. Specifically, it may include the following modules:
[0031] A resource classification module, which is used to identify the resource attributes of each task in the current system and generate resource attribute data for each task when the middleware receives task information sent by the user terminal;
[0032] A task priority module, which is used to determine the priority of a task according to the task information;
[0033] A lock policy library module, which is used to collect system resource status data in real time, and determine the optimal lock for each task according to the system resource status data and the resource attribute data of each task, and bind the optimal lock of each task to the target resource of each task in turn according to the task priority order to generate a lock handle;
[0034] An automatic execution module, which is used to inject the lock handle into the task context and perform a locking operation.
[0035] Refer to Figure 2, the lock management processing flow for multi-task automatic mutual exclusion is as follows: ① First, the system loads the XML / JSON description file of the standardized plugin interface (the user can optionally customize new locks and mark task priorities), and then communicates with the middleware through the internal HTTP communication protocol, sending task information to the algorithm middleware. The task information can include the task type. In the case where the user customizes new locks and marks task priorities, the task information can include user lock plugin configuration and task priority label information. ② After the middleware obtains all the task information, it starts the resource classification module to identify, count, and statistically analyze the time consumption of all tasks in the current system through interface methods such as static configuration, memory access counter, and nanosecond timer. Finally, it generates resource attribute data, stores these data as multi-dimensional vectors (for example: [shared type, high-frequency read / write, short operation time consumption]) in the multi-dimensional resource portrait database and establishes an index for real-time query. ③ The task priority module binds corresponding task priorities to all tasks. The lock policy library module real-time collects system status data (CPU load, task queue length), and according to the task priority order, pulls the resource attribute data of each task from the multi-dimensional portrait database, and sequentially binds the final lock policy to the target resources of each task to generate a lock handle. ④ The automatic execution module marks the task priority, injects the lock handle into the task context, replaces the manual locking code, and executes the locking step. For example, mapping the file path read / write through the / proc file system to real-time tasks, read / write locks.
[0036] Among them, the lock policy library module is the management repository of various lock mechanisms (spin lock, read / write lock, atomic lock, mutex lock, priority inheritance lock, etc.), and at the same time provides the best lock for tasks. That is, encapsulating the lock mechanism into a standardized interface and adopting a plug-in architecture, it can dynamically load new locks through the XML / JSON configuration file, and users can add and extend new locks. The best lock type algorithm selects the optimal lock for tasks based on the resource portrait (access mode, read / write frequency type, time consumption) and system status (CPU load, task queue length). Preferably, the best lock type algorithm matches the corresponding lock according to the following resource portrait and system status conditions to achieve the adaptive optimization of the lock mechanism and the scenario. The rule matching order is: access mode → read / write frequency → operation time consumption + system status.
[0037] 1. Exclusive type + low-frequency read / write + long operation time consumption + high CPU load + long task queue → mutex lock;
[0038] 2. Exclusive type + low-frequency read / write + long operation time consumption + medium CPU load + medium task queue → mutex lock;
[0039] 3. Exclusive type + high-frequency read / write + short operation time consumption + low CPU load + short task queue → priority inheritance lock;
[0040] 4. Exclusive + High-frequency Reading and Writing + Long Operation Time-consuming + High CPU Load + Long Task Queue → Segmented Lock;
[0041] 5. Shared + High-frequency Reading and Writing + Short Operation Time-consuming + Low CPU Load + Short Task Queue → Atomic Lock;
[0042] 6. Shared + High-frequency Reading and Writing + Short Operation Time-consuming + High CPU Load + Long Task Queue → Read-write Lock (Read Priority);
[0043] 7. Shared + Medium-frequency Reading and Writing + Long Operation Time-consuming + Medium CPU Load + Medium Task Queue → Read-write Lock (Write Priority);
[0044] 8. Shared + Low-frequency Reading and Writing + Long Operation Time-consuming + Low CPU Load + Short Task Queue → Semaphore (Lock);
[0045] 9. Shared + High-frequency Reading and Writing + Short Operation Time-consuming + Medium CPU Load + Long Task Queue → Spin Lock;
[0046] 10. Shared + Medium-frequency Reading and Writing + Short Operation Time-consuming + High CPU Load + Medium Task Queue → Mutex Lock.
[0047] In an alternative embodiment of the present invention, the resource classification module is further configured to perform resource access mode recognition, read and write counting per unit time, and single operation time-consuming calculation on system resources, obtain attribute data of system resources, store the attribute data of system resources in the multi-dimensional resource portrait database in the form of multi-dimensional vectors, and establish an index for real-time query; the attribute data includes resource access mode, read and write type, and operation time-consuming type.
[0048] In this embodiment, the resource classification module is built with a resource feature analysis algorithm, which is responsible for intelligently identifying the attributes of system resources and constructing a resource type portrait database through dynamic monitoring and pattern recognition technologies. The implementation logic is as follows: First, pre-define a resource database in the static configuration to facilitate the identification and marking of resource access modes. For example, try to identify the exclusive feature O_EXCL flag of hardware devices such as serial ports / USBs through system calls (such as open, mmap), and mark the resource as "exclusive hardware"; then monitor the access frequency of resources in the memory cache queue through the memory access counter, and mark resources with more than 1000 read and write times per second as "high-frequency reading and writing type"; then use a nanosecond-level timer to count the single operation time-consuming of resources, mark operations with a time-consuming <10ms as short-time operations, and mark operations such as file I / O with a time-consuming ≥10ms as long-time operations; finally, store these resources with attribute tags as multi-dimensional vectors in the multi-dimensional resource portrait database for subsequent module queries.
[0049] In an alternative embodiment of the present invention, the task priority module is further configured to:
[0050] Determine whether the task information contains task priority label information;
[0051] If the task information contains task priority label information, bind the corresponding priority to the task according to the task priority label information;
[0052] If the task information does not contain task priority label information, determine the priority of the task according to the priority mapping table and the task type of the task, and bind the corresponding priority to the task.
[0053] In this embodiment, the task priority module supports users to mark task priority labels. By maintaining a dynamic priority mapping table, real-time tasks (hardware interrupts, serial port communication) > high-priority user processes (memory calculation) > background services (log writing) > low-priority batch processing (network). First, it is judged whether the task has a user mark. If not, then according to the task type, the task is marked with labels such as "real-time task" or "high-priority user process" or "background service" to determine the priority.
[0054] In an alternative embodiment of the present invention, the task priority module is further configured to: when a high-priority task initiates a lock request, compare the priority levels of the requesting task and the current lock-holding task through the dynamic priority mapping table, and trigger a preemption arbitration mechanism; for tasks with the same priority level, dynamically adjust the enhanced FIFO queue through a timestamp sliding window, and the tasks dequeue in timestamp order;
[0055] The lock policy library module is further configured to: forcibly recycle the lock held by a low-priority task according to the preemption arbitration mechanism, and roll back the transaction of the low-priority task to the memory state at the safe point through the transaction log; for tasks with the same priority level, allocate lock resources in the order of task requests within the window period.
[0056] In this embodiment, the task priority module and the lock policy library module construct a preemption rule algorithm through priority labels and a timestamp sliding window. When a high-priority task initiates a lock request, a preemption arbitration mechanism is triggered - forcibly recycle the lock held by a low-priority task and roll back its transaction to the memory state at the safe point through the transaction log to solve the priority inversion problem. For tasks with the same priority, an enhanced FIFO queue is adopted, and the timestamp sliding window is used to prevent queue starvation (no resource allocation), and the tasks dequeue in timestamp order to ensure the deep coordination of lock policy scheduling and priority decision-making.
[0057] In an alternative embodiment of the present invention, the lock policy library module is further configured to dynamically load and parse a custom new lock description file added by the integrated user in a hot-pluggable manner; the custom new lock description file includes lock type information, applicable scenario information, and resource dependency information.
[0058] In this embodiment, the user-defined module of the client supports the user to customize a new type of lock through a standardized plug-in interface and dynamically integrate it into the lock policy library in a hot-pluggable manner. The lock policy library module dynamically loads and parses the custom new type of lock description file added by the user in a hot-pluggable manner. Among them, the custom new type of lock description file may include meta-information such as lock type information, applicable scenario information, and resource dependency information.
[0059] In an alternative embodiment of the present invention, the lock management middleware for multi-task automatic mutual exclusion further includes a circular deadlock detection module.
[0060] The circular deadlock detection module is used for: periodically scanning the lock waiting relationships of tasks in the system, constructing and maintaining a resource allocation directed graph; detecting loop structures in the resource allocation directed graph to identify deadlocks; if a deadlock is detected and the deadlock duration exceeds a preset time threshold, triggering an alarm and recording lock stack information.
[0061] In an alternative embodiment of the present invention, the circular deadlock detection module is further used for:
[0062] In the deadlock handling process, obtain the task priorities and lock type information of the processes involved in the deadlock, roll back the transaction to release the tasks occupying the lower-priority locks. If the rollback fails, send an alarm message to the system monitoring center to forcibly terminate the process and trigger the restart of the tasks occupying the lower-priority locks.
[0063] A distributed deadlock detection mechanism is designed in the circular deadlock detection module, and a graph theory algorithm is used to periodically scan the lock waiting relationships. The module maintains a resource allocation directed graph, and identifies loops through DFS depth-first search. For example, process A → lock 1 → process B → lock 2 → process A, and millisecond-level fault location is achieved through the lock event pipeline log. If the detected deadlock time exceeds the preset threshold (>10s), trigger an alarm and record the lock stack information, and start the deadlock handling process: first, obtain the task priorities of processes A and B and their respective lock types, roll back the transaction to release the tasks occupying the lower-priority locks. If the rollback fails, send a SIGDEADLK signal to the system monitoring center to trigger the restart of the tasks occupying the lower-priority locks, achieving millisecond-level deadlock resolution.
[0064] Refer to Figure 2 In the processing process, the circular deadlock detection module can repeatedly detect whether a circular deadlock occurs during the execution process. If a deadlock is detected and the time exceeds the preset threshold (>10s), then obtain the task priorities of the processes where the deadlock occurs and their respective lock types, roll back the lower-priority locks in the transaction, release the system occupation of this task and record the log information. If the rollback fails, send the deadlock-related log information to the Telpo system personnel terminal, and at the same time, the client returns a SIGDEADLK signal and restarts the tasks of the lower-priority locks.
[0065] In the present invention, the main functions of the client communicating with the middleware are as follows:
[0066] 1. User-defined module: This module allows developers to customize new locks (such as distributed locks, transaction locks, segmented locks, etc.) through standardized plug-in interfaces, and dynamically integrate them into the lock policy library in a hot-swappable manner, and provides an API interface for filling in task names and marking task priorities. The implementation logic is: users follow the predefined lock operation interface (such as lock() / unlock()) to implement the core lock logic, and declare meta-information such as lock type, applicable scenarios, resource dependencies, etc. through XML / JSON description files. The system automatically loads the user lock plug-in at startup and the lock policy library module automatically adapts the call according to the real-time system status and the task priority assigned to the user lock when it is used. This design decouples business logic from the lock mechanism, and users can independently compile and deploy lock plug-ins without intruding into the core system code.
[0067] 2. Logging module: This module receives information provided by the automatic execution module. It records the locks held by the task, the time point of the preemption, and the preemption event log for deadlock analysis.
[0068] The present invention has the following advantages:
[0069] ① Intelligent resource management: Through resource feature analysis algorithms and multi-dimensional portrait databases, it automatically identifies the read and write characteristics of resources such as hardware devices and memory queues, and dynamically matches the optimal lock strategy (such as automatically allocating atomic locks in high-frequency read and write scenarios). Compared with traditional manual lock management, the risk of lock conflicts is reduced by 90% and resource utilization is increased by 75%.
[0070] ② Real-time breakthrough: The innovative priority preemptive scheduling algorithm allows high-priority tasks to forcibly reclaim low-priority lock resources through the transaction rollback mechanism, completely solving the priority inversion problem. The measured real-time task response delay is millisecond-level, meeting the strict timeliness requirements of industrial control scenarios.
[0071] ③ High-reliability deadlock protection: Distributed graph theory algorithm is used to periodically scan lock waiting relationships, combined with depth-first search (DFS) to achieve millisecond-level circular deadlock detection, and deadlock is resolved through a priority-sensitive transaction rollback mechanism, and the system deadlock rate is close to 0.
[0072] ④Flexible expansion capability: Supports hot-swappable plug-in lock strategies. Users can customize new locks such as distributed locks and segmented locks through standardized interfaces and dynamically load them into the strategy library, significantly improving development efficiency.
[0073] ⑤ Improved development efficiency: Developers only need to mark the task priority tags to achieve zero manual lock coding, shortening the debugging cycle of locks in embedded systems by 80%, significantly reducing the development threshold and maintenance costs of multi-task systems.
[0074] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory. The processor executes the computer program to load the multi-task automatic mutual exclusion lock management middleware according to any one of the embodiments of the present invention.
[0075] Specifically, the electronic device includes: a memory and a processor. The memory is communicatively connected to the processor through a bus. A computer program is stored in the memory and can run on the processor, thereby loading the multi-task automatic mutual exclusion lock management middleware according to any one of the first aspects of the embodiments of the present invention.
[0076] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0077] The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0078] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium, on which a computer program / instructions are stored. When the computer program / instructions are executed by a processor, the multi-task automatic mutual exclusion lock management middleware according to any one of the first aspects of the embodiments of the present invention is loaded.
[0079] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.
[0080] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, devices, electronic devices, storage media, or computer program products. Therefore, the embodiments of the present invention can take the form of all-hardware embodiments, all-software embodiments, or embodiments combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) that contain computer-usable program code.
[0081] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the claims and their equivalents.
[0082] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or terminal device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article, or terminal device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article, or terminal device including the said element.
[0083] The above has introduced in detail a multi-task automatic mutual exclusion lock management middleware provided by the present invention. Specific examples are used in this text to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application. The above embodiments are only the preferred embodiments cited to fully illustrate the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or transformations made by those skilled in the art on the basis of the present invention are within the protection scope of the present invention.
Claims
1. A lock management middleware for multi-task automatic mutual exclusion, characterized in that, include: The resource classification module is used to identify the resource attributes of each task in the current system and generate resource attribute data of each task after the middleware receives the task information sent by the user end; A task priority module is used to determine the priority of tasks based on task information; The lock strategy library module is used to collect system resource status data in real time, and determine the optimal lock for each task based on the system resource status data and the resource attribute data of each task, and bind the optimal lock of each task to the target resource of each task in order of task priority to generate a lock handle; The automatic execution module is used to inject the lock handle into the task context and perform the locking operation.
2. The multi-task automatic mutual exclusion lock management middleware according to claim 1, characterized in that: The resource classification module is also used to identify the resource access mode of each task in the current system, count the number of reads and writes per unit time, and calculate the time consumption of a single operation, so as to obtain the resource attribute data of each task, and store the resource attribute data of each task in the form of a multidimensional vector in a multidimensional resource portrait database, and establish an index for real-time query; the resource attribute data includes resource access mode, read and write type, and operation time type.
3. The multi-task automatic mutual exclusion lock management middleware according to claim 1, characterized in that: The resource classification module is also used to identify resource access patterns of system resources, count the number of reads and writes per unit time, and calculate the time consumption of a single operation to obtain attribute data of system resources, and store the attribute data of system resources in the form of multidimensional vectors in a multidimensional resource portrait database, and establish an index for real-time query; the attribute data includes resource access patterns, read and write types, and operation time consumption types.
4. The multi-task automatic mutual exclusion lock management middleware according to claim 1, characterized in that: The task priority module is also used to: Determine whether the task information contains task priority tag information; If the task information includes task priority tag information, binding the corresponding priority to the task according to the task priority tag information; If the task information does not include the task priority tag information, the priority of the task is determined according to the priority mapping table and the task type of the task, and the corresponding priority is bound to the task.
5. The multi-task automatic mutual exclusion lock management middleware according to claim 4, characterized in that: The task priority module is also used to: when a high-priority task initiates a lock request, compare the priority levels of the requesting task and the current lock-holding task through a dynamic priority mapping table to trigger a preemptive arbitration mechanism; for tasks at the same priority level, dynamically adjust the enhanced FIFO queue through a timestamp sliding window, and the tasks are dequeued in timestamp order; The lock policy library module is also used to: forcibly reclaim the locks held by low-priority tasks according to the preemption arbitration mechanism, and roll back the transactions of low-priority tasks to the memory state of the safe point through the transaction log; for tasks at the same priority level, execute lock resource allocation according to the order of task requests within the window period.
6. The multi-task automatic mutual exclusion lock management middleware according to claim 1, characterized in that: The lock policy library module is also used to dynamically load and parse custom new lock description files added by integrated users in a hot-pluggable manner; the custom new lock description files include lock type information, applicable scenario information, and resource dependency information.
7. The mutex lock management middleware for multi-tasking automatic mutual exclusion according to claim 1, characterized in that The lock management middleware for multi-task automatic mutual exclusion further includes a circular deadlock detection module. The circular deadlock detection module is used to: periodically scan the lock waiting relationships of tasks in the system, construct and maintain a resource allocation directed graph; detect loop structures in the resource allocation directed graph to identify deadlocks; if a deadlock is detected and the deadlock duration exceeds a preset time threshold, trigger an alarm and record lock stack information.
8. The lock management middleware for multi-task automatic mutual exclusion according to claim 7, wherein The circular deadlock detection module is further used to: In the deadlock handling process, obtain the task priorities and lock type information of the processes involved in the deadlock, roll back the transaction to release the tasks occupying the lower-priority locks, and if the rollback fails, send an alarm message to the system monitoring center to forcibly terminate the process and trigger the restart of the tasks occupying the lower-priority locks.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the electronic device executes the computer program, it loads the lock management middleware for multi-task automatic mutual exclusion according to any one of claims 1 to 8.
10. A readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by a processor, it loads the lock management middleware for multi-task automatic mutual exclusion according to any one of claims 1 to 8.
Citation Information
Cited By
Cloud-edge collaborative industrial control network security protection method based on strategy library
CN121396652A