Distributed Computing Pearls. Gadi Taubenfeld

Чтение книги онлайн.

Читать онлайн книгу Distributed Computing Pearls - Gadi Taubenfeld страница 9

Distributed Computing Pearls - Gadi Taubenfeld Synthesis Lectures on Distributed Computing Theory

Скачать книгу

(2) either A2 or B2 are present (but not both). Why can Bob not simply check these two conditions only once, and if both hold, conclude that Alice will buy a loaf of bread and go to sleep?

       Answers:

      1. (a) It satisfies requirement #2, but does not satisfy requirement #1. (b) It satisfies requirement #1, but does not satisfy requirement #2. (c) It satisfies requirement #1, but does not satisfy requirement #2.

      2. No. In such a case, it is possible that both Alice and Bob will buy bread at the same time. To see why this claim is valid, assume that the order of those two actions is replaced (that is, line 1 appears after line 3), and consider the following scenario: initially, no message is sent. Alice arrives home, checks and sees that there are no messages from Bob. Then, before she manages to send a message, Bob arrives. Bob also notices that there are no messages from Alice, and so he sends the messages acquire2 and acquire1. He checks again, and since there are no messages from Alice, he goes and buys bread. Alice continues. She sends the message acquire1 and then checks and finds that B2 is present and A2 is not, she also goes and buys bread.

      3. Because Alice might be in the middle of executing Step 1, after sending the message acquire1. If at that point Bob checks the two conditions and goes to sleep, Alice will complete Step 1, gives priority to Bob in buying bread, and will get stuck in Step 2.

      CHAPTER 3

       A Tale of Two Lovers

      In many distributed systems, sometimes there is a need to ensure that two things happen together or not at all. The two lovers problem, which again involves two-person interactions, demonstrates the difficulty of reaching such an agreement when communication is restricted to sending and receiving messages which can get lost.

      The problem is for two lovers to decide on the exact time for a meeting. The problem is described as follows.

      Two lovers have to coordinate a time for meeting at a romantic restaurant for dinner. If they simultaneously arrive at the restaurant, they are assured to end up marrying and live happily ever after. If only one arrives, their relationship will come to an end. As a result, neither lover will arrive without a guarantee that the other will arrive at the same time. In particular, neither lover will arrive without communicating first with the other.

      The lovers can communicate only by sending messages. However, every time a message is sent it stands some chance of getting lost.

      The problem is to find an algorithm that allows the lovers to coordinate a time for a meeting even though some messages may get lost.

      To prevent a situation where both lovers, fearing that their relationship will come to an end, simply refrain from arriving, it is required that if everything goes smoothly and no message is lost, the lovers must be able to coordinate a time for a meeting. If enough messages are lost, however, the lovers may refrain from arriving, but both must do so.

      To see the corresponding synchronization problem for computing systems, consider two computers (the two lovers) that are trying to perform a database transaction over an unreliable communication line, and need to decide whether to commit or abort the transaction.

      A specific example would be the problem of transferring $100 between two bank accounts which reside in different banks. Two clerks (the lovers), who are responsible for the accounts, need to update that balance in the two accounts simultaneously. They should do it, even though their computers are connected by an unreliable communication channel.

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4S0DRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA agEoAAMAAAABAAIAAAExAAIAAAAeAAAAcgEyAAIAAAAUAAAAkIdpAAQAAAABAAAApAAAANAALcbA AAAnEAAtxsAAACcQQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykAMjAxODowNTowOSAxMDox NToyMwAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAIyqADAAQAAAABAAAK3gAAAAAAAAAGAQMAAwAA AAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIA BAAAAAEAACvNAAAAAAAAAEgAAAABAAAAS

Скачать книгу