分布式Process之三: Time and Ordering
来源:互联网 发布:php session共享 编辑:程序博客网 时间:2024/05/18 16:57
1 two approach to order events across process
1)synchronize global clock, use absolute time
2)use logical time-stamp
本文关注第二个方法。
2 Happen-Before关系
定义逻辑关系 happen-before (" -> ") among pairs of events,三条规则
1)同一process A -> B if time(A) < time(B) local time
2) send(M) - > receive(M)
3) transitivity: A -> B and B -> C, then A -> C
类比java 线程 的happen before规则:
1)同一线程,顺序的指令,前面的指令 -> 后面的指令
2)通过同步器:
对一个锁的unlock -> 同一个锁后续的lock
对volatile 变量的写 -> 后续的读
3)transitivity: A -> B and B -> C, then A -> C
是一种partial order 因为不是所有的event都有happen-before关系,没有happen-before关系的event 叫 concurrent event。
A -> B or B -> A or A ||| B
3 Lamport timestamp
用sequence number给每个事件赋timestamp,并在消息中携带自己的integer clock
Each process uses a local counter (clock) which is an integer• Initial value of counter is 0
– A process increments its counter when a send or an instruction happens at it. The counter is assigned to the event as its timestamp.
– A send (message) event carries its timestamp
– For a receive (message) event the counter is updated bymax(local clock, message timestamp) + 1
A -> B 则 => LT(A) < LT(B) 但是反过来不成立,
LT(A) < LT(B) = > A -> B or A|||B
也就是说用Lamport stamp不能区分出 是A -> B还是 A|||B,只能排除不会是B -> A
4 Vector timestamp
每个process不是维护一个自己的integer clock, 而是它每一个process的最新sequence number
发消息前increment自己的 clock, 然后把整个vector include在消息里
收到消息的process, 先increment自己的clock,然后用message里的vector timestamp, 更新自己vector,(取每个process最新的clock)
1). On an instruction or send event at process i, it increments only its ithelement of its vector clock
2). Each message carries the send-event’s vector timestamp Vmessage[1…N]
3). On receiving a message at process i:Vi[i] = Vi[i] + 1Vi[j] = max(Vmessage[j], Vi[j]) for j ≠ i
VT(A) < VT(B) iif A -> B
Not (VT(A <= VT(B)) and Not (VT(B) <= VT(A)) iif A ||| B
也就是说,vector里,有的分量是A大,有的是B大,则A和B是Concurrent的
- 分布式Process之三: Time and Ordering
- Linear time ordering
- Python之process(三)
- Time, Clocks, and the Ordering of Events in a Distributed System
- Note: Time clocks and the ordering of events in a distributed system
- Time, Clocks, and the Ordering of Events in a Distributed System(译)
- 【每周论文】Time, Clocks, and Ordering of Events in a Distributed System
- Memory Ordering at Compile Time
- Memory Ordering at Compile Time
- Memory Ordering at Compile Time
- 分布式process总结之二:Mutual Exclusion
- Guava之Ordering
- CPU-Cache-and-Memory-Ordering
- LINQ之路14:LINQ Operators之排序和分组(Ordering and Grouping)
- Effective C#之Item 26: Implement Ordering Relations with IComparable and IComparer
- The Building Blocks- Components of EA Part 2- Process, People, Network and Time
- LeetCode OJ 之 Best Time to Buy and Sell Stock III (买卖股票的最佳时间 - 三)
- Google Guava学习之Ordering
- PCA技术降维
- (小笔记) 动态添加textview
- JBoss Access log的配置
- leetcode -- Letter Combinations of a Phone Number -- 重点
- angular debounce throttle
- 分布式Process之三: Time and Ordering
- 基于多尺度对比度x射线图像增强算法
- SPIKE&FUZZING 模糊测试(收藏)
- CentOS7.1安装Oracle 12.1客户端以及cx_Oracle
- spark on yarn启用动态分配
- 数据结构之二叉搜索树
- IOS 基础框架名称
- C++学习笔记(初级篇)——Lambda表达式
- Wifi控件的使用