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

Function nxtask_spawn_create

sched/task/task_spawn.c:82–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 ****************************************************************************/
81
82static int nxtask_spawn_create(FAR const char *name, int priority,
83 FAR void *stack_addr, int stack_size,
84 main_t entry, FAR char * const argv[],
85 FAR char * const envp[],
86 FAR const posix_spawn_file_actions_t *actions,
87 FAR const posix_spawnattr_t *attr)
88{
89 FAR struct tcb_s *tcb;
90 pid_t pid;
91 int ret;
92
93 /* Allocate a TCB for the new task. */
94
95 tcb = kmm_zalloc(sizeof(struct tcb_s));
96 if (tcb == NULL)
97 {
98 serr("ERROR: Failed to allocate TCB\n");
99 return -ENOMEM;
100 }
101
102 /* Setup the task type */
103
104 tcb->flags = TCB_FLAG_TTYPE_TASK | TCB_FLAG_FREE_TCB;
105
106 /* Initialize the task */
107
108 ret = nxtask_init(tcb, name, priority, stack_addr, stack_size,
109 entry, argv, envp, actions);
110 if (ret < OK)
111 {
112 kmm_free(tcb);
113 return ret;
114 }
115
116 /* Get the assigned pid before we start the task */
117
118 pid = tcb->pid;
119
120 /* Set the attributes */
121
122 if (attr)
123 {
124 ret = spawn_execattrs(pid, attr);
125 if (ret < 0)
126 {
127 goto errout_with_taskinit;
128 }
129 }
130
131 /* Activate the task */
132
133 nxtask_activate(tcb);
134
135 return pid;
136
137errout_with_taskinit:
138 nxtask_uninit(tcb);
139 return ret;

Callers 1

nxtask_spawn_execFunction · 0.85

Calls 6

kmm_zallocFunction · 0.85
nxtask_initFunction · 0.85
kmm_freeFunction · 0.85
spawn_execattrsFunction · 0.85
nxtask_activateFunction · 0.85
nxtask_uninitFunction · 0.85

Tested by

no test coverage detected