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

Function nxthread_create

sched/task/task_create.c:77–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 ****************************************************************************/
76
77int nxthread_create(FAR const char *name, uint8_t ttype, int priority,
78 FAR void *stack_addr, int stack_size, main_t entry,
79 FAR char * const argv[], FAR char * const envp[])
80{
81 FAR struct tcb_s *tcb;
82 pid_t pid;
83 int ret;
84
85 /* Allocate a TCB for the new task. */
86
87 tcb = kmm_zalloc(sizeof(struct tcb_s));
88 if (!tcb)
89 {
90 serr("ERROR: Failed to allocate TCB\n");
91 return -ENOMEM;
92 }
93
94 /* Setup the task type */
95
96 tcb->flags = ttype | TCB_FLAG_FREE_TCB;
97
98 /* Initialize the task */
99
100 ret = nxtask_init(tcb, name, priority,
101 stack_addr, stack_size, entry, argv, envp, NULL);
102 if (ret < OK)
103 {
104 kmm_free(tcb);
105 return ret;
106 }
107
108 /* Get the assigned pid before we start the task */
109
110 pid = tcb->pid;
111
112 /* Activate the task */
113
114 nxtask_activate(tcb);
115
116 return pid;
117}
118
119/****************************************************************************
120 * Name: nxtask_create

Callers 3

nx_create_initthreadFunction · 0.85
nxtask_createFunction · 0.85

Calls 4

kmm_zallocFunction · 0.85
nxtask_initFunction · 0.85
kmm_freeFunction · 0.85
nxtask_activateFunction · 0.85

Tested by

no test coverage detected