Hacker News new | ask | show | jobs
by Twey 30 days ago
Message-passing doesn't necessarily involve naïvely copying the data around. If you have access to shared memory then you can pass a pointer; the only thing you really need to ‘pass’ is the capability to access the message data. This is how seL4 does it, for example.

Of course if you don't have shared memory then you have to copy anyway :) And because of CPU caching architecture the benefits of having an owned copy of the data can sometimes outweigh the cost of copying it, even if shared memory is available.

1 comments

Ok if you define message passing that broadly then I would agree, but I think that definition is also broad enough to bring in the downsides of shared memory such as deadlocking.

We're also now talking about patterns which are common in other contexts, but I don't have a problem with that. io_uring for example - is it shared memory, asynchronous, message passing, or all three (probably yes)?

Message-passing systems have always had the capability to deadlock: if you have two processes that each wait for a message from the other, you have deadlock, just the same as two threads trying to take a lock. So long as the memory is either read-only or else transferred, not shared (the shared ^ writeable rule) you don't get hit with race conditions, which are the problem with shared memory.