tag:blogger.com,1999:blog-5246027334551923738.post5913465963863651059..comments2022-11-23T03:37:05.086-08:00Comments on armstrong on software: Why I don't like shared memoryJoe Armstronghttp://www.blogger.com/profile/13842732706414838736noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-5246027334551923738.post-57035368805152239812008-10-01T08:21:00.000-07:002008-10-01T08:21:00.000-07:00Joe, I atually think having shared memory is a gre...Joe, <BR/>I atually think having shared memory is a great thing. But i also agree with the comment above. Especially with problem #7 A single faulty process can broadcast corrupt data to all other processes, easily invalidating their local data, as illustrated by computer viruses.<BR/><BR/>Cheers, <BR/>JamesAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-44821458250155410682006-09-10T21:53:00.000-07:002006-09-10T21:53:00.000-07:00You may find it interesting that in the field of s...You may find it interesting that in the field of static analysis and code verification - shared memory is often reduced to a message passing protocol. It seems that what you really dislike is the usage of blocking. Yes, blocking is the root of many software evils, but is very common in message passing systems too. Maybe you should write a column about that?<br /><br />More comments following:<br Yaarhttps://www.blogger.com/profile/09280567613091088643noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-974919784919274112006-09-07T18:49:00.000-07:002006-09-07T18:49:00.000-07:00re genneth's comment, "You might also point toward...<i>re genneth's comment, "You might also point towards the recent paper that surveyed recent language trends." Can you post a link?</i><br /><br />I believe this is the reference: http://www.info.ucl.ac.be/~pvr/bookcc.htmlUnknownhttps://www.blogger.com/profile/12668489479062353375noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-58107660992150770872006-09-06T22:48:00.000-07:002006-09-06T22:48:00.000-07:00Just a note about the (deeply flawed) traffic ligh...Just a note about the (deeply flawed) traffic light analogy that some people seem to have missed: <br /><br />The supposition that we (or a thread) might all be looking at the same traffic light overlooks the fact that only one person at a time can be looking at it (particularly in a single-processor machine). Suggesting that shared state often resolves itself to certain constants (like the Unknownhttps://www.blogger.com/profile/02337720287930596272noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-35503420060427274252006-09-06T20:05:00.000-07:002006-09-06T20:05:00.000-07:00Is Mnesia a shared memory system?
If you need to ...Is Mnesia a shared memory system?<br /><br />If you need to find data, how do you do this (efficiently) in a non-shared memory system? Especially if it is more data than can fit on one machine (and even more if it needs to be persistent)?Unknownhttps://www.blogger.com/profile/08416634655419603358noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-42655186992245634972006-09-06T08:10:00.000-07:002006-09-06T08:10:00.000-07:00Threads, processes, machines are all part of the e...Threads, processes, machines are all part of the execution of a model. They aren't the model.<br /><br />Similarly, pipes, sockets, shared memory, in memory calls are also part of the execution of message passing. They aren't the model too.<br /><br />For example, a bank teller waits on a queue of customers. They only do something when the queue is not empty. To me that means that each object Unknownhttps://www.blogger.com/profile/17566791487903817499noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-89851280271595555162006-09-05T21:36:00.000-07:002006-09-05T21:36:00.000-07:00re Joe's comment, "Surely you need shared memory t...re Joe's comment, "Surely you need shared memory to implement a messaging system?"<br /><br />Perhaps, but not necessarily. You could use sockets, for example, which would allow you to run things in parallel on a cluster as well as a SMP. Second, assuming you did use shared memory to implement the messaging system, you'd only need to get it right in one place. Get the messaging system right (or, Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-50157537167096334872006-09-05T21:34:00.000-07:002006-09-05T21:34:00.000-07:00By the way, good article. Looking forward to many...By the way, good article. Looking forward to many more, though it's probably not necessary to use simplified analogies to explain Erlang concurrency. Most programmers seriously studying Erlang right now are most likely early adopters and real hackers capable of understanding the intracacies of the language on its own terms, or by <a href="http://defmacro.org/ramblings/concurrency.html">analogy<Byronhttps://www.blogger.com/profile/06426920239047764399noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-77273477081696772332006-09-05T16:35:00.000-07:002006-09-05T16:35:00.000-07:00Joe (not Armstrong) said...
"Surely you need share...Joe (not Armstrong) said...<br />"Surely you need shared memory to implement a messaging system?"<br /><br />No; in fact shared memory systems are implemented in terms of message passing at the hardware level. That's what a cache coherence protocol does.<br /><br />----<br />Several people mentioned the cost of message copying. Since Erlang is based on a pure-functional core language, message Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-45261993509650476842006-09-05T15:58:00.000-07:002006-09-05T15:58:00.000-07:00I don't understand Problem 5 - it seems like a res...I don't understand Problem 5 - it seems like a restatement of what Problems 2 and 3 describe more specifically. In fact, I don't even like its wording - it seems to say that if you don't use shared memory, then tasks never have to wait for each other. That's certainly not true. Message-passing systems certainly have tasks blocked waiting for results from other tasks.<br /><br />Otherwise, I agreeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-5456562024623239282006-09-05T15:12:00.000-07:002006-09-05T15:12:00.000-07:00I do not share memory with other trafficants when ...I do not share memory with other trafficants when waiting for a traffic light - the light is not forcing us all to stop state,<br />it is a message (photons)!<br /><br />I can ignore it and drive anyway. And ambulances are even allowed to do just that!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-29428753331883604302006-09-05T12:15:00.000-07:002006-09-05T12:15:00.000-07:00I have a few questions about this article.
Proble...I have a few questions about this article.<br /><br />Problem 3: <i>"A typical page size might be in the range 8-64KB - with a page size of 8K you might only want to protect a single byte, but you are forced to protect a minimum of 8KBytes."</i><br /><br />Leaving aside that on 32-bit architectures this is usually 4k, what do you mean that someone is forced to protect at least a page? I can haveAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-1956490418678744902006-09-05T11:29:00.000-07:002006-09-05T11:29:00.000-07:00Enjoyed the article; thanks.
@things-like-image-p...Enjoyed the article; thanks.<br /><br />@things-like-image-processing: this is obviously a case where message passing probably wouldn't be the best solution. <br /><br />One of the issues discussed was the disconnect between page size and space-I-want-to-lock size; with image processing your processes will generally be working on different areas, so I don't see it as being as much of an issue.<brAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-76213389472658241072006-09-05T11:04:00.000-07:002006-09-05T11:04:00.000-07:00@Ben & Joe: Seems like the salient point regardin...@Ben & Joe: Seems like the salient point regarding the traffic light is that 1), it is read-only, as far as the drivers are concerned (drivers can't change its state), and 2) it can be read by all drivers in its lane concurrently without need for message passing or non-shared-state constructs.<br /><br />A better example might be the entire system of traffic lights, rather than any single one. Byronhttps://www.blogger.com/profile/06426920239047764399noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-1375101626475049082006-09-05T10:10:00.000-07:002006-09-05T10:10:00.000-07:00Most of the above problems can be avoided by the u...Most of the above problems can be avoided by the use of consensus operators, such as compare-and-swap.<br /><br />You may be interested in investigating lock free data structures.<br /><br />That said, lock free structures do require careful design.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-79379039335763977382006-09-05T08:20:00.000-07:002006-09-05T08:20:00.000-07:00No no no - Ben is wrong
If I drive at a red traffi...No no no - Ben is wrong<br />If I drive at a red traffic light<br />at 7*10^4 Km/sec the red light will<br />appear green due to the doppler shift.<br /><br />So some people will see red other green, depending upon the speed.<br /><br />So there is no shared state, <br />eveybody has a different idea and they cannot agree.Joe Armstronghttps://www.blogger.com/profile/13842732706414838736noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-78898751523439134622006-09-05T07:59:00.000-07:002006-09-05T07:59:00.000-07:00It's funny -- in principle I agree with you, altho...It's funny -- in principle I agree with you, although, since my work tends to be more in things like embedded image processing, copying massive amounts of data doesn't seem like such a hot idea. Still, for most purposes, I'm on your side.<br /><br />The thing that bugs me, and I wish you would leave out, is the attempt to justify it with weak "the world is like this" metaphors.<br /><br />Things Unknownhttps://www.blogger.com/profile/14610516076295063011noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-20809585407259088922006-09-05T07:35:00.000-07:002006-09-05T07:35:00.000-07:00Surely you need shared memory to implement a messa...Surely you need shared memory to implement a messaging system?<br /><br />As far as I can tell you would have to allocate to each process a message queue which would have to be shared among other processes to allow message posting.<br /><br />Is there some other way of doing it and if not, don't some of the mentioned evils of shared memory apply to messaging itself?Unknownhttps://www.blogger.com/profile/14548951628324291027noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-86691528566887396592006-09-05T07:01:00.000-07:002006-09-05T07:01:00.000-07:00I have a question to do with memory usage and the ...I have a question to do with memory usage and the cost of memory copies. <br /><br />Often processes work on huge amounts of data (e.g. image and signal processing) and it isn't feasable to copy the data from process to process.<br /><br />How do we organize work done by several processes on these large chunks of data given limited memory resources?Unknownhttps://www.blogger.com/profile/17194542106915327611noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-24001856600749058462006-09-05T06:00:00.000-07:002006-09-05T06:00:00.000-07:00A much better article than the last one; I think a...A much better article than the last one; I think a reasonable level to pitch things is to imagine a Java/C++ programmer who works on "enterprise" systems. Myself, a member of the choir already, isn't about to be unduly swayed. Someone who needs a metaphor to understand message passing isn't going to benefit either.<br /><br />You might also point towards the recent paper that surveyed recent Anonymoushttps://www.blogger.com/profile/02376760053977600605noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-22690016270623560882006-09-05T05:28:00.000-07:002006-09-05T05:28:00.000-07:00This is a great article. You really convinced me h...This is a great article. You really convinced me how wrong shared memory model could be. Anyway, message passing with independent memory space fits the rule of good engineering and design: minimal mechanism and maximum functionality.<br /><br />One of the important thing is: it scales!黄涧石https://www.blogger.com/profile/00374234948204424471noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-77697942648472872002006-09-05T05:07:00.000-07:002006-09-05T05:07:00.000-07:00But even with message passing you can have dead-lo...But even with message passing you can have dead-locks. Message queues can fill up and leave you in a blocked state.If you now have some interdependencies, you have a dead-lock. Been there recently.<br /><br />But I still think that MP is better than shared memory, even if you have nice mechanisms like software transactional memoryAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-27128410677988056392006-09-05T04:15:00.000-07:002006-09-05T04:15:00.000-07:00Great article. I generally agree with your conclus...Great article. I generally agree with your conclusions about how awkward and error prone shared memory model is - yet your physics digression I suspect to be not adequate. Shared memory, when mapped to physisc, does not mean that we introduce two objects existing both at the same time and in the same place, because sharing memory region does not create seperate, yet coupled, views of its contentsUnknownhttps://www.blogger.com/profile/09185257878066845657noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-27611184772016665482006-09-05T02:44:00.000-07:002006-09-05T02:44:00.000-07:00I accept the First Law of Concurrency, that the wa...I accept the First Law of Concurrency, that the way to keep your sanity in concurrent programming is to have <b>No Shared Data</b>. But working against this on a distributed platform there are requirements for such things as 1) no single point of failure; 2) allocation of work to available resources; 3) aggregation of related real-time events.Hal Snyderhttps://www.blogger.com/profile/10630622510875987916noreply@blogger.comtag:blogger.com,1999:blog-5246027334551923738.post-65138453948940602912006-09-05T02:21:00.000-07:002006-09-05T02:21:00.000-07:00There is an alternative to locking large blocks of...There is an alternative to locking large blocks of memory at a time, in suitably low-level languages - manual locking. Here you acquire a semaphore or mutex from the operating system or other reliable API that can guarantee atomic locks/unlocks. To the API itself, the lock you acquire has no particular semantics.<br /><br />The locking is accomplished at a highly granular level by explicitly Anonymousnoreply@blogger.com