Ricart–Agrawala algorithm: Difference between revisions

Content deleted Content added
mNo edit summary
Algorithm: Making the algorithm more clear and reducing the terminology
Line 4:
=== Terminology ===
* A ''site'' is any computing device which is running the Ricart-Agrawala Algorithm
* ForThe any''requesting onesite'' requestis ofthe site which is requesting entry into the critical section:.
** The ''requestingreceiving site'' is theevery other site which is requestingreceiving entrythe request intofrom the criticalrequesting sectionsite.
** The ''receiving site'' is every other site which is receiving the request from the requesting site.
* ''ts'' refers to the local timestamp of the system according to its [[logical clock]].
 
=== Algorithm ===
Requesting Site:
* Sends a message to all sites. This message includes the site's name, and the current timestamp of the system according to its [[logical clock]] (''which is assumed to be synchronized with the other sites'')
* A requesting site <math>P_i</math> sends a message <math>request(ts, i)</math> to all sites.
 
Receiving Site:
* Upon reception of a <math>request(ts, i)</math> message, the receiving site <math>P_j</math> will immediately send a timestamped <math>reply(ts, j)</math> message if and only if:
:** <math>P_j</math>the receiving process is not requestingcurrently orinterested executingin the critical section OR
:* the receiving process has a lower priority (''usually this means having a later timestamp)
** <math>P_j</math> is requesting the critical section but sent a request with a higher timestamp than the timestamp of <math>P_i</math>
* Otherwise, <math>P_j</math>the receiving process will defer the <math>reply</math> message. This means that a reply will be sent only after the receiving process has finished using the critical section itself.
 
Critical Section:
* SiteRequesting <math>P_i</math>site enters its critical section only after receiving all <math>reply</math> messages.
* Upon exiting the critical section, <math>P_i</math>the site sends all deferred <math>reply</math> messages.
 
=== Performance ===