28.10.2014 Views

Synergy User Manual and Tutorial. - THE CORE MEMORY

Synergy User Manual and Tutorial. - THE CORE MEMORY

Synergy User Manual and Tutorial. - THE CORE MEMORY

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Synergy</strong> <strong>User</strong> <strong>Manual</strong> <strong>and</strong> <strong>Tutorial</strong><br />

int tplength;<br />

char tpname[20];<br />

char host[128];<br />

// Length of ts entry<br />

// Identifier of ts entry<br />

// Host machine name<br />

// Get host machine name<br />

gethostname(host, sizeof(host));<br />

// Open tuple spaces<br />

printf("Worker: 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("Worker: Tuple spaces open complete\n");<br />

// Set tpname to B<br />

strcpy(tpname,"B");<br />

// Read matrix B from tuple space<br />

status = cnf_tsread(tsd, tpname, B, 0);<br />

// Print matrix B<br />

if(N 0){<br />

// Check termination signal<br />

if (!strcmp(tpname, "A-term")){<br />

printf("Worker: Recieved the terminal signal\n");<br />

// Replace the terminal signal in problem ts<br />

status = cnf_tsput(tsd, tpname, rows, tplength);<br />

// Free memory for rows<br />

free(rows);<br />

// Terminate worker<br />

printf("Worker: Terminated\n");<br />

cnf_term();<br />

}<br />

// Get number rows in this chunk from last index<br />

177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!