An apology for the long post but this is not a simple issue and hence not a simple question. So I am looking into ways to integrate Pharo with Unreal to bring some nuclear powered graphics to Pharo and make us first class citizents to 2D and 3D world. https://www.unrealengine.com/what-is-unreal-engine-4 2) Will I be limited by the fact that the VM currently does not multithread or cannot use multithreading libraries ? ( I have no intention of using multithreading but some handling of process access to the data may be necessary to make sure data is safe from concurent modification) 3) Is there anything else I should be aware of as common pitfalls for such implementation ? |
First a disclaimer, I do not have a lot of experience with inter-process communication (I have a bit, though), and no direct experience with mmaped files.
Communication through mmaped files, or shared memory in general, is inherently asynchronous, so lack of multiple OS threads should not be a blocker if the protocol is well designed.
I expect you would need some sort of out-of-band signalling so polling is not necessary. Pipes or sockets could be used for that, slower for data transfer (more copying), but they are compatible with select() and other OS polling features. You could build synchronisation primitives on top of sockets, too. But building things like mutexes would be inefficient. I guess you could use pipes for all the message sending and memory management, and shared memory for bulk data transfer. Large number of messages could be handled in batch this way:
Not very efficient for messages that depend on one another. But I am not sure you could do better without things like interprocess semaphores or a FFI.
|
Pipes are actually slower than sockets (local UNIX sockets that is) and I dont need sockets if I am using shared memory. I could create an event que and not allow direct access to shared memory, this way I make sure everything happens in order and in sequence. This way I can make sure multiple writes and reads dont happen at the same time. This could be a first implementation and if the need arises for multi threading then I can revise this design but frankly I rather stay away from multithreading and other complexities and keep this simple and easy to learn and code. On Sun, Jan 17, 2016 at 10:19 PM David Allouche <[hidden email]> wrote:
|
> On 17 Jan 2016, at 22:18, Dimitris Chloupis <[hidden email]> wrote: > > Pipes are actually slower than sockets (local UNIX sockets that is) and I dont need sockets if I am using shared memory. > > I could create an event que and not allow direct access to shared memory, this way I make sure everything happens in order and in sequence. This way I can make sure multiple writes and reads dont happen at the same time. This could be a first implementation and if the need arises for multi threading then I can revise this design but frankly I rather stay away from multithreading and other complexities and keep this simple and easy to learn and code. You will still need a signalling channel so either side knows that it has new commands to process without having to poll. |
the way I see it at least, polling is not a problem, Graphics work on frame loop, that means actions that have to repeat per frame , Unreal objects are constructed around this functionality , same way we have a World cycle that drawOn: methods work , then of course you have event loops etc. A signal mechanism would have been a callback functionality but frankly I dont think its necessary. My goal is to bring unreal closer to pharo , so that means I will use similar functionality to Morphic and Bloc for drawing to make easy for pharo guis to port to unreal because unreal is not only capable of 3d but also 2d graphics. So the idea is when the frame loops starts , execute first what Unreal has to execute , then read a message qeue where pharo will register messages very similar to pharo messaging . I may allow Pharo to assign messages to specific frames. Those messages will call functions/methods of the Unreal API. Of course it can work vice versa so that Unreal becomes aware of the Pharo enviroment and callback pharo mehods etc and even Blender methods (for asset creation) and I could even hook on this message que many other applications essential to build a common language that apps and libraries can talk to each other without depending on specific implementation and wrapper APIs. On Mon, Jan 18, 2016 at 10:14 AM David Allouche <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |