static void restart_thread(pthread_t *waiter, int cancelable) { int status; /* Destroy the condition variable */ printf("restart_thread: Destroying cond\n"); status = pthread_cond_destroy(&cond); if (status != 0) { printf("restart_thread: ERROR pthread_cond_destroy failed, status=%d\n", status); } /* Destroy the mutex */ printf("restart_thread: Destroying mutex\n"); status = pthread_cond_destroy(&cond); if (status != 0) { printf("restart_thread: ERROR pthread_mutex_destroy failed, status=%d\n", status); } /* Then restart the thread */ printf("restart_thread: Re-starting thread\n"); start_thread(waiter, cancelable); }
void main(void) { startup_board(); start_thread(&service_thread, service, 0, stack, sizeof(stack)); start_cdc_service(); set_cdc_timeout(10); while (1) { yield_thread((condition_t)has_cdc_connection, 0); debug("connected\n"); while (has_cdc_connection()) { static u8_t buffer[1024]; const u32_t count = read_cdc_data(buffer, sizeof(buffer)); if (count) { write_cdc_data(buffer, count); debug("%m\n", buffer, count); } } debug("disconnected\n"); } }
recoder(const char* local_ip_1, const char* local_port_1, const char* remote_ip_1, const char* remote_port_1, const char* local_ip_2, const char* local_port_2, const char* remote_ip_2, const char* remote_port_2) { udp1 = new udp_recoder_stack({ {"udp_socket::local_ip", local_ip_1}, {"udp_socket::local_port", local_port_1}, {"udp_socket::remote_ip", remote_ip_1}, {"udp_socket::remote_port", remote_port_1}, {"kodo::tx_redundancy", 1.167} }); udp2 = new udp_recoder_stack({ {"udp_socket::local_ip", local_ip_2}, {"udp_socket::local_port", local_port_2}, {"udp_socket::remote_ip", remote_ip_2}, {"udp_socket::remote_port", remote_port_2}, {"kodo::tx_redundancy", 1.167} }); udp1->connect_signal_fw(boost::bind(&udp_recoder_stack::write_pkt, udp2, _1)); udp2->connect_signal_fw(boost::bind(&udp_recoder_stack::write_pkt, udp1, _1)); start_thread(); #ifdef VERBOSE printf("%s\n", "recoder class created"); #endif }
void main(void) { startup_board(); start_thread(&service_thread, service, 0, stack, sizeof(stack)); start_hid_service(); while (1) { yield_thread((condition_t)has_hid_connection, 0); debug("connected\n"); while (has_hid_connection()) { press(0x04); press(0x05); press(0x06); sleep(250); move(0, -100); sleep(250); move(-100, 0); sleep(250); move(0, 100); sleep(250); move(100, 0); sleep(200); } debug("disconnected\n"); } }
void Thread::fork(STATE) { if(int error = start_thread(state, Thread::run)) { char buf[RBX_STRERROR_BUFSIZE]; char* err = RBX_STRERROR(error, buf, RBX_STRERROR_BUFSIZE); Exception::raise_thread_error(state, err); } }
SignalHandler::SignalHandler(STATE, Configuration& config) : AuxiliaryThread() , shared_(state->shared()) , target_(state->vm()) , self_(NULL) , queued_signals_(0) , paused_(false) , exit_(false) , thread_(state) { signal_handler_ = this; shared_.auxiliary_threads()->register_thread(this); shared_.set_signal_handler(this); for(int i = 0; i < NSIG; i++) { pending_signals_[i] = 0; } worker_lock_.init(); worker_cond_.init(); pause_cond_.init(); setup_default_handlers(config.report_path.value); start_thread(state); }
void open_console() { safe_pipe(&control_read,&control_write); safe_pipe(&size_read,&size_write); safe_pipe(&stdin_read,&stdin_write); start_thread(stdin_loop,NULL); }
void test_thread_move_from_rvalue_using_explicit_move() { //boost::thread x(boost::move(start_thread())); boost::thread x=start_thread(); BOOST_CHECK(x.get_id()!=boost::thread::id()); x.join(); }
int pigpio_start(char *addrStr, char *portStr) { if (!gPigStarted) { gPigCommand = pigpioOpenSocket(addrStr, portStr); if (gPigCommand >= 0) { gPigNotify = pigpioOpenSocket(addrStr, portStr); if (gPigNotify >= 0) { gPigHandle = pigpio_command(gPigNotify, PI_CMD_NOIB, 0, 0, 1); if (gPigHandle < 0) return pigif_bad_noib; else { pthNotify = start_thread(pthNotifyThread, 0); if (pthNotify) { gPigStarted = 1; return 0; } else return pigif_notify_failed; } } else return gPigNotify; } else return gPigCommand; } return 0; }
int main(int argc, const char *argv[]){ printf("\n\n"); // Listen to SIGINT signals (program termination) signal(SIGINT, signal_handler); // Tell linux not to use the user leds in the board. take_over_leds(); // Load device tree overlay to enable PRU hardware. load_device_tree_overlay(); // Load and run binary into pru0 init_pru_program(); open_sound_file(); start_thread(); /* while(!finish){ */ sleep(5); /* } */ prussdrv_pru_disable(PRU_NUM); prussdrv_exit (); stop_thread(); close_sound_file(); return 0; }
static void cmd_poll(void) { printf("#####################################\n"); printf("## NFC demo through Neardal ##\n"); printf("#####################################\n"); if (create_loop(&main_loop) != NEARDAL_SUCCESS) return; do { main_loop_state = wait; /* Start discovery Loop */ if (start_discovery(NEARD_ADP_MODE_DUAL) != NEARDAL_SUCCESS) return; printf("---- Waiting for a Tag/Device"); /* Start a thread to get keystroke */ if (start_thread(&wait_for_keystroke) != NEARDAL_SUCCESS) return; /* Wait for tag/device lost to restart the discovery or for keystroke to leave */ g_timeout_add (100 , wait_lost , main_loop); g_main_loop_run(main_loop); /* loop until keystroke */ } while (main_loop_state != keystroke); g_main_loop_unref(main_loop); neardal_stop_poll(AdpName); printf("Leaving ...\n"); }
static uae_u32 scsidev_open (void) { uaecptr tmp1 = m68k_areg (regs, 1); /* IOReq */ uae_u32 unit = m68k_dreg (regs, 0); struct scsidevdata *sdd; #ifdef DEBUGME printf("scsidev_open(0x%x, %d)\n", tmp1, unit); #endif /* Check unit number */ if ((sdd = get_scsidev_data (unit)) && start_thread (sdd)) { opencount++; put_word (m68k_areg (regs, 6)+32, get_word (m68k_areg (regs, 6)+32) + 1); put_long (tmp1 + 24, unit); /* io_Unit */ put_byte (tmp1 + 31, 0); /* io_Error */ put_byte (tmp1 + 8, 7); /* ln_type = NT_REPLYMSG */ return 0; } put_long (tmp1 + 20, (uae_u32)-1); put_byte (tmp1 + 31, (uae_u8)-1); return (uae_u32)-1; }
int main() { initports(); printf("\nCreating a client\n"); clientid++; start_thread(client); printf("\nCreating a client\n"); clientid++; start_thread(client1); printf("\nCreating a server\n"); start_thread(server); printf("\n\n"); run(); while (1) { sleep(1);} }
void simple_test(func_args* args) { THREAD_TYPE serverThread; func_args svrArgs; char *svrArgv[NUMARGS]; char argc0s[32]; char argc1s[32]; char argc2s[32]; func_args cliArgs; char *cliArgv[NUMARGS]; char argc0c[32]; char argc1c[32]; char argc2c[32]; svrArgv[0] = argc0s; svrArgv[1] = argc1s; svrArgv[2] = argc2s; cliArgv[0] = argc0c; cliArgv[1] = argc1c; cliArgv[2] = argc2c; svrArgs.argc = 1; svrArgs.argv = svrArgv; svrArgs.return_code = 0; cliArgs.argc = 1; cliArgs.argv = cliArgv; cliArgs.return_code = 0; strcpy(svrArgs.argv[0], "SimpleServer"); #if !defined(USE_WINDOWS_API) && !defined(CYASSL_SNIFFER) svrArgs.argc = NUMARGS; strcpy(svrArgs.argv[1], "-p"); strcpy(svrArgs.argv[2], "0"); #endif /* Set the last arg later, when it is known. */ args->return_code = 0; svrArgs.signal = args->signal; start_thread(server_test, &svrArgs, &serverThread); wait_tcp_ready(&svrArgs); /* Setting the actual port number. */ strcpy(cliArgs.argv[0], "SimpleClient"); #ifndef USE_WINDOWS_API cliArgs.argc = NUMARGS; strcpy(cliArgs.argv[1], "-p"); snprintf(cliArgs.argv[2], sizeof(argc2c), "%d", svrArgs.signal->port); #endif client_test(&cliArgs); if (cliArgs.return_code != 0) { args->return_code = cliArgs.return_code; return; } join_thread(serverThread); if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code; }
void lcd_thread_start(void) { if(cfg.enablelcd) { running = 1; start_thread((void *) &refresh_lcd_file, "LCD"); } }
void lcd_thread_start(void) { if(cfg.enablelcd) { running = 1; start_thread("LCD", (void *) &refresh_lcd_file, NULL, NULL, 1, 1); } }
void thread_pool_start(thread_pool_t *tp) { ASSERT(tp, "start thread from empty thread pool"); int i = 0; for (; i < tp->thread_count; ++i) start_thread(tp->threads + i); }
static void schedule_new_thread(struct k_thread *thread, s32_t delay) { #ifdef CONFIG_SYS_CLOCK_EXISTS if (delay == 0) { start_thread(thread); } else { s32_t ticks = _TICK_ALIGN + _ms_to_ticks(delay); int key = irq_lock(); _add_thread_timeout(thread, NULL, ticks); irq_unlock(key); } #else ARG_UNUSED(delay); start_thread(thread); #endif }
static HANDLE w32_create_thread(DWORD stack_size, w32_thread_start_func func, void *val) { return start_thread(0, stack_size, func, val, CREATE_SUSPENDED #ifdef _WIN32_WCE |STACK_SIZE_PARAM_IS_A_RESERVATION #endif ,0); }
int main() { p[0].in=0; p[0].out=0; p[20].in=0; p[20].out=0; p[99].in=0; p[99].out=0; init_port(); printf("\n\t\t\tCreating a client1"); start_thread(client1); printf("\n\t\t\tCreating a client2"); start_thread(client2); printf("\n\t\t\tCreating a client3"); start_thread(client3); printf("\n\t\t\tCreating a server"); printf("\n\t\t\t*******************\n"); start_thread(server); run(); while (1) sleep(1); }
void FinalizerHandler::after_fork_child(STATE) { live_guard_.init(); worker_lock_.init(); worker_cond_.init(); supervisor_lock_.init(); supervisor_cond_.init(); start_thread(state); }
int main(int argc, char* argv[]) { start_thread(); //wait 10 seconds before exiting main std::this_thread::sleep_for(std::chrono::seconds(10)); std::cout << "Exit main!" << std::endl; return 0; }
WriterThread(Pipe<SendableThing *> *fpipe, int in_fd) { assert(fpipe != NULL); assert(in_fd >= 0); _fpipe = fpipe; _in_fd = in_fd; start_thread( ); }
/* Main function to test */ int main() { Q = InitQ(Q); start_thread(function1); // start_thread(function2); // start_thread(function3); // start_thread(function4); run(); }
void MainWindow::createcapthread() { capture = new Capture_thread; connect(capture, SIGNAL(start_cap()), this, SLOT(start_thread())); connect(capture, SIGNAL(show_listdata(const ListData, QString)), this, SLOT(update_show(const ListData, QString)), Qt::QueuedConnection); }
SvgSubprocessCharacterGenerator::SvgSubprocessCharacterGenerator( const char *cmd, unsigned int dirty_level ) : CharacterGenerator(1), _dirty_level(dirty_level) { _cmd = strdup(cmd); send_fd = -1; recv_fd = -1; start_thread( ); }
void factor_vm::open_console() { FACTOR_ASSERT(!stdin_thread_initialized_p); safe_pipe(&control_read, &control_write); safe_pipe(&size_read, &size_write); safe_pipe(&stdin_read, &stdin_write); stdin_thread = start_thread(stdin_loop, NULL); stdin_thread_initialized_p = true; pthread_mutex_init(&stdin_mutex, NULL); }
void SignalHandler::after_fork_child(STATE) { worker_lock_.init(); worker_cond_.init(); pause_cond_.init(); VM::discard(state, self_); self_ = NULL; start_thread(state); }
K init(K x) { dumb_socketpair(sockets, 0); sd1(sockets[1], recieve_data); FEED_STATE = FF_CONTINUE_FEED; start_thread(); return (K) 0; }
void Metrics::start(STATE) { vm_ = NULL; thread_exit_ = false; timer_ = new timer::Timer; metrics_collection_.init(); metrics_history_.init(); start_thread(state); }