Tmk_distribute(data, size) is used to read size number of bytes from the
address specified by data and writes the same bytes at the same address on
all other TreadMarks processes, i.e. it is used to create identical local,
private memory entries in all processes. The Tmk_distribute()-call sends a
message to all other TreadMarks processes and waits until it has received
an ack message from everyone before returning (retransmitting a message
repeatedly, if necessary, until the last ack is received).
The user include file Tmk.h defines the following:
#define TMK_DISTRIBUTE(variable) \
Tmk_distribute((char *)&variable, sizeof(variable))
code example (from TreadMarks quicksort application):
typedef struct GlobalMemory {
TaskElement TaskStack[MAX_TASK_QUEUE];
unsigned TaskStackTop;
unsigned NumWaiting;
unsigned A[MAX_SORT_SIZE];
int TaskStackLock;
} GlobalMemory;
GlobalMemory *gMem;
...
gMem = (GlobalMemory *)Tmk_malloc(sizeof(GlobalMemory));
TMK_DISTRIBUTE(gMem);
so the previous line is expanded to
Tmk_distribute((char *)&gMem, sizeof(gMem)) ;
(This information is taken from TreadMarks source code version 0.10.1)
Regards, Alex Scherer (ETH Zurich, Switzerland)