void State_Machine(void) { switch (M_State) { case ST_RX_SETUP: Receive_Setup(); // Receive and decode host Setup Message break; case ST_RX_FILE: Receive_File(); // Receive File data from host break; case ST_TX_ACK: M_State = ST_RX_FILE; // Ack Transmit complete, continue RX data break; case ST_TX_FILE: // Send file data to host WriteStageLength = ((BytesToWrite - BytesWrote) > MAX_BLOCK_SIZE_WRITE)? MAX_BLOCK_SIZE_WRITE:(BytesToWrite - BytesWrote); BytesWrote += Block_Write((BYTE*)(ReadIndex), WriteStageLength); ReadIndex += WriteStageLength; if ((BlocksWrote%8) == 0) Led2 = ~Led2; if (BytesWrote == NumBytes) Led2 = 0; break; default: break; } }
/*### SCATTER FILES #############################################*/ void Scatter_Files(int np, int *proclist, char **ifname, char **ofname, int src, int myProc, int commtag, MPI_Comm comm) { int i; char command[200]; if (myProc != src) { for (i=0; i<np; i++) { if (proclist[i] == myProc) { Receive_File(ofname[i], src, commtag, comm); break; } } } else { for (i=0; i<np; i++) { if (proclist[i] == myProc) { if (strcmp(ifname[i], ofname[i]) != 0) { sprintf(command, "cp -f %s %s", ifname[i], ofname[i]); system(command); } } else Send_File(ifname[i], proclist[i], commtag, comm); } } }