MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_thread_idle_init

Function rt_thread_idle_init

src/idle.c:165–203  ·  view source on GitHub ↗

* @brief This function will initialize idle thread, then start it. * * @note this function must be invoked when system init. */

Source from the content-addressed store, hash-verified

163 * @note this function must be invoked when system init.
164 */
165void rt_thread_idle_init(void)
166{
167 rt_ubase_t i;
168#if RT_NAME_MAX > 0
169 char idle_thread_name[RT_NAME_MAX];
170#endif /* RT_NAME_MAX > 0 */
171
172#ifdef RT_USING_IDLE_HOOK
173 rt_spin_lock_init(&_hook_spinlock);
174#endif
175
176 for (i = 0; i < _CPUS_NR; i++)
177 {
178#if RT_NAME_MAX > 0
179 rt_snprintf(idle_thread_name, RT_NAME_MAX, "tidle%d", i);
180#endif /* RT_NAME_MAX > 0 */
181 rt_thread_init(&idle_thread[i],
182#if RT_NAME_MAX > 0
183 idle_thread_name,
184#else
185 "tidle",
186#endif /* RT_NAME_MAX > 0 */
187 idle_thread_entry,
188 RT_NULL,
189 &idle_thread_stack[i][0],
190 sizeof(idle_thread_stack[i]),
191 RT_THREAD_PRIORITY_MAX - 1,
192 32);
193#ifdef RT_USING_SMP
194 rt_thread_control(&idle_thread[i], RT_THREAD_CTRL_BIND_CPU, (void*)i);
195#endif /* RT_USING_SMP */
196
197 /* update */
198 rt_cpu_index(i)->idle_thread = &idle_thread[i];
199
200 /* startup */
201 rt_thread_startup(&idle_thread[i]);
202 }
203}
204
205/**
206 * @brief This function will get the handler of the idle thread.

Callers 15

rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
rtthread_startupFunction · 0.85

Calls 6

rt_snprintfFunction · 0.85
rt_thread_initFunction · 0.85
rt_thread_controlFunction · 0.85
rt_thread_startupFunction · 0.85
rt_spin_lock_initFunction · 0.70
rt_cpu_indexFunction · 0.70

Tested by

no test coverage detected