Re: Tmk_distribute
Denis Beaumont (beaumont@pasteur.fr)
Fri, 29 Aug 1997 08:27:15 -0400
Francisco Machado wrote:
>
> Can someone please help me out in figuring out the behaviour of
> Tmk_distribute ? I read the message posted sometime ago about it, but I still
> need help. The question arises in tsp.c (the Travelling Salesman example that
> comes with TMK source).
>
> /* BEGIN SHARED DATA */
> GlobalMemory *global = NULL;
> /* END SHARED DATA */
>
> int StartNode, TspSize, NodesFromEnd;
>
> Both TspSize and global are global variables. And in the main function
> the following appears
>
> (...)
>
> global = (GlobalMemory *) Tmk_malloc(sizeof(GlobalMemory);
>
> (...) initialization of TspSize
>
> TMK_DISTRIBUTE(TspSize);
>
> (...) Initialization of global
>
> TMK_DISTRIBUTE(global);
>
> What is the difference in the usages of TMK_DISTRIBUTE ?
>
> When are data merely copied to the same variable in all the processes ?
>
> When are they placed in shared memory, visible and modifiable by all the
> processes ?
>
> Thank you for any answers
>
> Francisco Pereira
Shared data are in fact static data pointers to data located in a "mmap"
area.
The static data have same addresses for all processes, and the "mmap"
area starts at the same address for all processes (proc 0 creates a
"mmap" area and gives the starting address and the length of this area
to the others processes to let them create an identical "mmap" area)
TMK_DISTRIBUTE() tells all processes that (the address of) a static
pointer is used for sharing memory (located in mmap)
Shared memory (that is mmap) is updated when you call Tmk_lock_acquire()
or Tmk_barrier()
Denis Beaumont