📄 gossip_nodo2.c
字号:
/****************************************************************
* TU Eindhoven, Eindhoven, The Netherlands, June 2004
* Author : Jose Prats
* (jprats@step.es)
* Purpose : Test transmission and reception between mmips nodes
* and shared memory node
****************************************************************/
#include "mtools.h" /* Needed for: mprintf() */
#include "stdcomm.h" /* Needed for: sc_receive() and sc_send() */
#ifdef CC_I386 /*gcc on i386 */
#include <stdio.h>
#include <stdlib.h>
#endif
/* Enable the following line to generate extra info using mprintf(). */
#define DEBUG
#define ADDR_TO_NODE3TO1 0x0001
#define ADDR_TO_NODE3TO2 0x0101
char *my_data = (char*)0x03; // Data in local memory
char *remote_data = (char*)0x8003; // Data in remote memory
char *my_remote_addr = (char*)0x8040; // Data in remote memory
char *final_result_addr = (char*)0x8050; // Final result in remote memory to write
int received;
int data;
int i;
int confirm;
void main (void)
{
/*mprintf("\nStarting proc N2\n");
my_remote_addr[0] = my_data[0] + remote_data[0]; //Reading from local and remote memory and
//then writing in the remote memory
mprintf("\nN2 my_data: %d\n", my_data[0]);
mprintf("\nN2 remote_data: %d\n", remote_data[0]);
mprintf("\nN2 sum: %d\n", my_remote_addr[0]);
sc_receive(&received, sizeof(int)); //Waiting for the result from NODE2
mprintf("N2 received:%d \n", received);
data = *my_remote_addr + received; //Read from remote memory and sum the data received from NODE2
final_result_addr[0] = data; //Write final result in the remote memory
mprintf("\nN2 data to send: %d\n", final_result_addr[0]);
confirm = 1; //To solve consistency problems, NODE3 sends a "data ready"
//confirmation to NODE1 and NODE2
sc_send(ADDR_TO_NODE3TO1, &confirm, sizeof(int));
mprintf("\nN2 confirmation to N0: %d\n", confirm);
sc_send(ADDR_TO_NODE3TO2, &confirm, sizeof(int));
mprintf("\nN2 confirmation to N1: %d\n", confirm);
mprintf("\nN2 end\n");*/
mprintf("N2 valor:%d \n", i);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -