void init_timer(){ slow_tick = 1; fast_tick = 1; tick_counter = 0; oldtimer = getvect(8); init_handler(&state); asm cli // speed up clock // 1193180 / 298295 = 4 (298295kHz, 3,3523861 us, 3 ticks 10,057158us) // its 16384 times faster than standard 18.2Hz clock asm { mov bx, FREQ_DIVI mov al, 00110100b out 43h, al mov al, bl out 40h, al mov al, bh out 40h, al } setvect(8, new_timer); asm sti }
/* initialize handler ,std & err output level */ void init_olsr_debug(){ if(std_handler == NULL) { init_handler(); //init_output_level(); } return; }
PyObject *init_guava(void) { PyObject *guava_module = NULL; PyObject *request_module = NULL; PyObject *server_module = NULL; PyObject *handler_module = NULL; PyObject *controller_module = NULL; PyObject *router_module = NULL; PyObject *session_module = NULL; PyObject *cookie_module = NULL; PyEval_InitThreads(); guava_module = Py_InitModule("guava", NULL); request_module = init_request(); if (!register_module(guava_module, "request", request_module)) { return NULL; } server_module = init_server(); if (!register_module(guava_module, "server", server_module)) { return NULL; } handler_module = init_handler(); if (!register_module(guava_module, "handler", handler_module)) { return NULL; } router_module = init_router(); if (!register_module(guava_module, "router", router_module)) { return NULL; } controller_module = init_controller(); if (!register_module(guava_module, "controller", controller_module)) { return NULL; } session_module = init_session(); if (!register_module(guava_module, "session", session_module)) { return NULL; } cookie_module = init_cookie(); if (!register_module(guava_module, "cookie", cookie_module)) { return NULL; } PyModule_AddStringConstant(guava_module, "version", GUAVA_VERSION); return guava_module; }
int main(int argc, char *argv[]) { Mem = new Memory(); if ( Mem == NULL ){ my_error("couldn't allocate Mem"); exit(0); } Mem->GetOptions(argc,argv); Socket sock = init_connection(Mem->SP_host,Mem->SP_port); Mem->sock = &sock; if(Mem->sock->socketfd == -1) { cerr << "Can't open connection for player" << endl; exit(-1); } send_initialize_message(); if ( wait_message(recvbuf, Mem->sock) == 0 ) my_error("wait_message failed"); parse_initialize_message(recvbuf); Mem->Initialize(); score(); /* find out the score */ if (Mem->IP_only_connect) return 0; sigset_t sigfullmask = init_handler(); while ( Mem->ServerAlive == TRUE && wait_for_signals(&sigfullmask) ); if (Mem->sock->socketfd != -1) close_connection(Mem->sock); printf("Shutting down player %d\n",Mem->MyNumber); }
/* * Call solver on file given as an argument */ int main(int argc, char *argv[]) { int resu; if (argc != 2) { fprintf(stderr, "Usage: %s <input file>\n", argv[0]); exit(1); } resu = build_instance(argv[1], &solver); if (resu < 0) { exit(2); } construction_time = get_cpu_time(); print_problem_size(stdout, &solver, argv[1], construction_time); init_handler(); sat_solve(&solver, NULL, true); search_time = get_cpu_time() - construction_time; print_results(&solver, construction_time, search_time); delete_smt_core(&solver); return 0; }
bool EasyHelper::is_alive(easy_addr_t &addr, easy_io_t *eio) { UNUSED(eio); #if 1 //~ using `connect' struct sockaddr sa; int sfd; if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { TBSYS_LOG(ERROR, "establish socket failed: %s", strerror(errno)); return false; } fcntl(sfd, F_SETFL, O_NONBLOCK); memset(&sa, 0, sizeof(sa)); memcpy(&sa, &addr, sizeof(uint64_t)); bool alive = false; errno = 0; if (connect(sfd, &sa, sizeof(sa)) == -1) { if (errno == EINPROGRESS) { alive = wait_connected(sfd, 10/*ms*/); } } else { alive = true; } if (!alive) { char buf[32]; TBSYS_LOG(ERROR, "connect to '%s' failed: %m", easy_inet_addr_to_str(&addr, buf, sizeof(buf))); } close(sfd); return alive; #else //~ using ping packet if (eio == NULL) { eio = tair::EasyHelper::eio; } if (eio == NULL) { TBSYS_LOG(ERROR, "you must specify a eio"); return false; } static easy_io_handler_pt io_handler; init_handler(&io_handler, NULL); io_handler.process = alive_processor_cb; request_ping *packet = new request_ping; base_packet *bp = (base_packet*)easy_sync_send(eio, addr, packet, (void*)0L, &io_handler, 100/*ms*/); if (bp) { delete bp; return true; } else { return false; } #endif }