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 />
}<br />
printf("Master: The sum total is: %d\n", sumTotal);<br />
// Calculate correct answer with math formula<br />
calcSum = (N*(N+1))/2;<br />
printf ("Master: The formula calculated sum is: %d\n", calcSum);<br />
// Compare results<br />
if(calcSum == sumTotal)<br />
printf("Master: The workers gave the correct answer\n");<br />
else<br />
printf("Master: The workers gave an incorrect answer\n");<br />
// Insert negative integer tuple as termination signal<br />
printf("Master: Sending terminal signal\n");<br />
// Set length of entry<br />
tplength = (1) * sizeof(int);<br />
// Set entry value<br />
sendArr[0] = -1;<br />
// Set entry name<br />
sprintf(tpname, "A%d", N+1);<br />
// Send entry to tuple space<br />
status = cnf_tsput(tsd, tpname, sendArr, tplength);<br />
printf("Master: Finished sending terminal signal\n");<br />
// Terminate program<br />
printf("Master: Terminated\n");<br />
cnf_term();<br />
The following is the tuple space “sum of n integers” worker program implemented by<br />
receiving work in chunks:<br />
#include <br />
#include <br />
main(){<br />
// Variable declarations<br />
int tsd;<br />
// Problem tuple space identifier<br />
int res;<br />
// Result tuple space identifier<br />
int *recdPtr;<br />
// Pointer to recd array<br />
int sendSum = 0;<br />
// Sum of numbers received<br />
int *sendPtr = &sendSum; // Pointer to sendSum<br />
int status;<br />
// Return status for tuple operations<br />
int tplength;<br />
// Length of ts entry<br />
int chunk_size;<br />
// Size of recdPtr<br />
int i;<br />
// Index counter<br />
char tpname[20];<br />
// Identifier of ts entry<br />
char host[128];<br />
// Host machine name<br />
// Get host machine name<br />
gethostname(host, sizeof(host));<br />
// Open tuple spaces<br />
168