slang-users mailing list

[2011 Date Index] [2011 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] fork with shared memory


Hi again,

I managed to send information between different processes using the isis functions in fork_socket.sl. However, one more question remains unsolved to me: Is there a possibility to create something like a "probe_obj" function, such that I only "recveive" an object if it was acutally sent to me? Functions for receiving objects like fread (and the according higher level functions) always wait until something is actually received.

Below is a small example, which should illustrate how the function "probe_obj" should work:

-------------------------------
require("fork_socket.sl");

() = new_slave_list();
slv = fork_slave(&function_eventually_sends_an_object);

tic;
forever
{
   if (probe_obj(slv))
   {
       variable obj = recv_obj(slv);
       message("Object successfully received!");
       break;
   }

   if (toc > 100.)
   {
       message("Process timed out ...");
       break;
   }

   sleep(0.1);
}
-------------------------------


Cheers,
Thomas


On 11/10/2011 07:45 PM, John E. Davis wrote:
Thomas Dauser<thomas.dauser@xxxxxxxxxxxxxxxxxxxxxxxxxx>  wrote:
[...]
Now my question: Is there any possibility to do this with shared memory,
such that the child process changes the value of the "test"-variable?
I found things like shmget() and vfork() for other programming
languages, but I did not find any slang-function, which can solve this
issue.
 [...]
Below is a simple example slsh script that creates a process to ROT13
a character string and send the encoded string back to the parent
process.  Although it does not define any explicit message interface,
it should give you an idea of what is involved at the lowest level.  A
much higher level interface exists in the isis
<http://space.mit.edu/cxc/isis/>  source code in a file called
fork_socket.sl.  This file is not isis-specific and should run in any
slang interpreter.  It is used to perform parallel processing on a
multicore CPU.


[2011 date index] [2011 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]