首页 > 未分类 > 存储一致性之弱一致性(Weak Consistency)

存储一致性之弱一致性(Weak Consistency)

2011年5月6日 发表评论 阅读评论

弱一致性WC(Week Consistency)模型的提出,是人们观察到大多数并行程序排定几个进程对数据存取次序时都需要使用同步操作;而在同步操作之间,一个进程所进行的数据存取操作次序对其他进程会是不可见的。例如,某进程对同步变量实施加锁后进入临界段,已在临界段内所做的存储器数据读写操作,由于互斥性其他进程根本看不到,更不用说读写操作次序了。

只是在此进程解锁退出临界段,其对共享变量所做的修改结果应立即被其他进程所看到,基于上述观察,我们可放宽对非同步读写操作次序的限制而只对同步存储器操作施加顺序一致性,来解决存储器一致性问题。

Dubois等(1986)定义这种使用同步变量来部分地定义的一致性模型为弱一致性:

weak consistency, by saying that it has three properties:

  1. Accesses to synchronization variables are sequentially consistent.
  2. No access to a synchronization variable is allowed to be performed until all previous writes have completed everywhere.
  3. No data access ( read or write ) is allowed to be performed until all previous accesses to synchronization variables have been performed.

中译为:

弱一致性,它有三个属性:

a. 对同步变量的访问是顺序一致的;

b. 在所有先前的写操作完成之前,不能访问同步变量;

c. 在先前所有同步变量的访问完成前,不能访问(读或写)数据。

弱一致性要求同步访问(访问要求执行同步操作)是顺序一致的。在一个同步访问可以被执行之前,所有以前正常的数据访问必须完成。在一个正常的数据访问可以被执行之前,所有以前同步访问必须完成。这实质上把一致性问题留给程序员决定。在一个同步操作之后,内存将立即是一致的。

第一点指出所有过程以相同顺序看到对同步变量进行的所有操作。即,如果进程P1调用synchronize(S1),与此同时进程P2调用synchronize(S2),那么,实际效果好象是synchronize(S1)发生在synchronize(S2) 之前,或synchronize(S2)发生在synchronize(S1) 之前,但所有进程看到同样的顺序。实际上,一个同步变量的访问将立即被广播出去。在广播发送结束之前,任意其他进程不能访问其他同步变量。

第二点指出访问同步变量“刷新了管道”,它强迫在所有拷贝上完成所有程序中的写操作。其中包括正在执行的、部分完成的或已经在某些本地拷贝上完成却未在其它拷贝上完成的写操作。同步访问开始前,应保证先前所有的写操作已完成。在更新共享数据后做同步操作,进程可迫使将新值传遍到该存储的所有其它本地拷贝。

第三点指出访问一般(即非同步)变量,不管是读是写,只有在所有前序的同步操作结束后方可进行。在读共享数据前做同步操作,可以保证进程读到最新值。

从应用的角度来说,软件和存储器的协议指出,只有当访问同步变量时,存储器才需更新;新的写操作可以在前一写操作完成之前开始,在一些情况下可完全避免写。当然,此协议加重了编程人员的负担,但换来了优越的性能。

不同于以往的存储器模型,它是对一组操作的一致性约束,而不是单独的读或写。当很少单独而基本上以簇的形式(短时间内有很多访问,每一访问时间都不长)访问共亨变量时,这个模型更为有用。

弱一致性存在这样的问题,即当访问同步变量时,存储器并不知道这是因为进程已完成对共享数据的写操作还是要开始读共享数据。因此,它必须执行这两种情况要求的操作,也就是它要确保本地启动的写操作都已完成(即发送到其他所有的拷贝),同时还要收集其他机器执行的写操作。

弱一致性的示意图如下:



