同步 (計算機科學)

維基百科,自由的百科全書

計算機科學中, 同步(synchronization)是指兩個不同但有聯繫的概念:進程同步與數據同步。進程同步指多個進程在特定點會合(join up)或者握手使得達成協議或者使得操作序列有序。數據同步指一個數據集的多份拷貝一致以維護完整性。常用進程同步原語實現數據同步。

線程或進程同步[編輯]

Figure 1: 3個進程同時訪問共享資源(臨界區)

多個線程(或進程)要執行同一個特定的不可重入的程序代碼塊(稱為臨界區),這就需要適當的並發控制同步技術[1]。否則,可能會發生競態條件


Figure 2: 一個進程訪問共享資源基於某種同步技術。[2]

另一種同步要求產生於特定的操作順序,如應該先買機票然後登機。[3]

同步還需處理:

經典同步問題[編輯]


參見[編輯]

參考文獻[編輯]

  1. ^ Gramoli, V. More than you ever wanted to know about synchronization: Synchrobench, measuring the impact of the synchronization on concurrent algorithms (PDF). Proceedings of the 20th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. ACM: 1–10. 2015 [2016-08-15]. (原始內容存檔 (PDF)於2016-03-04). 
  2. ^ Janssen, Cory. Thread Synchronization. Techopedia. [23 November 2014]. (原始內容存檔於2020-10-19). 
  3. ^ Fatheisian, Halleh; Rosenberger, Eric. Synchronization. Department of Computer Science, George Mason University. [23 November 2014]. (原始內容存檔於2015-01-28). 

外部連結[編輯]