void dothereprs() { boost::thread* thr[Globals::threads_num]; for (int i = 0; i < Globals::threads_num; ++i) thr[i] = new boost::thread(Slave(i)); for (int i = 0; i < Globals::threads_num; ++i) { thr[i]->join(); delete thr[i]; } }
AROS_UFH3(LONG, SlaveEntry, AROS_UFHA(STRPTR, argPtr, A0), AROS_UFHA(ULONG, argSize, D0), AROS_UFHA(struct ExecBase *, SysBase, A6)) { AROS_USERFUNC_INIT Slave( SysBase ); return 0; AROS_USERFUNC_EXIT }
int sc_main(int ac, char *av[]) { sc_signal<bool> data_ready; sc_signal<bool> data_ack; sc_signal<int> data; sc_clock clock("CLOCK", 10, SC_NS, 0.5, 0.0, SC_NS); proc1 Master("MasterProcess", clock, data_ack, data, data_ready); proc2 Slave("SlaveProcess", clock, data_ready, data, data_ack); sc_start(); cout << "SIMULATION COMPLETED AT TIME " << sc_time_stamp() << endl; return 0; }
/* Main entry point */ int HandledCommand(dbref player, dbref loc, char *command) { dbref curr, temp; if(Slave(player)) return 0; if(strlen(command) > (LBUF_SIZE - MBUF_SIZE)) return 0; if(OkayHcode(player) && HandledCommand_sub(player, player, command)) return 1; if(OkayHcode(loc) && HandledCommand_sub(player, loc, command)) return 1; SAFE_DOLIST(curr, temp, Contents(player)) { if(OkayHcode(curr)) if(HandledCommand_sub(player, curr, command)) return 1; #if 0 /* Recursion is evil ; let's not do that, this time */ if(Has_contents(curr)) if(HandledCommand_contents(player, curr, command)) return 1; #endif } return 0; }
int main ( int argc, char *argv[] ) { omp_set_num_threads(omp_get_max_threads()); //Control number of input parameter if(argc<3) { printf("ERROR MISSING DIR PATH IN/OUT \n"); return 1; } //MPI vars int error = 0; // mi restituisce gli errori mpi int nproc = 0; // numero processori totali int myid = 0; // id singolo processore //init MPI error = MPI_Init(&argc, &argv); //init MPI Comm error = MPI_Comm_size(MPI_COMM_WORLD, &nproc); error = MPI_Comm_rank(MPI_COMM_WORLD, &myid); //check directory char * dirIn; char * dirOut; char * istant; dirIn = (char *) malloc(500*sizeof(char )); dirOut = (char *) malloc(500*sizeof(char )); istant = (char *) malloc(100*sizeof(char )); strcpy(dirIn,argv[1]); strcpy(dirOut,argv[2]); strcat(dirIn,"/"); strcat(dirOut,"/"); //printf("I'm %d of %d\n",myid,nproc); // read number of json file in input dir int numFile = 0; numFile = readDirectoryNum(dirIn); //create file list structure char ** list; list = (char **) malloc(numFile*sizeof(char*)); for(int i=0;i<numFile;i++) list[i] = (char *) malloc(200*sizeof(char)); // read list file in input directory readDirectory(dirIn,list,numFile); if(myid == 0) { printf("\n"); printf("GILLESPIE HT v 1.0 \n"); printf("Gillespie algo high throughput software\n"); printf("https://github.com/EricPascolo/GillespieHT\n"); printf("Created by Eric Pascolo (set 2014)\n"); printf("\n"); if(nproc>1) printf("\tParallel Run with %d slave\n",nproc-1); else printf("\tSerial Run\n"); printf("\tThreads/Task : %d \n",omp_get_max_threads()); printf("\tInput directory : %s \n",dirIn); printf("\tOutput directory : %s \n",dirOut); printf("\tNumber of file: %d \n",numFile); printf("\nBEGIN Simulation at %s\n",getTime(istant)); printf("\n"); printf("\n"); printf("\tLIST FILE\n"); printf("\t---------\n"); for(int i=0;i<numFile;i++) printf("\t%5d %20s\n",i,list[i]); printf("\t---------\n\n"); } MPI_Barrier(MPI_COMM_WORLD); if(myid == 0) { Master(nproc,dirIn,dirOut,list,numFile); } else { Slave(myid,nproc,dirIn,dirOut,list,numFile); } MPI_Barrier(MPI_COMM_WORLD); if(myid == 0) { printf("\nEND Simulation at %s\n",getTime(istant)); } error = MPI_Finalize(); return 0; }
void SlaveEntry(void) { struct ExecBase* SysBase = *((struct ExecBase**) 4); Slave( SysBase ); }
void CI2CShell::Run (void) { Print ("\n\nI2C Shell\n" "Using master #%u\n" "Default clock rate is %u KHz\n" "Enter \"help\" for help!\n\n", CMachineInfo::Get ()->GetDevice (DeviceI2CMaster), m_nI2CClockHz / 1000); while (m_bContinue) { ReadLine (); CString Command; while (GetToken (&Command)) { if (((const char *) Command)[0] == '#') { break; } else if (Command.Compare ("slave") == 0) { if (!Slave ()) { break; } } else if (Command.Compare ("clock") == 0) { if (!Clock ()) { break; } } else if (Command.Compare ("detect") == 0) { if (!Detect ()) { break; } } else if ( Command.Compare ("read") == 0 || Command.Compare ("rd") == 0) { if (!Read ()) { break; } } else if ( Command.Compare ("write") == 0 || Command.Compare ("wr") == 0) { if (!Write ()) { break; } } else if (Command.Compare ("delay") == 0) { if (!Delay ()) { break; } } else if (Command.Compare ("reboot") == 0) { m_bContinue = FALSE; } else if (Command.Compare ("help") == 0) { Print (HelpMsg); } else { Print ("Unknown command: %s\n", (const char *) Command); break; } } } }