本文作者: Sigma    在新浪微博关注SigmaSigmaWeibo    RSS订阅本博客
本文链接: http://www.sigma.me/2011/05/06/weak-consistency.html
本博客采用知识共享署名—非商业性-禁止演绎使用3.0协议进行许可,转载请保留作者和原文链接。

  1. 2019年1月9日04:40 | #1

    I actually wanted to post a comment so as to appreciate you for those fabulous tips and hints you are sharing here. My extensive internet lookup has at the end been recognized with reasonable strategies to talk about with my contacts. I would admit that many of us website visitors are unequivocally lucky to dwell in a wonderful website with many outstanding individuals with beneficial pointers. I feel extremely blessed to have discovered the weblog and look forward to many more enjoyable times reading here. Thank you again for a lot of things.

  2. 2019年1月10日02:23 | #2

    I in addition to my buddies were taking note of the good thoughts found on the blog and then quickly came up with a terrible suspicion I had not expressed respect to the site owner for those secrets. My women ended up consequently warmed to see all of them and have now undoubtedly been loving them. Appreciation for getting really thoughtful and for using variety of fantastic subject areas millions of individuals are really wanting to discover. My sincere apologies for not saying thanks to you earlier.

  3. 2019年1月10日19:13 | #3

    I simply needed to say thanks yet again. I am not sure the things I would have followed in the absence of these recommendations provided by you over my situation. This was a scary matter in my circumstances, however , taking a look at this well-written technique you treated the issue forced me to leap for happiness. I’m happy for this guidance and thus have high hopes you find out what an amazing job that you’re doing training others thru your webpage. Most likely you haven’t come across any of us.

  4. 2019年1月11日13:18 | #4

    I simply wanted to say thanks again. I do not know the things I would’ve achieved without the actual opinions documented by you directly on such question. It was actually a fearsome difficulty in my view, but spending time with the very well-written avenue you solved that took me to weep for contentment. I will be thankful for the assistance and sincerely hope you realize what an amazing job you have been carrying out teaching other individuals via your webblog. I am certain you have never met any of us.

  5. 2019年1月11日14:03 | #5

    I am glad for writing to make you understand of the useful encounter our daughter developed viewing yuor web blog. She realized a lot of things, including what it is like to have an excellent coaching nature to let many more quite simply fully understand a variety of complicated topics. You really surpassed readers’ expected results. Many thanks for providing the valuable, dependable, revealing and even fun guidance on this topic to Kate.

  6. 2019年1月12日08:28 | #6

    I would like to express my love for your generosity giving support to visitors who really need guidance on this particular content. Your personal dedication to getting the solution around appeared to be definitely effective and has without exception made workers much like me to arrive at their dreams. Your insightful help and advice denotes so much to me and even more to my office colleagues. Thank you; from all of us.

  7. 2019年1月13日05:05 | #7

    I have to express appreciation to you just for rescuing me from this particular crisis. After checking through the search engines and coming across thoughts that were not pleasant, I was thinking my life was done. Existing without the solutions to the problems you have solved as a result of your entire guideline is a crucial case, as well as the kind that could have badly affected my career if I had not noticed your blog post. That competence and kindness in playing with all areas was tremendous. I don’t know what I would have done if I had not discovered such a solution like this. It’s possible to at this point look forward to my future. Thank you very much for your professional and sensible guide. I will not hesitate to refer your blog post to any individual who should have tips on this matter.

  8. 2019年1月14日01:07 | #8

    My spouse and i felt very comfortable when Chris managed to do his investigations with the precious recommendations he gained while using the weblog. It’s not at all simplistic to just possibly be giving freely helpful tips which often some other people have been trying to sell. And we all recognize we now have the writer to appreciate because of that. The illustrations you made, the straightforward site menu, the relationships your site help promote – it’s everything remarkable, and it’s really leading our son in addition to us believe that this matter is cool, which is exceptionally serious. Thank you for everything!

  9. 2019年2月8日04:46 | #9

    I just want to say I’m very new to blogging and site-building and certainly liked this blog. Almost certainly I’m going to bookmark your blog . You certainly come with awesome articles and reviews. Thanks a bunch for sharing with us your web-site.

  10. 2019年2月9日21:30 | #10

    Nice post. I find out something much harder on distinct blogs everyday. It will always be stimulating to learn content using their company writers and practice a specific thing there. I’d choose to apply certain with the content on my own weblog regardless of whether you don’t mind. Natually I’ll supply you with a link on the internet weblog. Appreciate your sharing.

  11. 2019年2月15日02:41 | #11

    What blogging site can I start a blog and actually get viewers or subscribers?

  12. 2019年2月15日19:46 | #12

    I need as much suggestions as possible. The more the better. I haven’t had the chance to sit and really go over the process. Again, looking for some answers where I can start blogging immediately..

  13. 2019年2月16日04:44 | #13

    What happens to files when my wordpress space upgrade expires?

  14. 2019年2月16日10:51 | #14

    Just got a Blogger account, it works good, but how do I find different users blogs I like with search. I remember there is a way, but I am not seeing it now. Thanks for your help..

  15. 2019年2月16日11:58 | #15

    Thanks, I’ve recently been looking for info about this subject for ages and yours is the best I have located so far.

  16. 2019年2月16日12:06 | #16

    I think one of your adverts caused my web browser to resize, you may well want to put that on your blacklist.

  1. 本文目前尚无任何 trackbacks 和 pingbacks.

无觅相关文章插件,快速提升流量