int main(int argc,char* argv[]) { int rc; /** caribou_init() must first be called before any other CARIBOU function calls */ caribou_init(0); /** Allocate and start up the enqueue and dequeue threads... */ caribou_thread_create("thread1",thread1,NULL,NULL,stack1,THREAD_STACK_SIZE,THREAD_PRIORITY); caribou_thread_create("thread2",thread2,NULL,NULL,stack2,THREAD_STACK_SIZE,THREAD_PRIORITY); /** * House keep chores are managed from the main thread, and must be called via caribou_exec() * Never to return * No sleeping in the main thread! */ caribou_exec(); }
int main(int argc,char* argv[]) { int rc; /** caribou_init() must first be called before any other CARIBOU function calls */ caribou_init(0); print_summary(); /** Initialize a mutex object */ caribou_mutex_init(&test.mutex_a,0); /** Initialize a queue of the specified depth */ caribou_queue_init(&test.queue_a,QUEUE_DEPTH,&test.queue_msgs); /** Allocate and start up the enqueue and dequeue threads... */ caribou_thread_create("test1_thread",test1_thread,NULL,NULL,test.stack_thread1,THREAD_STACK_SIZE,THREAD_PRIORITY); caribou_thread_create("test2_thread",test2_thread,NULL,NULL,test.stack_thread2,THREAD_STACK_SIZE,THREAD_PRIORITY); caribou_thread_create("board_thread",board_thread,NULL,NULL,test.board_stack,THREAD_STACK_SIZE,THREAD_PRIORITY); /** * House keep chores are managed from the main thread, and must be called via caribou_exec() * Never to return */ caribou_exec(); }
void network_init() { LwIP_Init(); #if defined(USE_DHCP) caribou_thread_create("dhcp",LwIP_DHCP_task,NULL,NULL,stack_dhcp_thread,THREAD_STACK_SIZE,THREAD_PRIORITY); #endif }
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) { sys_thread_t newthread = malloc(sizeof(sys_thread_wrapper_t)); if (newthread) { void* stack = malloc(stacksize); if ( stack ) { int lock_state = caribou_lock(); newthread->next = lwip_system_threads; lwip_system_threads = newthread; caribou_lock_set(lock_state); newthread->timeouts = NULL; newthread->caribou_thread = caribou_thread_create("lwip",thread,NULL,arg,stack,stacksize,prio); if ( !newthread->caribou_thread ) { free(stack); free(newthread); newthread=NULL; } } else { free(newthread); newthread=NULL; } } return NULL; }
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) { sys_thread_t newthread = malloc(sizeof(sys_thread_wrapper_t)); if (newthread) { #if !defined(CARIBOU_MPU_ENABLED) void* stack = malloc(stacksize); if ( stack ) { #endif int lock_state = caribou_lock(); newthread->next = lwip_system_threads; lwip_system_threads = newthread; caribou_lock_set(lock_state); newthread->timeouts = NULL; #if defined(CARIBOU_MPU_ENABLED) newthread->thread = caribou_thread_create(name,thread,NULL,arg,NULL,stacksize,prio); #else newthread->thread = caribou_thread_create(name,thread,NULL,arg,stack,stacksize,prio); #endif if ( !newthread->thread ) { #if !defined(CARIBOU_MPU_ENABLED) free(stack); #endif free(newthread); newthread=NULL; } #if !defined(CARIBOU_MPU_ENABLED) } else { free(newthread); newthread=NULL; } #endif } return newthread; }