美文网首页
2. Mutual Exclusion

2. Mutual Exclusion

作者: 何大炮 | 来源:发表于2017-08-21 14:15 被阅读0次

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

相关文章

网友评论

      本文标题:2. Mutual Exclusion

      本文链接:https://www.haomeiwen.com/subject/usrurxtx.html