2. Mutual Exclusion

The general situation: N processes execute instruction sequence concurrently.

Mutual Exclusion

It is a Safety Property means Instructions from critical sections of 2 or more processes must never be interleaved.

Requirement:

  1. No deadlocks.
  2. No starvation
  3. Efficiency

To guarantee the Mutual exclusion:
Here we use the Bakery Algorithm.

Semaphores

There are 3 conditions for the definition:

  1. processes agree on a variable S operating as a flag to indicate synchronization condition
  2. an atomic operation P on S: for pass
    P(s): [if S > 0, then S -= 1;]
  3. an atomic operation V on S: for release
    V(s): [S := S + 1]

Then, the S is called the semaphores.

3 kinds of Semaphore types exist:

  1. Binary Semaphore

Restricted to [0,1] or [False, True]
There are sufficient to create other type of semaphores

  1. General Semaphore(counting Semaphores)
    Increment or decrement the Semaphore By one.

  2. Quantity Semaphore
    Increment or decrement value for the semaphores

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容