这篇教程C++ thread_create函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中thread_create函数的典型用法代码示例。如果您正苦于以下问题:C++ thread_create函数的具体用法?C++ thread_create怎么用?C++ thread_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了thread_create函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: border_initializeuint8_t border_initialize(transceiver_type_t trans,ipv6_addr_t *border_router_addr) { ipv6_addr_t addr; serial_reader_pid = thread_create( serial_reader_stack, READER_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, serial_reader_f, "serial_reader"); if (border_router_addr == NULL) { border_router_addr = &addr; addr = flowcontrol_init(); } /* only allow addresses generated accoding to * RFC 4944 (Section 6) & RFC 2464 (Section 4) from short address * -- for now */ if ( border_router_addr->uint16[4] != HTONS(IEEE_802154_PAN_ID ^ 0x0200) || border_router_addr->uint16[5] != HTONS(0x00FF) || border_router_addr->uint16[6] != HTONS(0xFE00) ) { return SIXLOWERROR_ADDRESS; } // radio-address is 8-bit so this must be tested extra if (border_router_addr->uint8[14] != 0) { return SIXLOWERROR_ADDRESS; } memcpy(&(abr_addr.uint8[0]),&(border_router_addr->uint8[0]),16); sixlowpan_init(trans,border_router_addr->uint8[15],1); ipv6_init_iface_as_router(); return SUCCESS;}
开发者ID:benpicco,项目名称:RIOT-old,代码行数:38,
示例2: mainint main(void){ puts("START"); kernel_pid_t pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST, _thread, NULL, "second_thread"); thread_t *thread = (thread_t*) thread_get(pid); _set(thread, 0x1); _set(thread, 0x64); _set(thread, 0x1); _set(thread, 0x8); _set(thread, 0x2); _set(thread, 0x4); while(!done) {}; puts("main: setting 100ms timeout..."); xtimer_t t; uint32_t before = xtimer_now_usec(); xtimer_set_timeout_flag(&t, TIMEOUT); thread_flags_wait_any(THREAD_FLAG_TIMEOUT); uint32_t diff = xtimer_now_usec() - before; printf("main: timeout triggered. time passed: %uus/n", (unsigned)diff); if (diff < (TIMEOUT + THRESHOLD)) { puts("SUCCESS"); return 0; } puts("FAILURE"); return 1;}
开发者ID:LudwigKnuepfer,项目名称:RIOT,代码行数:38,
示例3: http_client_test2void http_client_test2(void){ aio_worker_init(); pthread_t thread; bool running = true; thread_create(&thread, http_server_thread, &running); struct http_header_t headers[3]; headers[0].name = "User-Agent"; headers[0].value = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0"; headers[1].name = "Accept-Language"; headers[1].value = "en-US,en;q=0.5"; headers[2].name = "Connection"; headers[2].value = "keep-alive"; // block IO void *http = http_client_create("127.0.0.1", PORT, 1); assert(0 == http_client_get(http, "/", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, NULL)); assert(0 == http_client_get(http, "/img/bdlogo.png", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, NULL)); assert(0 == http_client_get(http, "/", NULL, 0, http_client_test_onreply, NULL)); http_client_destroy(http); // AIO int32_t ref = 0; http = http_client_create("127.0.0.1", PORT, 0); assert(0 == http_client_get(http, "/", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, &ref)); while(1 != ref) system_sleep(1000); assert(0 == http_client_get(http, "/img/bdlogo.png", headers, sizeof(headers)/sizeof(headers[0]), http_client_test_onreply, &ref)); while(2 != ref) system_sleep(1000); assert(0 == http_client_get(http, "/", NULL, 0, http_client_test_onreply, &ref)); while(3 != ref) system_sleep(1000); http_client_destroy(http); running = false; thread_destroy(thread); aio_worker_cleanup();}
开发者ID:azalpy,项目名称:sdk,代码行数:38,
示例4: cc1100_phy_initvoid cc1100_phy_init(){ int i; rx_buffer_head = 0; rx_buffer_tail = 0; rx_buffer_size = 0; /* Initialize RX-Buffer (clear content) */ for (i = 0; i < RX_BUFF_SIZE; i++) { rx_buffer->packet.length = 0; } /* Initialize handler table & packet monitor */ packet_monitor = NULL; pm_init_table((pm_table_t *)&handler_table, MAX_PACKET_HANDLERS, handlers); /* Clear sequence number buffer */ memset(seq_buffer, 0, sizeof(seq_buffer_entry_t) * MAX_SEQ_BUFFER_SIZE); /* Initialize mutex */ cc1100_mutex_pid = -1; mutex_init(&cc1100_mutex); /* Allocate event numbers and start cc1100 event process */ cc1100_event_handler_pid = thread_create(event_handler_stack, sizeof(event_handler_stack), PRIORITY_CC1100, CREATE_STACKTEST, cc1100_event_handler_function, cc1100_event_handler_name); /* Active watchdog for the first time */ if (radio_mode == CC1100_MODE_CONSTANT_RX) { cc1100_watch_dog_period.microseconds = CC1100_WATCHDOG_PERIOD; if (cc1100_watch_dog_period.microseconds != 0) { timex_t temp = timex_set(0, 5000000L); vtimer_set_msg(&cc1100_watch_dog, temp, cc1100_event_handler_pid, NULL); } }}
开发者ID:fjrk,项目名称:RIOT,代码行数:38,
示例5: mainint main(void){ const char * ip_msg = "IPM message/n"; int64_t tick_orig; printf("Application started (M:%u)!/n", mm_heap_available()); ipm_queue_init(&ipm_q, 2); test_t = thread_create( "tst", &test_th_handle, NULL, CONFIG_STACK_SIZE, test_thread_stack, 80); tick_orig = sys_tick; while(true) { if(time_after(sys_tick, tick_orig + 3000)) printf("tm after: 3000/n"); ipm_post_msg(&ipm_q, ip_msg, strlen(ip_msg)); printf("maint mem: %u/n", mm_heap_available()); sleep(500); } return 0;}
开发者ID:bietje,项目名称:etaos,代码行数:23,
示例6: run/** * Example's executing routine * It has been declared by the macro EMBOX_EXAMPLE */static int run(int argc, char **argv) { struct thread *thr[CONF_THREADS_QUANTITY]; int data[CONF_THREADS_QUANTITY]; void *ret; int i; /* starting all threads */ for(i = 0; i < ARRAY_SIZE(thr); i ++) { data[i] = i; //printf("starting thread %d with", i); thr[i] = thread_create(0, thread_handler, &data[i]); //printf(" id = %d/n", thr[i]->id); } /* waiting until all threads finish and print return value*/ for(i = 0; i < ARRAY_SIZE(thr); i ++) { thread_join(thr[i], &ret); //printf("finished thread id %d with result %d/n", i, *((int *)ret)); } printf("/n"); return ENOERR;}
开发者ID:Julia117,项目名称:embox,代码行数:27,
示例7: mainintmain(int argc, char *argv[]){ int a, b, c, d, f, g, h, i = 1; int pid, pid2; char *e; g = (int)malloc(1); a = (int)malloc(1); b = (int)malloc(2); c = (int)malloc(40); f = (int)malloc(17); h = (int)malloc(16); e = (char *)c; e+=20; d = (int)e; printf(1, "%s", "** Placeholder program for grading scripts **/n"); printf(1, "** g %d, a %d, b %d, c %d, d %d, f %d, h %d**/n", g, a, b, c, d, f, h); pid = thread_create(worker,(void *)i); pid2 = thread_join(); printf(1, "create pid = %d, join pid = %d/n", pid, pid2); exit();}
开发者ID:abhinav-mehra,项目名称:xv6,代码行数:23,
示例8: mainint main(void){ puts("main starting"); kernel_pid_t pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST, _thread, NULL, "second_thread"); thread_t *thread = (thread_t*) thread_get(pid); _set(thread, 0x1); _set(thread, 0x64); _set(thread, 0x1); _set(thread, 0x8); _set(thread, 0x2); _set(thread, 0x4); while(1) {}; return 0;}
开发者ID:deepfryed,项目名称:RIOT,代码行数:23,
示例9: mallockbrd_instance_t *kbrd_init(void){ kbrd_instance_t *instance = malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC); if (instance) { instance->thread = thread_create(kkbrd, (void *) instance, TASK, THREAD_FLAG_NONE, "kkbrd"); if (!instance->thread) { free(instance); return NULL; } instance->sink = NULL; indev_initialize("kbrd", &instance->raw, &kbrd_raw_ops); spinlock_initialize(&instance->keylock, "kbrd.instance.keylock"); instance->keyflags = 0; instance->lockflags = 0; } return instance;}
开发者ID:jvesely,项目名称:helenos,代码行数:23,
示例10: thread_runstatic thread_tthread_run(char *name, void (*start)(void), void *stack, size_t stack_size, int nice){ thread_t th = 0; int rc; if ((rc = thread_create(task_self(), &th)) != 0) errx(1, "thread_create: %s", strerror(rc)); if ((rc = thread_load(th, start, (uint8_t*)stack + stack_size)) != 0) errx(1, "thread_load: %s", strerror(rc)); thread_name(th, name); if ((rc = thread_setprio(th, PRIO_DFLT + nice)) != 0) errx(1, "thread_setprio: %s", strerror(rc)); if ((rc = thread_resume(th)) != 0) errx(1, "thread_resume: %s", strerror(rc)); return th;}
开发者ID:AndrewD,项目名称:prex,代码行数:23,
示例11: main// This is the main thread// In a real program, it should probably start all of the threads and then wait for them to finish// without doing any "real" workint main(void) { printf("Main starting/n"); printf("Main calling thread_create/n"); // Start one other thread thread_create(&test_thread); printf("Main returned from thread_create/n"); // Loop, doing a little work then yielding to the other thread while(1) { printf("Main calling thread_yield/n"); thread_yield(); printf("Main returned from thread_yield/n"); } // We should never get here exit(0); }
开发者ID:haiqvo,项目名称:CMPS111,代码行数:26,
示例12: tgdb_thread_createthread_port_t tgdb_thread_create(vm_offset_t entry){ kern_return_t rc; mach_thread_t th; int i; for (th = &threads[0], i=0; i<MAX_THREADS; i++, th++) if (th->thread == MACH_PORT_NULL) break; if((rc = thread_create(mach_task_self(), &th->thread)) != KERN_SUCCESS) { printf("tgdb: thread_create returned %d/n", rc); return 0; } th->stack = stack_alloc(STACK_SIZE); set_thread_self(th); thread_set_regs(entry, th); return th->thread;}
开发者ID:rohsaini,项目名称:mkunity,代码行数:23,
示例13: DECLARE_TESTDECLARE_TEST( atomic, add ){ int num_threads = 32; int ithread; object_t threads[32]; for( ithread = 0; ithread < num_threads; ++ithread ) threads[ithread] = thread_create( add_thread, "add", THREAD_PRIORITY_NORMAL, 0 ); for( ithread = 0; ithread < num_threads; ++ithread ) thread_start( threads[ithread], 0 ); test_wait_for_threads_startup( threads, num_threads ); for( ithread = 0; ithread < num_threads; ++ithread ) thread_destroy( threads[ithread] ); test_wait_for_threads_exit( threads, num_threads ); EXPECT_EQ( val_32, 0 ); EXPECT_EQ( val_64, 0 ); return 0;}
开发者ID:NocturnDragon,项目名称:foundation_lib,代码行数:23,
示例14: mainint main(void) { LED_RED_ON;#ifdef LED_GREEN_OFF LED_GREEN_OFF;#endif timer_over_pid = thread_create(timer_over_buf, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, blinker, "blinker"); while(1) {#ifdef LED_GREEN_TOGGLE LED_GREEN_TOGGLE;#endif vtimer_usleep(SEC); } return 0;}
开发者ID:SilkeRieger,项目名称:projects,代码行数:23,
示例15: _handle_stats_requeststatic void _handle_stats_request(connection_t *con, http_parser_t *parser, char *uri){ stats_connection_t *stats; stats_event_inc(NULL, "stats_connections"); if (!connection_check_admin_pass(parser)) { ERROR0("Bad password for stats connection"); connection_close(con); httpp_destroy(parser); return; } stats_event_inc(NULL, "stats"); /* create stats connection and create stats handler thread */ stats = (stats_connection_t *)malloc(sizeof(stats_connection_t)); stats->parser = parser; stats->con = con; thread_create("Stats Connection", stats_connection, (void *)stats, THREAD_DETACHED);}
开发者ID:miksago,项目名称:icecast,代码行数:23,
示例16: nhdp_startkernel_pid_t nhdp_start(void){ if (nhdp_pid == KERNEL_PID_UNDEF) { /* Init destination address for NHDP's packets */ /* Start the NHDP thread */ nhdp_pid = thread_create(nhdp_stack, sizeof(nhdp_stack), THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST, _nhdp_runner, NULL, "NHDP");#if (NHDP_METRIC_NEEDS_TIMER) /* Configure periodic timer message to refresh metric values */ if (nhdp_pid != KERNEL_PID_UNDEF) { metric_interval = timex_from_uint64(DAT_REFRESH_INTERVAL * SEC_IN_USEC); metric_msg.type = NHDP_METRIC_TIMER; metric_msg.content.ptr = NULL; xtimer_set_msg64(&metric_timer, timex_uint64(metric_interval), metric_msg, nhdp_pid); }#endif } return nhdp_pid;}
开发者ID:AdamRLukaitis,项目名称:RIOT,代码行数:23,
示例17: fiboint fibo(int argc, const cmd_args *argv){ if (argc < 2) { printf("not enough args/n"); return -1; } lk_time_t tim = current_time(); thread_t *t = thread_create("fibo", &fibo_thread, (void *)(uintptr_t)argv[1].u, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE); thread_resume(t); int retcode; thread_join(t, &retcode, INFINITE_TIME); tim = current_time() - tim; printf("fibo %d/n", retcode); printf("took %u msecs to calculate/n", tim); return NO_ERROR;}
开发者ID:M1cha,项目名称:lk,代码行数:23,
示例18: _stats_cmdint _stats_cmd(int argc, char **argv){ if (argc != 2) { puts("Usage: stats [start|stop]"); return 1; } if (strcmp(argv[1], "start") == 0) { if (_stats_pid == KERNEL_PID_UNDEF) { _stats_pid = thread_create(stats_stack, sizeof(stats_stack), PRIO, THREAD_CREATE_STACKTEST, _stats_print, NULL, "stats"); } print_stats = true; } else if (strcmp(argv[1], "stop") == 0) { print_stats = false; } else { return 1; } return 0;}
开发者ID:cgundogan,项目名称:RIOT-APPS,代码行数:23,
示例19: smtsimu_initintsmtsimu_init (void){ AGENT *agent; /* Handle for our agent */ THREAD *thread; /* Handle to console thread */# include "smtsimu.i" /* Include dialog interpreter */ /* Shutdown event comes from Kernel */ declare_smtlib_shutdown (shutdown_event, SMT_PRIORITY_MAX); /* Alarm event sent by kernel to this agent */ declare_smttime_reply (alarm_event, 0); declare_smttime_error (error_event, 0); /* Ensure that operator console is running, else start it up */ smtoper_init (); if ((thread = thread_lookup (SMT_OPERATOR, "")) != NULL) operq = thread-> queue-> qid; else return (-1); /* Ensure that timer agent is running, else start it up */ if (smttime_init ()) return (-1); /* Create initial thread */ if ((thread = thread_create (AGENT_NAME, "")) != NULL) simuq = thread-> queue-> qid; else return (-1); /* Initialise static variables */ last_id = 0; /* Signal okay to caller that we initialised okay */ return (0);}
开发者ID:INNOAUS,项目名称:gsl,代码行数:37,
示例20: process_forkTID_t process_fork(void (*func)(int), int arg){ TID_t tid; thread_table_t *thread = thread_get_current_thread_entry(); process_id_t pid = thread->process_id; interrupt_status_t intr_status; thread_params_t params; params.done = 0; params.func = func; params.arg = arg; params.pid = pid; params.pagetable = thread->pagetable; intr_status = _interrupt_disable(); spinlock_acquire(&process_table_slock); tid = thread_create((void (*)(uint32_t))(setup_thread), (uint32_t)¶ms); if (tid < 0) { spinlock_release(&process_table_slock); _interrupt_set_state(intr_status); return -1; } process_table[pid].threads++; spinlock_release(&process_table_slock); _interrupt_set_state(intr_status); thread_run(tid); /* params will be dellocated when we return, so don't until the new thread is ready. */ while (!params.done); return tid;}
开发者ID:Eckankar,项目名称:OSM-G,代码行数:37,
示例21: ms_scan///-------------------------------------------------------------------------------------------------/// Begin a recursive scan of all paths previously provided to ms_add_path(). If async mode/// is enabled, this call will return immediately. You must obtain the file descriptor using/// ms_async_fd and this must be checked using an event loop or select(). When the fd becomes/// readable you must call ms_async_process to trigger any necessary callbacks.////// @author Andy Grundman/// @date 03/15/2011////// @param [in,out] s If non-null, the.////// ### remarks .///-------------------------------------------------------------------------------------------------void ms_scan(MediaScan *s) { if (s->on_result == NULL) { LOG_ERROR("Result callback not set, aborting scan/n"); goto out; } if (s->npaths == 0) { LOG_ERROR("No paths set, aborting scan/n"); goto out; } if (s->async) { thread_data_type *thread_data; thread_data = (thread_data_type *)calloc(sizeof(thread_data_type), 1); LOG_MEM("new thread_data @ %p/n", thread_data); thread_data->lpDir = NULL; thread_data->s = s; s->thread = thread_create(do_scan, thread_data, s->async_fds); if (!s->thread) { LOG_ERROR("Unable to start async thread/n"); goto out; } } else { thread_data_type thread_data; thread_data.s = s; thread_data.lpDir = NULL; do_scan(&thread_data); }out: return;} /* ms_scan() */
开发者ID:chincheta0815,项目名称:libmediascan,代码行数:50,
示例22: MainDelayExitvoid MainDelayExit( void ){ int i; pthread_t shutdownThreadId; LogPrintNoArg( LOG_CRIT, "Shutting down" ); /* Signal to all that we are aborting */ BotDone = FALSE; GlobalAbort = true; /* Unload all plugins (which should kill all associated threads) */ pluginUnloadAll(); /* Send out signals from all queues waking up anything waiting on them so * the listeners can unblock and die */ QueueKillAll(); /* Shut down IRC connections */ thread_create( &shutdownThreadId, bot_shutdown, NULL, "thread_shutdown", NULL ); /* Delay to allow all the other tasks to finish (esp. logging!) */ for( i = 15; i && !BotDone; i-- ) { sleep(1); } LogPrintNoArg(LOG_DEBUG, "Shutdown complete!" ); LogFlushOutput(); cursesAtExit(); /* And finally... die */ _exit( 0 );}
开发者ID:Beirdo,项目名称:beirdobot,代码行数:37,
示例23: init_transceivervoid init_transceiver(void){ kernel_pid_t radio_pid = thread_create( radio_stack_buffer, sizeof(radio_stack_buffer), PRIORITY_MAIN - 2, CREATE_STACKTEST, radio, NULL, "radio"); uint16_t transceivers = TRANSCEIVER_DEFAULT; transceiver_init(transceivers); transceiver_start(); transceiver_register(transceivers, radio_pid); msg_t mesg; mesg.type = SET_CHANNEL; mesg.content.ptr = (char *) &tcmd; uint16_t c = 10; tcmd.transceivers = TRANSCEIVER_DEFAULT; tcmd.data = &c; printf("Set transceiver to channel %u/n", c); msg_send(&mesg, transceiver_pid); mesg.type = SET_MONITOR; mesg.content.ptr = (char *) &tcmd; uint16_t v = 1; tcmd.data = &v; printf("Set transceiver into monitor mode/n"); msg_send(&mesg, transceiver_pid);}
开发者ID:OlegHahm,项目名称:applications,代码行数:37,
示例24: test_preemptivevoidtest_preemptive(){ int ret; long ii; Tid potato_tids[NPOTATO]; unintr_printf("starting preemptive test/n"); unintr_printf("this test will take %d seconds/n", DURATION / 1000000); gettimeofday(&pstart, NULL); /* spin for sometime, so you see the interrupt handler output */ spin(SIG_INTERVAL * 5); interrupts_quiet(); potato[0] = 1; for (ii = 1; ii < NPOTATO; ii++) { potato[ii] = 0; } for (ii = 0; ii < NPOTATO; ii++) { potato_tids[ii] = thread_create((void (*)(void *))do_potato, (void *)ii); assert(thread_ret_ok(potato_tids[ii])); } spin(DURATION); unintr_printf("cleaning hot potato/n"); for (ii = 0; ii < NPOTATO; ii++) { ret = thread_exit(THREAD_ANY); assert(thread_ret_ok(ret)); } unintr_printf("preemptive test done/n");}
开发者ID:vaibhavvijay,项目名称:ECE-344,代码行数:37,
示例25: shellvoid shell(void* user){ char buffer[MAX_INPUT]; int i; int command; char* operand; while(1){ print_str("/n Shell > "); i=0; buffer[i]='/0'; while(1){ if((*USART2_SR)&(USART_FLAG_RXNE)){ buffer[i]= (*USART2_DR) & 0xff; } if(buffer[i]==13 || buffer[i]=='/n'){ command = commandDetector(buffer); switch (command){ case NUL: break; case FIBONACCI: operand = &buffer[10]; if (thread_create(fibonacci, (void*)operand ) == -1) print_str("fibonacci creation failed/r/n"); break; case HELP: break; } break; }else if(buffer[i]=='/0'){ }else{ print_str(&buffer[i++]); } } bufferCleaner(buffer); }}
开发者ID:da255270,项目名称:mini-arm-os,代码行数:37,
示例26: thread_createint CMain::Run(){ if(m_Server.Init(this, m_Config.m_aBindAddr, m_Config.m_Port)) return 1; if(ReadConfig()) return 1; // Start JSON Update Thread m_JSONUpdateThreadData.m_ReloadRequired = 2; m_JSONUpdateThreadData.pClients = m_aClients; m_JSONUpdateThreadData.pConfig = &m_Config; void *LoadThread = thread_create(JSONUpdateThread, &m_JSONUpdateThreadData); //thread_detach(LoadThread); while(gs_Running) { if(gs_ReloadConfig) { if(ReadConfig()) return 1; m_Server.NetBan()->UnbanAll(); gs_ReloadConfig = 0; } m_Server.Update(); // wait for incomming data net_socket_read_wait(*m_Server.Network()->Socket(), 10); } dbg_msg("server", "Closing."); m_Server.Network()->Close(); thread_wait(LoadThread); return 0;}
开发者ID:def-,项目名称:ServerStatus,代码行数:37,
示例27: udpif_start_server/* start a new UDP server on given port */void udpif_start_server(uint16_t port, void(*ondata)(uint16_t src, char *data, int length)){ // allow only one server running at the same time - TODO this sucks, enable more then one! if (server_socket > 0) { printf("Error: UDP server already running/n"); return; } // open server socket server_socket = tl_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (server_socket < 0) { printf("Error: Unable to open UDP server socket/n"); } // set server address memset(&server_addr, 0, sizeof(server_addr)); server_addr.sin6_family = AF_INET; server_addr.sin6_port = HTONS(port); // bind server socket if (-1 == tl_socket_bind(server_socket, &server_addr, sizeof(server_addr))) { printf("Error: Binding the server socket failed!/n"); tl_socket_close(server_socket); } // set on data callback server_on_data = ondata; // start server thread int udpif_server_thread_pid = thread_create(server_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN, CREATE_STACKTEST, server_loop, "udp_server"); printf("UDP server started on port %d (Thread PID: %d)/n", port, udpif_server_thread_pid);}
开发者ID:OlegHahm,项目名称:SAFEST,代码行数:38,
示例28: test2void test2(void){ puts("first: sem_init"); if (sem_init(&s, 0, 0) != 0) { puts("first: sem_init FAILED"); } for (int i = 0; i < SEMAPHORE_TEST_THREADS; i++) { int priority = THREAD_PRIORITY_MAIN - (i + 3) % 10 + 1; snprintf(names[i], sizeof(names[i]), "priority %d", priority); printf("first: thread create: %d/n", priority); kernel_pid_t pid = thread_create(test2_thread_stack[i], sizeof(test2_thread_stack[i]), priority, CREATE_STACKTEST, priority_sema_thread, names[i], names[i]); if (pid == KERNEL_PID_UNDEF) { puts("first: thread create FAILED"); } printf("first: thread created: %s (%d/%d)/n", names[i], i + 1, SEMAPHORE_TEST_THREADS); } puts("------------------------------------------"); for (int i = 0; i < SEMAPHORE_TEST_THREADS; i++) { printf("post no. %d/n", i); sem_post(&s); puts("Back in main thread."); }}
开发者ID:4dahalibut,项目名称:RIOT,代码行数:36,
示例29: mainint main(void){ int tid; if (ide_detect(&ide) < 0) { uprint("ATA: No IDE controller found. Bye!"); return 1; } if (!ide_initialize(&ide)) { uprint("ATA: No disk have been detected. Bye!"); return 2; } uprint("ATA: configuration detected, creating devices ..."); for (int i = 0; i < 4; ++i) { if (ide.devices[i].exists) { tid = thread_create(driver_device_thread, 1, &ide.devices[i]); if (tid < 0) uprint("ATA: Fail to start thread"); } } while (1) sleep(1); return 0;}
开发者ID:Nakrez,项目名称:zOS,代码行数:36,
示例30: mainint main(void){ memcpy(&sx127x.params, sx127x_params, sizeof(sx127x_params)); netdev = (netdev_t*) &sx127x; netdev->driver = &sx127x_driver; netdev->driver->init(netdev); netdev->event_callback = _event_cb; _recv_pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST, _recv_thread, NULL, "recv_thread"); if (_recv_pid <= KERNEL_PID_UNDEF) { puts("Creation of receiver thread failed"); return 1; } /* start the shell */ puts("Initialization successful - starting the shell now"); char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0;}
开发者ID:jthacker,项目名称:RIOT,代码行数:24,
注:本文中的thread_create函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ thread_current函数代码示例 C++ thread_add_timer函数代码示例 |