ebook img

NON-BLOCKING ARRAY-BASED ALGORITHMS FOR STACKS AND QUEUES Niloufar Shafiei A ... PDF

180 Pages·2013·2.27 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview NON-BLOCKING ARRAY-BASED ALGORITHMS FOR STACKS AND QUEUES Niloufar Shafiei A ...

NON-BLOCKING ARRAY-BASED ALGORITHMS FOR STACKS AND QUEUES Niloufar Shafiei A thesis submitted to the Faculty of Graduate Studies in partial fulfilment of the requirements for the degree of Master of Science Graduate Programme in Computer Science and Engineering York University Toronto, Ontario December 2007 Abstract Non-blocking shared memory implementations do not employ locks. Thus they provide robustness and reliability. We present two new non-blocking array- basedsharedstackimplementationsandtwonewnon-blockingarray-basedshared queue implementations. We give detailed proofs of correctness and amortized time analyses for the algorithms. In addition, we use the Spin model checker to verify the correctness of our algorithms. Our first stack and queue algorithms use unbounded counter values and our second stack and queue algorithms use bounded counter values. To the best of our knowledge, our stack implementa- tions are the first practical array-based stack implementations and it is the first time that bounded counter values are employed to implement a shared stack and queue. We compare our stack and queue implementations to the popular pro- posed implementations experimentally. Our empirical results show our new stack algorithm is more scalable than Treiber’s stack algorithm and our new queue al- iv gorithm outperforms the queue algorithm of Michael and Scott and performs a little faster than the array-based queue algorithm of Colvin and Groves in both low and high contentions. v Acknowledgements First, I would like to thank my supervisor Professor Eric Ruppert, for his guid- ance, advice, encouragement and support. I am very grateful for his vast contri- butions to this thesis and for the many things that I have learnt from him during my M. Sc. studies. I would also like to thank my committee members, Professors Franck van Breugel, Patrick W. Dymond and Nantel Bergeron for taking the time to read this thesis and giving me valuable comments. Particularly, I would like to thank Professor Franck van Breugel for giving me advice and assisting me in the verification and implementation process. I would also like to thank Com- puter Science Department of York University and Computer Science Department of Amirkabir University for the excellent educational opportunities that I have been offered during my studies. Finally, my special thanks to my family for their unconditional love and support. vi Table of Contents Abstract iv Acknowledgements vi Table of Contents vii 1 Introduction 1 1.1 Arrays versus Linked Lists . . . . . . . . . . . . . . . . . . . . . . 5 1.2 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.3 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2 Problem Definition 14 2.1 Stack and Queue Specifications . . . . . . . . . . . . . . . . . . . 14 2.2 Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.3 Contention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 vii 2.4 Collect Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3 Related Work 20 3.1 Related Work on Stack Implementations . . . . . . . . . . . . . . 20 3.2 Related Work on Queue Implementations . . . . . . . . . . . . . . 25 4 Array-based Stack Algorithms 33 4.1 Non-blocking Stack Algorithm Using Unbounded Counter Values . 33 4.2 Non-blocking Stack Algorithm Using Bounded Counter Values . . 56 4.3 Time Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5 Array-based Queue Algorithms 85 5.1 Non-blocking Queue Algorithm Using Unbounded Counter Values 85 5.2 Non-blocking Queue Algorithm Using Bounded Counter Values . 100 5.3 Time Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 6 Model checking 154 6.1 The Spin Model Checker . . . . . . . . . . . . . . . . . . . . . . . 154 6.2 Verification of Our Concurrent Stack and Queue Algorithms . . . 155 7 Implementations 159 7.1 Comparison of Concurrent Stack Algorithms . . . . . . . . . . . . 160 viii 7.2 Comparison of Concurrent Queue Algorithms . . . . . . . . . . . 163 8 Conclusion 167 Bibliography 170 ix 1 Introduction In an asynchronous distributed shared-memory system, processes communicate through shared data structures. Mutual exclusion is the traditional way to im- plement shared data structures in distributed systems. Locks are used in mutual exclusion to allow only one process to access the same part of shared memory at a time. However the lock-based approach to implementing shared data structures cannot really take advantage of all processes. Only one operation at a time can enter the critical section, the code to access and modify the shared data structure that is protected by a lock, and all the other processes attempting to access the shared data structure simultaneously must wait. Thus, any delay of a process in the critical section can cause performance problems. Possible sources of delay include process pre-emptions, page faults, remote memory accesses, and cache misses. Furthermore, a lock-based algorithm is not reliable and fault-tolerant: if a process crashes while executing the critical section, other operations that want 1 to execute the same critical section wait forever and the entire system can stop making progress. Lock-based algorithms may also cause priority inversion: a low priority process may be pre-empted while holding a lock on a shared object and a high priority process that requires the same shared object has to wait due to the lower priority process. Locks might even cause deadlock: If processes must acquire locks on two or more resources, deadlock is possible if those locks are not acquired in the same order. Another way to implement shared data structures in distributed systems is the non-blocking (also called lock-free) approach. Non-blocking algorithms guar- antee some process completes its operation in a finite number of steps, no matter whether or not other processes have halted or have been delayed. So, in a non- blocking data structure, the system as a whole is always making progress. An implementation is wait-free if each process always makes progress and completes its operation in a finite number of steps. If an implementation is non-blocking, delays and failures of individual pro- cessesdonotpreventprogressofthesystemasawhole. Non-blockingshareddata structures provide fault-tolerance and reliability. Unlike lock-based data struc- tures, processes can access and modify the shared data structure at the same time. Thus, non-blocking objects are immune to deadlock when faced with pro- 2 cessfailures, andofferrobustperformanceevenwhenfacedwitharbitraryprocess delays. That is why a lot of work has been done in recent years on non-blocking data structures. Non-blocking algorithms are often complex and subtle and it is not so easy to design a fast non-blocking distributed algorithm and verify its correctness. In a non-blocking implementation, a process may not complete its operation indefinitely due to the progress of other processes. So, starvation of processes is possible in a non-blocking implementation. In a wait-free implementation, processes do not starve because each process completes its operations after a finite number of its own steps. Compared to non-blocking algorithms, wait-free algorithms usually have significant overhead. A system is said to be asynchronous if each process has its own independent clock,sothestepsofdifferentconcurrentoperationscanbeinterleavedarbitrarily. The thesis will focus on an asynchronous shared-memory distributed system of multiple processes. A shared data structure is called an object. Linearizability is a correctness condition for shared objects [12]. An execution of concurrent operations on a shared object is linearizable if each operation applied by concurrent processes takes effect instantaneously at some time between its invocation and its response. 3

Description:
Most existing distributed algorithms for shared stacks and queues are link- . and an enqueue operation can pair up and eliminate each other if the
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.