MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / thread_create

Method thread_create

libraries/AP_HAL_Linux/Scheduler.cpp:409–433  ·  view source on GitHub ↗

create a new thread */

Source from the content-addressed store, hash-verified

407 create a new thread
408*/
409bool Scheduler::thread_create(AP_HAL::MemberProc proc, const char *name, uint32_t stack_size, priority_base base, int8_t priority)
410{
411 Thread *thread = NEW_NOTHROW Thread{(Thread::task_t)proc};
412 if (!thread) {
413 return false;
414 }
415
416 const uint8_t thread_priority = calculate_thread_priority(base, priority);
417
418 // Add 256k to HAL-independent requested stack size
419 thread->set_stack_size(256 * 1024 + stack_size);
420
421 /*
422 * We should probably store the thread handlers and join() when exiting,
423 * but let's the thread manage itself for now.
424 */
425 thread->set_auto_free(true);
426
427 if (!thread->start(name, SCHED_FIFO, thread_priority)) {
428 delete thread;
429 return false;
430 }
431
432 return true;
433}

Callers 1

initMethod · 0.45

Calls 3

set_stack_sizeMethod · 0.45
set_auto_freeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected