進程同步02--臨界區問題(Critical Section Problem)

臨界區問題:
假設現有n個進程(P1, P2,…,Pn), 每個進程都如圖所示, 擁有一個可以修改共享變量(變量, 文件, 數據庫表等)的臨界區(critical section), 要求任何一個進程在臨界區執行時, 其他都不能執行.
這裏寫圖片描述

正式定義:

  1. Mutual exclusion(互斥): When a thread is executing in its critical section, no other threads can be executing in their critical sections.
  2. Progress(前進): If no thread is executing in its critical section, and if there are some threads that wish to enter their critical sections, then one of these threads will get into the critical section.
  3. Bounded waiting(有限次等待): After a thread makes a request to enter its critical section, there is a bound on the number of times that other threads are allowed to enter their critical sections, before the request is granted.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章