Sie sind auf Seite 1von 15

Hardware supports for mutual Exclusion

Lince Sebastian S4Mca Roll: 26

Mutual exclusion ?

How it solved ?

Concurrency Control
Pessimistic approaches Optimistic approaches

Pessimistic approaches
It tends to assume worst possible case and to defend against it by rather austere measures that often end up limiting concurrency

Pessimistic Solution
Block everything that could possibly interfere, so their should nothing to interfere.. Update the global variable Unblock

Optimistic approaches
Optimistic approaches are based on assumption that no or few conflicts are likely to experienced by any particular user of shared recourse

Optimistic Solution
Read the value of the global variable and prepare the tentative local update based on that value the global variable remains accessible to others users Compare the current value of global variable to the value used to prepare the tentative update. If value of global variable is unchanged, the tentative local update to global variable , discard the tentative update..

Disable/ enable interrupt (P)


The basic idea is quite simple ..it follows the principle that shared resources must be exclusively obtained by the process wishing to enter its critical section subsequently released for the use of others

while (true) { /* disable interrupts */ /* critical section */ /* enable interrupts */ /* remainder */ }

Test and set instruction(P)


In this assigning the global variable to FREE (0)when the guarded shared resource is available Check the status of global variable. If s=0, then resource is available If s=1, denotes busy state. Initially s will be 0

The function of the test and set instruction may be presented as the following function: boolean testset (int i) { if (i == 0) { i = 1; return true; } else { return false; } }

Compare and swap instruction(o)


Updating the global variable in the presence of concurrent activity and without any support from OS or the interrupt mechanism. Here copying the value of global variable to local space and using the value to calculate the tentative update.

The value of global variable is not disturbed by any other process during the calculation of the update, the tentative update is applied to the global variable and thus made it permanent. Independent from interrupt mechanism . Can used in multiprocessor environment. Running process is always capable of making progress towards its completion.

No Claps please Thank you

Das könnte Ihnen auch gefallen