230 likes | 409 Views
Adaptive and Efficient Mutual Exclusion. By Hagit Attya and Vita Bortnikov. Presented by:. Mian Huang. Talk Outline. Introduction Related Work Preliminaries Algorithms Future Work. Introduction. Mutual Exclusion Problem Limitations of most of current solutions
E N D
Adaptive and Efficient Mutual Exclusion By Hagit Attya and Vita Bortnikov Presented by: Mian Huang
Talk Outline • Introduction • Related Work • Preliminaries • Algorithms • Future Work
Introduction • Mutual Exclusion Problem • Limitations of most of current solutions • Adaptive solutions • Contributions of this Paper - Adaptive algorithms using only read and write operations that achieve: • Remote step complexity O(k), where k is actual contention • System response time O(log k) • Space complexity • Long-lived renaming - O(nN) where N is the range of processes’ names • One-shot renaming – O(n2) where n is total # of processes
Related Work • Dijkstra1965. • Lamport 1987. A fast mutual exclusion algorithm • Alur and Taubenfeld 1992. Results about fast mutual exclusion • Step complexity could not be adaptive for any asynchronous Algo. • Choy and Singh 1994. Adaptive solutions to the mutual exclusion problem • Without assuming hardware-provided synchronization primitives • Performance to be governed solely by # of contending processes
Preliminaries • Adaptive algorithms • Point contention (strongest) • Interval contention • Renaming algorithms(getName/releaseName) • Long-lived • One-shot • Non-wait-free algorithms
Preliminaries (Cont.) • The Computation Model A standard asynchronous shared-memory model of computation. • n processes • Multi-writer multi-reader registers • shared primitives – atomic read/write registers
Preliminaries(Cont.) • The Complexity Measures • Remote step complexity - Max# of shared memory operations performed by a process, where a wait is counted as a single operation • Remote memory references - A stronger version of the above parameter - Assumption of local spin • System response time - The time interval between subsequent entries into the critical section, where a time unit is the min execution interval in which each active process performs at least one step
How the Basic Algorithm Works • Architecture • An adaptive long-lived non-wait-free k-renaming • An adaptivetournament tree for mutual exclusion • What it does • A process gets a name in a range of size O(k) using long-livedrenaming • Uses this name to enter an adaptive tournament tree for mutual exclusion • The winner of the tournament tree enters the critical section
Adaptive Tournament Tree Long-Lived Renaming The Basic Algorithm Critical Section Figure 1. Algorithm Structure
Non-Wait-Free Renaming • The basic building block • Filter with an entrypoint and an exitpoint • success or fail • Modified filter improves time complexity • An array of n entries • Each entry contains a pointer to achain of filters/a chain • The name that the process receives is the index of the chain it wins • A chain of filters • Concatenated one after the other • Process succeeds • Process fails - If failed in the r’th filter of the l’th chain, then it skips the next r-1 chains and tries to win in the (l+r)’th chain
Non-Wait-Free Renaming r’thr-1 2 1 0 0 0 0 Filters Chains 0 l (r-1) l + r n-1 Figure 2. The next chain calculation
Private variables lastFilter : interger Procedure getName() //get a new name l := 0 Index := -1 Repeat l := l + index +1 //calculate next chain to enter <result,index> := executeChain(l) Until result = win lastFilter := startFilter[l] + index Return l+1 Procedure releaseName(name) // release a name startFilter[name] := lastFilter + 1 Procedure executeChain(l) // access chain l filters := Chains[l][startFilter[l]] curr := 0 while (true) if executeFilter(Filters[curr]) = success then if curr > 0 and Filters[curr-1].c then return <win, curr> else curr ++ else return <lose, curr> The code of Basic Algorithm Figure 3. Adaptive long-lived non-wait-free k-renaming with unbounded memory
The code of Basic Algorithm(Cont.) Procedure executeFilter(filter) // access a specific filter • if filter.turn then return fail • filter.turn :=id • if filter.d then return fail // there is a winner - fail • wait until filter.b or filter.turn id or filter.d • if filter.d then return fail • if filter.turn = id then filter.b := true // try to succeed • if filter.turn id then // failing in the filter • filter.c := true • filter.b := false • return fail • else // succeeding in the filter • filter.d := true • return success Figure 3. Adaptive long-lived non-wait-free k-renaming with unbounded memory
The Procedures – Basic Algorithm • getName() • Obtains a new name • Invokes procedure executeChain () • executeChain (l) • Returns a pair: <winor lose, the index of the last accessed filter in the chain> • Executes a filter of a chain • executeFilter(filter) • Modification of the filter suggested by Choy and Singh • Shared variables • releaseName(name)
Result of the Algorithm- Filter Properties The following properties ensure that exactly one process eventually remains in the chain and wins it. • Safety If k processes enter the filter, then at mostk/2 processessucceed in it. • Progress If one or more processes enter the filter, then at least one process succeeds in it. Modified filter will also have the property: • Time complexity Some process succeeds in the filter O(1) time units after the first process enters it
Result of the Algorithm- Chain Properties An execution interval of a process pi includes one iteration of enter, critical section, and exit • If the point contention during pi‘s execution interval is k, then pi wins in chain l <= k-1 • A process wins some chain within O(k) steps Remote step complexity • If k processes enter the chain, then some process wins the chain in log k + 2 filters • Some process wins the chain within O(logk) time units after the chain became busy, where k is the point contention of the winner’s execution interval System response time
An Adaptive Tournament Tree • What is it • Is anunbalanced binary tree • Constructed fromlog N complete binary tree of exponentially growing sizes(1,2,22,… nodes) – N is size of name space • Connected by a single path of nodes • Embedded two-process mutual exclusion algorithmwith O(1)remote steps - Yang and Anderson
The leaves are numbered from left to right. An adaptive Tournament Tree A process with a name in the range 0, …, k-1 climbs at most 2logk +1 nodes Root 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Complexity of the Basic Algorithm • Renaming Algorithm + Tournament Tree • Step complexity: O(k) + O(logk) O(k) • Time complexity: O(logk) + O(logk) O(logk)
Bounding The Number of Filters • Basic idea • The number of filters in a chain is bounded by recycling previously used filters • Solutions • A chain of only 2Nfilters are used cyclically • The process that exits from the critical section detects “slow” processes and promotes them to enter the critical section • In addition, the scan also initializesthe recycled filters • Space Complexity of the Renaming Algorithm • Is dominated by the size of array Chains – O(nN)
Reducing The Space Complexity • Basic idea • one-shot f(n)-renaming • Complexity of the n-renaming Algorithm • System response time O(logk) • Remote step complexity O(k’), where k’ is the interval contention • Space complexity O(n log n) • Space Complexity of the Mutual Exclusion Algorithm • O(n2) – n times the range of names
Summary of Result Talbe1 . Comparison with previous adaptive mutual exclusion algorithms
Future Work • Improve the remote step complexity of the algorithm or show that it is optimal • Prove a lower bound on the system response time • Design an algorithm with O(k)remote memory references and O(logk) system response time