多執行緒程式靠著額外的執行緒在多核心的系統上進行平行運算可以加速計算的進行。由於多執行緒程式有著競賽情況的隱憂,為了保證多執行緒系統的正確性,如何避免資料發生競賽情況是很重要的。 我們在這篇論文中提出了一個以模型為基礎的測試流程。我們用了自己定義的模型產生技術來為多執行緒的系統建立相對應的模型。然後我們會在模型模擬器上測試我們的模型。在模擬過程中,我們設計了一個選擇執行程序的策略來導致資料發生競賽情況。在潛在的競賽情況被發現之後,我們接著分析產生競賽情況模型的程式執行序列。分析的結果會產生對競賽情況有高風險的變數,接著我們會去保護這些變數。我們會找出這些應該被分別存取的變數,然後重新測試,我們就可以定位出程式中的錯誤,然後提出一個建議給程式使用者。
Multi-threaded programming speeds computation up by executing threads in parallel on multi-core. Preventing data race conditions is important to guarantee the correctness of multi-threaded systems. A model-based testing technique for race conditions is proposed in this paper. We construct models for multi-threaded systems in OpenMP with techniques. Then we run test with our strategy on the models with a model simulator. A process execution strategy is designed for inducing data race in simulations. After the potential race condition detected, we will do fault localization by analyzing the execution sequence first. After analyzing, we will protect those chosen variables one at a time. After protecting variables and running tests again, we will localize the fault in original program. Then we can give a suggestion to the program user.