MCPcopy Create free account
hub / github.com/apache/nuttx / nx_pthread_create

Function nx_pthread_create

sched/pthread/pthread_create.c:183–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181 ****************************************************************************/
182
183int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
184 FAR const pthread_attr_t *attr,
185 pthread_startroutine_t entry, pthread_addr_t arg)
186{
187 pthread_attr_t default_attr = g_default_pthread_attr;
188 FAR struct tcb_s *ptcb;
189 struct sched_param param;
190 FAR struct tcb_s *parent;
191 int policy;
192 int errcode;
193 int ret;
194
195 DEBUGASSERT(trampoline != NULL);
196
197 parent = this_task();
198 DEBUGASSERT(parent != NULL);
199
200 /* If attributes were not supplied, use the default attributes */
201
202 if (!attr)
203 {
204 /* Inherit parent priority by default. except idle */
205
206 if (!is_idle_task(parent))
207 {
208 default_attr.priority = parent->sched_priority;
209 }
210
211 attr = &default_attr;
212 }
213
214 /* Allocate a TCB for the new task. */
215
216 ptcb = kmm_zalloc(sizeof(struct tcb_s) + sizeof(struct pthread_entry_s));
217 if (!ptcb)
218 {
219 serr("ERROR: Failed to allocate TCB\n");
220 return ENOMEM;
221 }
222
223 ptcb->flags |= TCB_FLAG_FREE_TCB;
224
225 /* Initialize the task join */
226
227 nxtask_joininit(ptcb);
228
229 /* Bind the parent's group to the new TCB (we have not yet joined the
230 * group).
231 */
232
233 group_bind(ptcb);
234
235#ifdef CONFIG_ARCH_ADDRENV
236 /* Share the address environment of the parent task group. */
237
238 ret = addrenv_join(this_task(), ptcb);
239 if (ret < 0)
240 {

Callers 1

pthread_createFunction · 0.85

Calls 15

this_taskFunction · 0.85
kmm_zallocFunction · 0.85
nxtask_joininitFunction · 0.85
group_bindFunction · 0.85
addrenv_joinFunction · 0.85
nxsched_get_paramFunction · 0.85
nxsched_get_schedulerFunction · 0.85
nxsched_start_sporadicFunction · 0.85
pthread_setup_schedulerFunction · 0.85
tls_init_infoFunction · 0.85
pthread_tcb_setupFunction · 0.85

Tested by

no test coverage detected