Chapter 3
Chapter 3
Chapter 3
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Sistemas Distribuídos<br />
Relógios Lógicos (Lamport 1978)<br />
Sérgio Duarte<br />
Mestrado em Engenharia Informática<br />
Um relógio lógico (de Lamport) é um contador monótono crescente<br />
usado para atribuir uma estampilha temporal a um evento.<br />
Cada processo pi, mantém um relógio lógico Li actualizado da seguinte forma:<br />
‣ LC1 :<br />
‣ Se e é um evento executado em pi, faz-se:<br />
‣ LC2 :<br />
Li := Li + 1 [ alternativamente, Li := Li + x , x > 0 ]<br />
C(e) := Li, com C(e) a estampilha temporal atribuída ao evento e<br />
‣ Se e = esend(m), usa-se a regra anterior e envia-se (m,t), com t =C(send(m))<br />
‣ Se e = ereceive(m,t), faz-se Li=max(Li, t) e, de seguida, aplica-se a regra LC1<br />
Sistemas Distribuídos<br />
Relógios Lógicos : Exemplo<br />
1 2 3<br />
a c<br />
1<br />
b<br />
Sérgio Duarte<br />
3 4<br />
d e<br />
f<br />
(c) 2011 - DI / FCT / UNL<br />
Mestrado em Engenharia Informática<br />
5<br />
g<br />
(c) 2011 - DI / FCT / UNL