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 />

}<br />

// Send reply back to master<br />

// Set size of entry<br />

tplength = sizeof(sendMsg);<br />

// Set name to host<br />

strcpy(tpname, host);<br />

printf("Worker: Put '%s' Length %d Name %s\n",<br />

sendMsg, tplength, tpname);<br />

// Put response in result tuple space<br />

status = cnf_tsput(res, tpname, sendMsg, tplength);<br />

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

// Get struct person bob<br />

else if(!strcmp(tpname, "D_bob")){<br />

// Read problem from problem tuple space<br />

tplength = cnf_tsget(tsd, tpname, &bob, 0);<br />

// Record the data type received<br />

strcpy(sendMsg, tpname);<br />

// Display the data<br />

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

printf(" %s\n", bob.name);<br />

printf(" %s %s, %s %s\n", bob.address,<br />

bob.city, bob.state, bob.zip);<br />

printf(" %d %s %f %s\n", bob.age, bob.eyes,<br />

bob.height, bob.hair);<br />

printf(" Length %d Name %s\n", tplength, tpname);<br />

// Send reply back to master<br />

// Set size of entry<br />

tplength = sizeof(sendMsg);<br />

// Set name to host<br />

strcpy(tpname, host);<br />

printf("Worker: Put '%s' Length %d Name %s\n",<br />

sendMsg, tplength, tpname);<br />

// Put response in result tuple space<br />

status = cnf_tsput(res, tpname, sendMsg, tplength);<br />

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

}<br />

// Get string<br />

else if(!strcmp(tpname, "D_msg")){<br />

// Read problem from problem tuple space<br />

tplength = cnf_tsget(tsd, tpname, recdMsg, 0);<br />

// Record the data type received<br />

strcpy(sendMsg, tpname);<br />

// Display the data<br />

printf("Worker: took %s '%s'\n", tpname, recdMsg);<br />

// Send reply back to master<br />

// Set size of entry<br />

tplength = sizeof(sendMsg);<br />

// Set name to host<br />

strcpy(tpname, host);<br />

printf("Worker: Put '%s' Length %d Name %s\n",<br />

sendMsg, tplength, tpname);<br />

// Put response in result tuple space<br />

status = cnf_tsput(res, tpname, sendMsg, tplength);<br />

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

147

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

Saved successfully!

Ooh no, something went wrong!