Synergy User Manual and Tutorial. - THE CORE MEMORY
Synergy User Manual and Tutorial. - THE CORE MEMORY
Synergy User Manual and Tutorial. - THE CORE MEMORY
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Synergy</strong> <strong>User</strong> <strong>Manual</strong> <strong>and</strong> <strong>Tutorial</strong><br />
// Double array sent to worker<br />
double dblArr[MAX] = {10000.1234, 2000.567,<br />
300.89, 40.0, 5.01};<br />
// String sent to worker<br />
char sendMsg[50] = "A text string.\0";<br />
// Struct sent to worker<br />
struct person bob = {"Bob",<br />
"123 Broad St.",<br />
"Pliladelphia", "PA", "19124",<br />
20, "brown", 70.5, "red"};<br />
// Get host machine name<br />
gethostname(host, sizeof(host));<br />
// Open tuple spaces<br />
printf("Master: Opening tuple spaces\n");<br />
// Open problem tuple space<br />
tsd = cnf_open("problem",0);<br />
// Open result tuple space<br />
res = cnf_open("result",0);<br />
printf("Master: Tuple spaces open complete\n");<br />
// Get number of processors<br />
P = cnf_getP();<br />
printf("Master: Processors %d\n", P);<br />
// Put semaphore in problem tuple space<br />
// Set name to sem<br />
strcpy(tpname,"sem");<br />
// Set length for semaphore<br />
tplength = sizeof(int);<br />
// Place the semaphore signal in problem ts<br />
printf("Master: Putting semaphore\n");<br />
status = cnf_tsput(tsd, tpname, &sem, tplength);<br />
// Put int num in ts<br />
// Set length of send entry<br />
tplength = sizeof(int);<br />
// Set name of entry to num<br />
strcpy(tpname, "D_num");<br />
printf("Master: Putting '%d' Length %d Name %s\n",<br />
num, tplength, tpname);<br />
// Put entry in tuple space<br />
status = cnf_tsput(tsd, tpname, numPtr, tplength);<br />
printf("Master: Put '%d' complete\n", num);<br />
// Put long lnum in ts<br />
// Set length of send entry<br />
tplength = sizeof(long);<br />
// Set name of entry to lnum<br />
strcpy(tpname, "D_lnum");<br />
printf("Master: Putting '%ld' Length %d Name %s\n",<br />
lnum, tplength, tpname);<br />
// Put entry in tuple space<br />
status = cnf_tsput(tsd, tpname, lnumPtr, tplength);<br />
printf("Master: Put '%ld' complete\n", lnum);<br />
141