Weak Memory Code Inspection for Busy-Wait Infinite Loops
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current model inspection technologies fail to predict the number of execution times of busy-wait loops in rearranged code under weak memory ordering architectures, leading to an infinite number of execution flows and making it impossible to identify potential issues.
Innovation Solution
A code inspection method that utilizes a blocking mark to identify busy-wait loops in source code, allowing for the determination of infinite loops by checking if a read operation in a loop iteration cannot reference an unreferenced write operation, thereby reducing the need to inspect all execution flows.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If model inspection technology is used to inspect rearranged memory access execution flow under weak memory ordering architecture, then code correctness can be verified, but infinite quantity of execution flows are generated due to inability to predict busy-wait loop execution times
Solution Approach 1:
The patent applies preliminary action by inserting blocking marks at specific locations in the source code before execution. These blocking marks are placed at loop entry points and write operation locations to pre-establish control mechanisms that will limit execution flow generation during the inspection process
Solution Approach 2:
The patent uses blocking marks as intermediary elements between the inspector and the busy-wait loops. These marks act as mediators that allow the inspector to control and limit the execution of loops without directly interfering with the normal program flow, thereby reducing the infinite execution flows problem
2Reliability
If all execution flows are inspected to ensure code correctness, then comprehensive verification is achieved, but inspection time becomes unlimited due to infinite busy-wait loop iterations
Solution Approach 1:
The inspector performs preliminary actions by detecting blocking marks in the code before full inspection. This allows the inspector to identify and control busy-wait loops in advance, preventing infinite execution during the inspection process and ensuring the inspection can be completed in limited time
Solution Approach 2:
The patent applies partial action by focusing inspection efforts on specific critical sections marked with blocking marks rather than uniformly inspecting all code paths. This selective approach ensures comprehensive verification of critical areas while avoiding the time cost of inspecting all possible execution flows
Data Source
AI summary
This application discloses a code inspection method, including: obtaining first source code and test code, where the first source code includes a blocking mark, the first source code corresponds to a plurality of threads, the plurality of threads have at least one shared memory; generating, based on the first source code and the condition indicated by the test code, a plurality of execution flows under the weak memory ordering architecture for the plurality of threads that operate a same shared memory, where a busy-wait loop exists in a target execution flow that includes the blocking mark and that is in the plurality of execution flows; and determining the busy-wait loop in the target execution flow as an infinite loop if a read operation executed by a target thread in one iteration of the busy-wait loop cannot reference an unreferenced write operation.


