int main() { mp3_init(); pthread_create(&thread,NULL,player,0); pthread_mutex_init(&player_mutex,NULL); pthread_cond_init(&player_ready,NULL); ctrl_loop();//¼àÌý°´¼ü pthread_mutex_destroy(&player_mutex); pthread_cond_destroy(&player_ready); return 0; }
int MAIN(int argc, char **argv) { int ret; int i=0; int nb_lcore; struct user_params params; struct lcore_config lcore[APP_MAX_LCORES]; uint8_t lcore_id; /* Associate signal_hanlder function with appropriate signals */ signal(SIGUSR1, signal_handler); signal(SIGUSR2, signal_handler); /* Parse EAL arguments and init DPDK EAL * * After this function call, all lcores are initialized in WAIT state and * ready to receive functions to execute */ ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); argc -= ret; argv += ret; nb_lcore = rte_lcore_count(); if (nb_lcore < 2) rte_exit(EXIT_FAILURE, "Too few locres. At least 2 required (one for packet fwd, one for control plane), %d given\n", nb_lcore); /* * This call sets log level in the sense that log messages for a lower * layer that this will not be shown but will still take CPU cycles. * To actually remove logging code from the program, set log level in * DPDK config files located in $RTE_SDK/config. */ rte_set_log_level(RTE_LOG_DEBUG); /* * Parse application-specific arguments, which comes after the EAL ones and * are separated from the latter by a double dash (--) */ ret = parse_args(argc, argv, ¶ms); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid content router arguments\n"); // Configure the app config object app_conf.fib_num_buckets = FIB_NUM_BUCKETS; app_conf.fib_max_elements = FIB_MAX_ELEMENTS; app_conf.pit_num_buckets = PIT_NUM_BUCKETS; app_conf.pit_max_elements = PIT_MAX_ELEMENTS; app_conf.pit_ttl_us = PIT_TTL_US; /* CS settings */ app_conf.cs_num_buckets = CS_NUM_BUCKETS; app_conf.cs_max_elements = CS_MAX_ELEMENTS; /* Packet burst settings */ app_conf.tx_burst_size = MAX_PKT_BURST; app_conf.rx_burst_size = MAX_PKT_BURST; /* Packet pool settings */ app_conf.nb_mbuf = NB_MBUF; app_conf.mbuf_size = MBUF_SIZE; app_conf.mempool_cache_size = MEMPOOL_CACHE_SIZE; /* Other config */ app_conf.promic_mode = params.promisc_mode; app_conf.portmask = params.portmask; app_conf.numa_on = params.numa_on; for(i=0; i< APP_MAX_ETH_PORTS;i++) memcpy(app_conf.config_remote_addr[i],params.config_remote_addr[i] ,18); init_app(&app_conf, lcore_conf); reset_stats(); MAIN_LOG("All configuration done. Launching worker lcores\n"); /* launch per-lcore init on every lcore but lcore 0 and control plane lcore*/ for(lcore_id = 1; lcore_id < nb_lcore; lcore_id++){ if (lcore_id == CONTROL_PLANE_LCORE) continue; ret = rte_eal_remote_launch(pkt_fwd_loop, NULL,lcore_id); if (ret < 0) rte_exit(EXIT_FAILURE, "lcore %u busy\n",lcore_id); } /* launch control plane core if not MASTER (LCORE=0, current)*/ if (CONTROL_PLANE_LCORE != 0){ ret = rte_eal_remote_launch(ctrl_loop, NULL, CONTROL_PLANE_LCORE); MAIN_LOG("Fwd and Ctrl loops Launched\n"); if (ret < 0) rte_exit(EXIT_FAILURE, "lcore %u busy\n",CONTROL_PLANE_LCORE); pkt_fwd_loop(NULL); } else ctrl_loop(NULL); /* launch control plane core if not MASTER (LCORE=0, current)*/ RTE_LCORE_FOREACH_SLAVE(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) return -1; } return 0; }