// worker works until done == true or loop limit is reached void* worker_thread(void* limit) { type=WORKER; for(int i=0;i<*(int*)limit; i++) { wait_for_request(); randomize(); } return 0; }
void init_with_mpi(int argc, char ** argv) { mpi_mode = true; XDEBUG(std::cout << "adaptor: started in mpi mode" << std::endl); if(argc != 5) { std::cerr << "adaptor: wrong number of arguments" << std::endl; exit(1); } std::string ipc_file(argv[2]); if(*argv[4] == 'm') // Master process { master_instance = true; std::cout << "adaptor: master process started" << std::endl; parse_config(argv[3]); zmq_responder = zmq_socket (zmq_context, ZMQ_REP); zmq_connect(zmq_responder, ("ipc://" + ipc_file).c_str()); // Spit all actions out on request execute([&] () { // Wait for next request from client wait_for_request(); reply_config(); }); wait_for_request(); reply(); finalize(0); } else { std::cout << "adaptor: worker process started" << std::endl; init_ipc(ipc_file); parse_config(argv[3]); } }
int main(void) { /* name this process so others can find it */ diosix_set_role(DIOSIX_ROLE_VFS); /* step into the correct layer - layer 3 */ diosix_priv_layer_up(3); /* create some worker threads */ diosix_thread_fork(); diosix_thread_fork(); /* get some work to do */ while(1) wait_for_request(); }