Beruflich Dokumente
Kultur Dokumente
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..
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; } }
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.