MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / rt_thread_create

Function rt_thread_create

src/thread.c:550–587  ·  view source on GitHub ↗

* @brief This function will create a thread object and allocate thread object memory. * and stack. * * @param name The name of the thread (shall be unique.); the maximum length of * the thread name is specified by macro `RT_NAME_MAX` in `rtconfig.h`, * and the extra part is automatically truncated. * * @param entry Entry function of thread. * * @

Source from the content-addressed store, hash-verified

548 * If the return value is `RT_NULL`, it means this operation failed.
549 */
550rt_thread_t rt_thread_create(const char *name,
551 void (*entry)(void *parameter),
552 void *parameter,
553 rt_uint32_t stack_size,
554 rt_uint8_t priority,
555 rt_uint32_t tick)
556{
557 /* parameter check */
558 RT_ASSERT(tick != 0);
559
560 struct rt_thread *thread;
561 void *stack_start;
562
563 thread = (struct rt_thread *)rt_object_allocate(RT_Object_Class_Thread,
564 name);
565 if (thread == RT_NULL)
566 return RT_NULL;
567
568 stack_start = (void *)RT_KERNEL_MALLOC(stack_size);
569 if (stack_start == RT_NULL)
570 {
571 /* allocate stack failure */
572 rt_object_delete((rt_object_t)thread);
573
574 return RT_NULL;
575 }
576
577 _thread_init(thread,
578 name,
579 entry,
580 parameter,
581 stack_start,
582 stack_size,
583 priority,
584 tick);
585
586 return thread;
587}
588RTM_EXPORT(rt_thread_create);
589
590/**

Callers 15

finsh_system_initFunction · 0.85
mprotect_example_ro_dataFunction · 0.85
audio_speaker_initFunction · 0.85
audio_mic_initFunction · 0.85
rt_usbh_hub_initFunction · 0.85
rt_usbh_hid_kbd_initFunction · 0.85
rt_usbh_hid_mouse_initFunction · 0.85
lwp_execveFunction · 0.85
sys_thread_createFunction · 0.85
_sys_cloneFunction · 0.85
_sys_forkFunction · 0.85

Calls 3

rt_object_allocateFunction · 0.85
rt_object_deleteFunction · 0.85
_thread_initFunction · 0.85

Tested by 15

utest_thread_createFunction · 0.68
test_tcpFunction · 0.68
test_udpFunction · 0.68
sys_run_taskFunction · 0.68
gpio_output_taskFunction · 0.68
gpio_input_taskFunction · 0.68
uart_taskFunction · 0.68
adc_taskFunction · 0.68
usbd_taskFunction · 0.68
sys_run_taskFunction · 0.68
gpio_output_taskFunction · 0.68
gpio_input_taskFunction · 0.68