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

Function nxtask_spawn_exec

sched/task/task_spawn.c:186–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 ****************************************************************************/
185
186static int nxtask_spawn_exec(FAR pid_t *pidp, FAR const char *name,
187 main_t entry,
188 FAR const posix_spawn_file_actions_t *actions,
189 FAR const posix_spawnattr_t *attr,
190 FAR char * const *argv, FAR char * const envp[])
191{
192 FAR void *stackaddr = NULL;
193 size_t stacksize;
194 int priority;
195 int pid;
196 int ret = OK;
197
198 /* Use the default priority and stack size if no attributes are provided */
199
200 if (attr)
201 {
202 priority = attr->priority;
203 stacksize = attr->stacksize;
204 stackaddr = attr->stackaddr;
205 }
206 else
207 {
208 struct sched_param param;
209
210 /* Set the default priority to the same priority as this task */
211
212 ret = nxsched_get_param(0, &param);
213 if (ret < 0)
214 {
215 return ret;
216 }
217
218 priority = param.sched_priority;
219 stacksize = CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE;
220 }
221
222 /* Start the task */
223
224 pid = nxtask_spawn_create(name, priority, stackaddr,
225 stacksize, entry, argv,
226 envp ? envp : environ, actions, attr);
227 if (pid < 0)
228 {
229 ret = pid;
230 serr("ERROR: nxtask_spawn_create failed: %d\n", ret);
231 return ret;
232 }
233
234 /* Return the task ID to the caller */
235
236 if (pid)
237 {
238 *pidp = pid;
239 }
240
241 return ret;
242}
243

Callers 1

task_spawnFunction · 0.85

Calls 2

nxsched_get_paramFunction · 0.85
nxtask_spawn_createFunction · 0.85

Tested by

no test coverage detected