static void init_program(int argc,char **argv) { x11_init(argc,argv); if(sm->sologame) start_signal(); else { #ifdef USE_IPC int fd[2]; setup_sigchild(); if(pipe(fd) < 0) { perror("pipe"); exit(1); } if( (child_pids[0] = fork()) == 0) { close(fd[1]); if( (child_pids[1] = fork()) == 0) { /* we use a pipe to check if the daddy is dead: */ dup2(fd[0],0); /* I'm no unix-guru, so if you know a better way, */ close(fd[0]); /* pls. let me know (perhaps with a processgroup */ init_net(sm->hostname); /* <- should be neverending */ exit(1); /* <- but sure is sure :-) */ } close(fd[0]); x11_cntrl(); exit(1); } if(child_pids[0] < 0) { perror("fork"); exit(1); } close(fd[0]); #else if(init_net(sm->hostname) < 0) { fprintf(stderr,"nm: Networkproblems\n"); exit(1); } #endif } }
void SetNullIP(const char *pcInterface) { struct bootp wlan_bootp_data; int j = 0; char ipadd[16]; char netmask[16] = "0.0.0.0"; char gateway[16]; char broadcast[16] = "255.255.255.255"; unsigned long ulIP = 0; httpIP2String(ulIP, ipadd); strcpy(gateway, ipadd); DownInterface(pcInterface); diag_printf("IP is %s, NetMask is %s, Gateway is %s,Broadcast is %s\n",ipadd,netmask,gateway,broadcast); build_bootp_record(&wlan_bootp_data, pcInterface, ipadd, netmask,broadcast,gateway,gateway); show_bootp(pcInterface, &wlan_bootp_data); if (!init_net(pcInterface, &wlan_bootp_data)) { diag_printf("failed for %s\n",pcInterface); } for(;j<5;j++) init_loopback_interface(0); }
int main(int argc, char **argv) { SDL_Rect pos; t_world new_world; t_bag new_bag; SDLNet_SocketSet set; if (signal(SIGINT, free_all) == SIG_ERR) exit(EXIT_FAILURE); if (argc != 3) write(2, USAGE, strlen(USAGE)); else { init_buf_msg(&(gl_screen.my_msg)); gl_screen.info_bag = &new_bag; gl_screen.pos = &pos; gl_screen.world = &new_world; init_screen(&gl_screen); init_net(argv[1], (unsigned)atoi(argv[2]), &set, &gl_screen); init_sdl(&gl_screen); events(&gl_screen, &set); SDLNet_FreeSocketSet(set); SDLNet_TCP_Close(gl_screen.sock_server); free_gui(&gl_screen); } return (EXIT_SUCCESS); }
void init(int32_t argc, char *argv[]) { ::setlocale(LC_ALL, ""); if (options(&argc, argv)) _exit(0); int32_t cpus = 0; os_base::CPUs(cpus); if (cpus < 2) cpus = 2; exlib::Service::init(cpus + 1); init_prof(); init_argv(argc, argv); init_date(); init_rt(); init_sandbox(); init_acThread(); init_logger(); init_net(); init_fiber(); srand((unsigned int)time(0)); v8::Platform *platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(platform); v8::V8::Initialize(); }
void AppColdStart(void) { /* default startup */ init_hardware(); process_init(); procinit_init(); init_net(); jts_init(); /* application startup */ autostart_start(autostart_processes); /* enable watchdog on JN5148, there is none on JN5139 */ #ifdef __BA2__ watchdog_start(); #endif /* default main loop */ while(1) { process_run(); etimer_request_poll(); #ifdef __BA2__ watchdog_periodic(); #endif } }
int main(int argc, char** argv) { init_mpi(&argc, &argv); // disable log from caffe (disable glog entirely) FLAGS_minloglevel = 3; // Run tool or show usage. caffe::GlobalInit(&argc, &argv); int iters = FLAGS_iterations; string netdefs = FLAGS_model; Dtype lr = Dtype(FLAGS_lr); // at least iters in total // actuall number of workers is np - 1 iters = (iters + np - 2) / (np - 1); if (pid == 0) iters *= (np - 1); auto net = init_net(netdefs); std::vector<Blob<Dtype>*> bottom_vec; // sync parameters broadcast_params(net); if (pid == 0) root_node(net, iters, lr); else worker_node(net, iters); return finish_mpi(); }
//int init_net(int count , char *ip, int port); //int net_loop(); int main(int argc,char** argv) { char ip[10]="127.0.0.1"; int port=10002; int MAX_EPOLL_CNT=100; if(init_proc()){ return -1; } init_net(MAX_EPOLL_CNT, ip, 10000); for(int loop=0 ; loop < MAX_PID_CNT ; loop++ ){ int pid=fork(); if( pid>0 ){ std::cout<<"parent start:"<<getpid()<<std::endl; }else if(pid==0){ std::cout<<"child start"<<" pid: "<<getpid()<<" parent:"<<getppid()<<std::endl; exit_net(); while(1){ net_loop(0); } }else{ exit(-1); } } while(1){ net_loop(1); } exit_net(); return 0; }
void AppColdStart(void) { /* default startup */ init_hardware(); buzzer_init(); rgb_leds_init(); sseg_init(); process_init(); init_net(); /* start the main processes */ procinit_init(); autostart_start(autostart_processes); jts_init(); /* enable watchdog on JN5148, there is none on JN5139 */ watchdog_start(); /* default main loop */ while(1) { process_run(); etimer_request_poll(); watchdog_periodic(); } }
bool init_config() { do { if (init_lua_config() == false) { ERROR_LOG("%s", "初始化lua配置错误"); break; } if (init_net_config() == false) { ERROR_LOG("%s", "初始化网络配置失败"); break; } if (init_net() == false) { ERROR_LOG("%s", "初始化网络失败"); break; } protocol_init(); net::regist_connector_callback(connector_callback); connect_gs(); return true; } while (false); return false; }
/*---------------------------------------------------------------------------*/ static void start_process_run_loop(void *data) { /* Yield once during bootup */ simProcessRunValue = 1; cooja_mt_yield(); /* Initialize random generator */ random_init(0); /* Start process handler */ process_init(); /* Start Contiki processes */ procinit_init(); /* Print startup information */ printf(CONTIKI_VERSION_STRING " started. "); if(node_id > 0) { printf("Node id is set to %u.\n", node_id); } else { printf("Node id is not set.\n"); } /* Initialize communication stack */ init_net(); /* Start serial process */ serial_line_init(); /* Start autostart processes (defined in Contiki application) */ print_processes(autostart_processes); autostart_start(autostart_processes); while(1) { /* Always pretend we have processes left while inside process_run() */ simProcessRunValue = 1; if (simDoReceiverCallback) { simDoReceiverCallback = 0; radio_call_receiver(); } simProcessRunValue = process_run(); while (simProcessRunValue-- > 0) { process_run(); } simProcessRunValue = process_nevents(); // Check if we must stay awake if (simDontFallAsleep) { simDontFallAsleep=0; simProcessRunValue = 1; } /* Yield thread when one process_run has completed */ cooja_mt_yield(); } }
int main(int argc,char **argv) { int i; //iterator pid *x,*y,*z; //structs representing 3 pid controllers imu_t *imu; fd_set net_set; double oldmag,magdiff; struct timeval timeout; int axes[4]={0,0,0,0}; int x_adjust,y_adjust,z_adjust; int sock = init_net(); register_int(); x=init_pid(3500,000,000); y=init_pid(3400,000,1000); z=init_pid(000,000,000); timeout.tv_sec=0; timeout.tv_usec=REFRESH_TIME; for(i=0;i<4;i++) { //initialize PWM modules motors[i]=init_pwm(i); } imu = init_imu(); update_imu(imu); oldmag=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE; while(1) { ////printf("loop\n"); FD_ZERO(&net_set); FD_SET(sock,&net_set); if(select(sock+1,&net_set,(fd_set *) 0,(fd_set *) 0, &timeout)==1) { ////printf("reading from the socket\n"); //read from sock if(!update_axis(sock,axes)) { break; } } else { ////printf("reading from the imu\n"); //update imu update_imu(imu); timeout.tv_sec=0; timeout.tv_usec=REFRESH_TIME; magdiff=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE-oldmag; if(magdiff>300) { magdiff-=360; } if(magdiff<-300) { magdiff+=360; } x_adjust = update_pid(x,0/*axes[1]*.00061*/,imu->mpu.fusedEuler[VEC3_X] * RAD_TO_DEGREE); y_adjust = update_pid(y,0/*axes[2]*.00061*/,imu->mpu.fusedEuler[VEC3_Y] * RAD_TO_DEGREE); //printf("X axis value: %lf\n",imu->mpu.fusedEuler[VEC3_X]*RAD_TO_DEGREE); //printf("Y axis value: %lf\n",imu->mpu.fusedEuler[VEC3_Y]*RAD_TO_DEGREE); z_adjust = update_pid(z,axes[3]*.00061,magdiff); oldmag=imu->mpu.fusedEuler[VEC3_Z] * RAD_TO_DEGREE; set_duty(motors[0],900000+axes[0]*16-z_adjust-y_adjust+x_adjust); set_duty(motors[1],900000+axes[0]*16+z_adjust-y_adjust-x_adjust); set_duty(motors[2],900000+axes[0]*16-z_adjust+y_adjust-x_adjust); set_duty(motors[3],900000+axes[0]*16+z_adjust+y_adjust+x_adjust); } } exit_fxn(0); }
int main(void) { //initialize... init_net(); //do something return 0; }
int main(void) { leds_init(); leds_on(LEDS_RED); /* Initialize USART */ init_usart(); /* Clock */ clock_init(); leds_on(LEDS_GREEN); ds2401_init(); random_init(0); rtimer_init(); /* Process subsystem */ process_init(); process_start(&etimer_process, NULL); ctimer_init(); leds_on(LEDS_YELLOW); init_net(); node_id_restore(); printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u, using %s.\n"), node_id, rime_mac->name); printf_P(PSTR("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"), ds2401_id[0], ds2401_id[1], ds2401_id[2], ds2401_id[3], ds2401_id[4], ds2401_id[5], ds2401_id[6], ds2401_id[7]); leds_off(LEDS_ALL); /* Autostart processes */ autostart_start(autostart_processes); /* Main scheduler loop */ do { process_run(); }while(1); return 0; }
int main(int argc, char** argv){ dpid = fork(); if (dpid != 0) { waitpid(dpid, NULL, 0); //int status; //wait3(&status, WNOHANG, NULL); exit(0); } int sid = setsid(); init_net(); if (sid < 0) { perror("session creation error"); exit(1); } std::vector<pollfd> pollfds(fds.size()); for (int i = 0; i < pollfds.size(); i++) { pollfds[i].fd = fds[i]; pollfds[i].events = POLLIN | POLLERR | POLLHUP | POLLRDHUP | POLLNVAL; pollfds[i].revents = 0; } for(;;){ int ret = poll(pollfds.data(), pollfds.size(), -1); int status; wait3(&status, WNOHANG, NULL); if(ret == 0) continue; for (int i = 0; i < pollfds.size(); i++) { if (pollfds[i].revents & (POLLERR | POLLHUP | POLLRDHUP | POLLNVAL)) { pollfds[i].events = 0; close(fds[i]); perror("socket has been disconnected"); //this shoud not be reachable _exit(1); } if (pollfds[i].revents & POLLIN) { int cfd = accept(fds[i], NULL, NULL); if (cfd < 0) { perror("fd < 0"); continue; } printf("Accepting %d\n", cfd); int pid = fork(); if (pid == 0) { for (int i = 0; i < fds.size(); i++) { close(fds[i]); } handle_client(cfd); return 0; } close(cfd); } } } }
/*---------------------------------------------------------------------------*/ int main(void) { leds_init(); leds_on(LEDS_RED); /* Initialize USART */ init_usart(); /* Clock */ clock_init(); leds_on(LEDS_GREEN); ds2401_init(); node_id_restore(); random_init(ds2401_id[0] + node_id); rtimer_init(); /* Process subsystem */ process_init(); process_start(&etimer_process, NULL); ctimer_init(); leds_on(LEDS_YELLOW); init_net(); printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id); leds_off(LEDS_ALL); /* Autostart processes */ autostart_start(autostart_processes); mmem_init(); /* Main scheduler loop */ do { process_run(); }while(1); return 0; }
void GateModule::init(const std::unordered_map<std::string, std::string>& config) { std::string name = config.at("name"); std::string ip = config.at("ip"); std::string port = config.at("port"); std::string thread_num = config.at("net_thread_num"); set_name(name); init_net(std::stoi(thread_num)); listen(ip, port); }
int pppoe_disc_start(struct pppoe_serv_t *serv) { struct disc_net *net = find_net(serv->net); struct rb_node **p, *parent = NULL; struct tree *t; int ifindex = serv->ifindex, i; struct pppoe_serv_t *n; if (!net) { pthread_mutex_lock(&nets_lock); net = find_net(serv->net); if (!net) net = init_net(serv->net); pthread_mutex_unlock(&nets_lock); if (!net) return -1; } t = &net->tree[ifindex & HASH_BITS]; pthread_mutex_lock(&t->lock); p = &t->root.rb_node; while (*p) { parent = *p; n = rb_entry(parent, typeof(*n), node); i = n->ifindex; if (ifindex < i) p = &(*p)->rb_left; else if (ifindex > i) p = &(*p)->rb_right; else { pthread_mutex_unlock(&t->lock); log_error("pppoe: disc: attempt to add duplicate ifindex\n"); return -1; } } rb_link_node(&serv->node, parent, p); rb_insert_color(&serv->node, &t->root); pthread_mutex_unlock(&t->lock); return net->hnd.fd; }
int main(int argc,char *argv[]){ int i=0; srand(time(NULL)); net mlpnet; int layer_neurons[]={2,10,5,1}; char sigmods[]={'l','l','l','l'}; init_net(&mlpnet,4,layer_neurons,sigmods); float *inputs=(float*)malloc(sizeof(float)*2); sample *samples; int num_lines=count_lines(argv[1]); samples=(sample*)malloc(sizeof(sample)*num_lines); read_samples(argv[1],samples,num_lines); train(&mlpnet,num_lines,samples,EPOCHS); free_samples(samples,num_lines); //================================================== num_lines=count_lines(argv[2]); sample *test_samples=(sample*)malloc(sizeof(sample)*num_lines); read_samples(argv[2],test_samples,num_lines); float *scores=(float*)malloc(sizeof(float)*num_lines); predict(&mlpnet,num_lines,test_samples,scores); free_samples(test_samples,num_lines); free_net(&mlpnet,4,layer_neurons); char scorefile[100]; sprintf(scorefile,"%s.score",argv[1]); FILE *score=fopen(scorefile,"w"); for(i=0;i<num_lines;i++) { fprintf(score,"%f\n",scores[i]); } fclose(score); return 0; }
int main (int argc, char *argv[]) { debugenv(); setprogname(argv[0]); FN; init_net(); init_fs(); init_tau(); tag_loop(); return 0; }
int main (int argc, char *argv[]) { debugenv(); setprogname(argv[0]); init_shell(NULL); init_net(); init_sage(); init_dir(); init_test(); CMD(test, "# test function"); return shell(); }
void init(void) { printf("Enter the ip address of other machine: "); scanf("%s",DEST_IP); glClearColor (0.0, 0.0, 0.0, 0.0); glClearDepth(1.0); glDisable(GL_CULL_FACE); glShadeModel (GL_SMOOTH); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 1000.0); glMatrixMode (GL_MODELVIEW); init_net(); init_car_model(); init_key_press(); createLights(); }
int init_tesseract(const char *arg0, const char *textbase, const char *language, const char *configfile, int configc, const char *const *configv) { init_tesseract_lang_data (arg0, textbase, language, configfile, configc, configv); start_recog(configfile, textbase); set_tess_tweak_vars(); if (tessedit_use_nn) //phils nn stuff init_net(); return 0; //Normal exit }
main () { ANN *net; FILE *cf; float inputs[13], outputs[2]; int actual, estimate, ncases; int i, j; if ((net = init_net("testnet.wts")) == (ANN *) NULL) { printf("error initializing network from testnet.wts\n"); exit(1); } printf("Network returned is %d layers of size:", net->nlayers); for (i=0; i<net->nlayers; i++) printf(" %d", net->sz[i]); printf("\n"); if ((cf = fopen("testnet.cls", "r")) == (FILE *) NULL) { printf("error opening class file testnet.cls\n"); exit(1); } fscanf(cf, "%d", &ncases); printf("Number of cases = %d\n", ncases); for (i=0; i<ncases; i++) { fscanf(cf, "%i", &actual); for (j=0; j<13; j++) fscanf(cf, "%f", &inputs[j]); run_net(net, inputs, outputs); if (outputs[0] >= outputs[1]) estimate = 1; else estimate = 2; printf("Case %d: activation out = %6f %6f; expected %d, got %d\n", i, outputs[0], outputs[1], actual, estimate); } free_net(net); exit(0); }
int main (int argc, char *argv[]) { int rc; debugenv(); FN; setprogname(argv[0]); rc = init_fs(); if (rc) return rc; rc = init_net(); if (rc) return rc; tag_loop(); return 0; }
/* Jennic equivalent of main() */ void AppColdStart(void) { /* default startup */ init_hardware(); process_init(); init_net(); procinit_init(); autostart_start(autostart_processes); jts_init(); /* default main loop */ while(1) { process_run(); etimer_request_poll(); } }
int main(void) { uint8_t t=0; SystemInit(); systick_init(); init_usart(usart1); //init_rtc(); // init_net(); len=0; //buffer[0]=1; //send(usart1,buffer,1); while (1) { process_net(); //if(t!=timer.sec) if(rtc_flag==1) { rtc_flag=0; //time_get(); //t=timer.sec; //debug_format("%d-----\r\n",l); //l++; //debug_format("Time: %0.4dÄê%0.2dÔÂ%0.2dÈÕ %0.2d:%0.2d:%0.2d\r\n",timer.w_year,timer.w_month,timer.w_date,timer.hour,timer.min,timer.sec); } //send(usart4,buffer,len); if(delay>30) { //time_show(); len=receive(usart1,buffer); if(len>0) { //send(usart1,buffer,len); debug_format("the receive len is %d \r\n",len); len=0; } delay=0; } } }
int main(int argc, char* argv[]) { char str[100] = ""; int basepoint = 20; /* if (argc < 2) return 0; if (stricmp(argv[1], "/p") == 0) { HWND hwnd; sscanf(argv[2], "%d", &hwnd); attachHWND(hwnd); } else if (stricmp(argv[1], "/s")) return 0;//*/ init(); init_net(&g_net, basepoint * 4, basepoint * 3, g_width, g_height); setbkmode(TRANSPARENT); fps fps_obj; setrendermode(RENDER_MANUAL); for (; kbhit() == 0; delay_fps(60)) { cleardevice(); setcolor(0x8000); draw_net(&g_net); setcolor(0xFFFFFF); outtextxy(0,0,str); move_net(&g_net); move_net(&g_net); { int x, y, k; getmouse(&x, &y, &k); if (k) { cap_pt(&g_net, x, y, 1); } else { cap_pt(&g_net, x, y, 0); } } } closegraph(); return 0; }
PROCESS_THREAD(contiki_stk501_main_init_process, ev, data) { PROCESS_BEGIN(); /* Network support (uIP) */ init_net(); /* Initalize heap allocator */ mmem_init (); /* Code propagator */ process_start(&codeprop_process, NULL); /* Multi-threading support */ #ifdef MT_DEMO mt_init (); #endif PROCESS_END(); }
int another_net(void) { clock_init(); random_init(MOTE_ID); init_net(MOTE_ID); process_init(); start_radio_task(); process_start(&etimer_process, NULL); ctimer_init(); rtimer_init(); procinit_init(); autostart_start(autostart_processes); start_udp_server_task(); PRINTF("Processes running\n"); OSSemBinaryCreate(0, &Contiki_Sem); PRINTF("\n*******%s online*******\n\r", CONTIKI_VERSION_STRING); while (1) { int n; do { n = process_run(); } while (n > 0); OSSemPend(Contiki_Sem, 0); } }
PROCESS_THREAD(contiki_stk501_main_init_process, ev, data) { PROCESS_BEGIN(); /* Network support (uIP) */ init_net(); /* Initalize heap allocator */ mmem_init (); /* Code propagator */ /* TODO: The core elfloader-avr.c has 16/32 bit pointer problems so this won't build */ //process_start(&codeprop_process, NULL); /* Multi-threading support */ #ifdef MT_DEMO mt_init (); #endif PROCESS_END(); }