The main function of the Rt-thread system is located in the Startup.c file.
/** * This function would startup Rt-thread RTOS.*/voidRtthread_startup (void){ /*Init Board*/rt_hw_board_init ();//Nvic_config, Systick_config, Serial_device Register, set CONSOLE for Output (rt_kprintf (...)) in BOARD.C /*Show Version*/rt_show_version ();//Show the version of Rtthread by serial device (set to being console-device in BOARD.C) in kservice.c /*Init tick*/Rt_system_tick_init (); //empty fucntion (since 1.1.0) in Clock.c /*Init kernel Object*/rt_system_object_init ();//empty fucntion (since 0.3.0) in object.c /*Init timer System*/rt_system_timer_init ();//Init rt_timer_list[0].next=rt_timer_list[0].prev=rt_timer_list[0] (means Rt_timer_list is empty) in Timer.cRt_system_heap_init ((void*) Stm32_sram_begin, (void*) stm32_sram_end);//init system heap in MEM.C /*Init Scheduler System*/rt_system_scheduler_init ();//init the System scheduler, and init rt_thread_defunct (dead thread list) to is empty in scheduler.c /*init application*/Rt_application_init (); //init all defined thread in APPLICATION.C#ifdef Rt_using_finsh/*Init finsh*/Finsh_system_init (); //If use Components_init, and Init_component_export (Finsh_system_init) in shell.c, then it can be commenttedFinsh_set_device (Finsh_device_name);//sets the input device of Finsh shell (Rt_device_open (Dev, rt_device_oflag_rdwr | Rt_device_flag_int_rx | Rt_device_flag_stream) in Shell.c#endif /*init timer thread*/rt_system_timer_thread_init ();//init system software Timer thread (opened by #define Rt_using_timer_soft in rtconfig.h) in Timer.c /*init idle thread*/Rt_thread_idle_init (); //init idle thread (cleanup all dead thread), then start to is ready in idle.c /*Start Scheduler*/Rt_system_scheduler_start (); //Startup Scheduler (first swith to the highest priority thread and enable interrupt) in SCHEDULER.C /*never reach here*/ return ;}
int Main (void) { /**///enable interrupt (Cpsie I) when the first Thread switch (rt_hw_context_switch_to) in Lipcpu/cortex-m4/context_rvds. S rt_hw_interrupt_disable (); /* * /Rtthread_startup () ; return 0 ;}
Rt-thread Main Function Analysis