Mutual exclusion over network – pattern?

I want to do the following:

I have a number of computers. On each computer a programm will run. There is no centralized server.

The program can choose by defined criteria to give another computer specified data. While doing so, the other computer should not do the same. (A sort of 2 way synchronize)

Let’s make an example. (C1 .. Cn are the programs running on different computers)

C1 sends C2 updated data. While processing is active, C2 should not ask C1 for update something else.

The idea was:

C1 sends a message to C2: PauseExecution()
C1 sends to C2 items to be processed (updates some data on C2)
C1 sends a message to C2: ResumeExecution().
C2 sends a message to C1: PauseExecution()
C2 sends to C1 items to be processed (updates some data on C1)
C2 sends a message to C1: ResumeExecution().
But now the biggest problem arises.

If C1 sends a message to C2 to Pause, and C22 sends at the same tiem a message to C1 to Pause, both would block.

There is no centralized server / shared memory for keeping a semaphore.

Is there another pattern which can be used, so that n computers will not block?

So this question is about algorithmic exclusion.

Or is there another workaround for this problem, if no semaphore or mutex can be used?

2

The keyword here is distributed transaction. Hit google with that and you’ll find plenty of possible ways, but as Karl already said a two-phased commit is the traditional solution.

Given that there is no central authority, it makes sense to assume nothing about the other systems until you get an acknowledgment from them that they agree to your plans (first phase). Only when all the involved systems agree do they perform the transaction / data sending / whatever (second phase).

Depending on the amount of transfers you have and the number of systems involved, you have to take a closer look at possible cases of starvation though. Let’s say that systems A and B continually want to send data to system C and more or less bombard it with first-phase commits, i.e. they ask system C if it is willing to accept a file from them. If you now want a system D to send a file to C, it might never get an acknowledgment depending on the specific implementation details’ fairness.

There are a number of well-known algorithms for this. Ricart-Agrawala appears to have the fewest issues. Basically, instead of commanding another system to pause execution, you pause your own execution, send a request, and wait for a reply before unpausing. Then you send another message when you’re done executing the critical section. The different algorithms have different ways of avoiding deadlock.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật