Chapter 4. Synchronization

Never practice two vices at once.

—Tallulah Bankhead

Synchronization plays a crucial role in the design of any distributed application. Inevitably, to accomplish a common task or goal, the processes in a distributed system need to coordinate with one another and avoid stepping on each other's toes. For instance, distributed applications often need to mediate access to limited shared resources, ensure fair access to resources, or prevent a set of processes from coming to a standstill because of competing requests for the same resources.

Synchronizing distributed processes can be challenging. In a nondistributed system in which multiple threads are running, the operating system serves as a centralized manager of all synchronization. In a distributed environment, on the other hand, asynchronous processes run independently at their own pace, and there is no central controller that can manage their activities and interactions. To synchronize processes, we have to rely on designing and building distributed means of cooperation, which can be tricky and error-prone.

Creating your distributed applications with spaces can significantly ease the burden of synchronizing processes. This is largely because synchronization is already built into the space operations themselves. You've already seen the basics of how synchronization works in space-based programming: Multiple processes can read an entry in a space at any time, but when a process wants to update an entry, it has to remove it from the space and thereby gain exclusive access to it first. In other words, coordinated access to entries is enforced by the read, take, and write operations themselves.

Entries and the operations on them give us everything we need to build more complex synchronization schemes. In this chapter, we'll explore useful synchronization techniques that can be implemented using some basic distributed data structures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset