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

Function _thread_init

src/thread.c:176–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176static rt_err_t _thread_init(struct rt_thread *thread,
177 const char *name,
178 void (*entry)(void *parameter),
179 void *parameter,
180 void *stack_start,
181 rt_uint32_t stack_size,
182 rt_uint8_t priority,
183 rt_uint32_t tick)
184{
185 RT_UNUSED(name);
186
187 rt_sched_thread_init_ctx(thread, tick, priority);
188
189#ifdef RT_USING_MEM_PROTECTION
190 thread->mem_regions = RT_NULL;
191#endif
192
193#ifdef RT_USING_SMART
194 thread->wakeup_handle.func = RT_NULL;
195#endif
196
197 thread->entry = (void *)entry;
198 thread->parameter = parameter;
199
200 /* stack init */
201 thread->stack_addr = stack_start;
202 thread->stack_size = stack_size;
203
204 /* init thread stack */
205 rt_memset(thread->stack_addr, '#', thread->stack_size);
206#ifdef RT_USING_HW_STACK_GUARD
207 rt_hw_stack_guard_init(thread);
208#endif
209#ifdef ARCH_CPU_STACK_GROWS_UPWARD
210 thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
211 (void *)((char *)thread->stack_addr),
212 (void *)_thread_exit);
213#else
214 thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
215 (rt_uint8_t *)((char *)thread->stack_addr + thread->stack_size - sizeof(rt_ubase_t)),
216 (void *)_thread_exit);
217#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
218
219#ifdef RT_USING_MUTEX
220 rt_list_init(&thread->taken_object_list);
221 thread->pending_object = RT_NULL;
222#endif
223
224#ifdef RT_USING_EVENT
225 thread->event_set = 0;
226 thread->event_info = 0;
227#endif /* RT_USING_EVENT */
228
229 /* error and flags */
230 thread->error = RT_EOK;
231
232 /* lock init */
233#ifdef RT_USING_SMP

Callers 2

rt_thread_initFunction · 0.85
rt_thread_createFunction · 0.85

Calls 7

rt_sched_thread_init_ctxFunction · 0.85
rt_memsetFunction · 0.85
rt_list_initFunction · 0.85
rt_timer_initFunction · 0.85
rt_spin_lock_initFunction · 0.70
rt_hw_stack_guard_initFunction · 0.50
rt_hw_stack_initFunction · 0.50

Tested by

no test coverage detected