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

Function nxtask_setup_fork

sched/task/task_fork.c:96–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 ****************************************************************************/
95
96FAR struct tcb_s *nxtask_setup_fork(start_t retaddr)
97{
98 FAR struct tcb_s *ptcb = this_task();
99 FAR struct tcb_s *parent;
100 FAR struct tcb_s *child;
101 FAR char **argv;
102 size_t stack_size;
103 uint8_t ttype;
104 int priority;
105 int ret;
106
107 DEBUGASSERT(retaddr != NULL);
108
109 /* Get the type of the fork'ed task (kernel or user) */
110
111 if ((ptcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
112 {
113 /* Fork'ed from a kernel thread */
114
115 ttype = TCB_FLAG_TTYPE_KERNEL;
116 parent = ptcb;
117 }
118 else
119 {
120 /* Fork'ed from a user task or pthread */
121
122 ttype = TCB_FLAG_TTYPE_TASK;
123 if ((ptcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_TASK)
124 {
125 parent = ptcb;
126 }
127 else
128 {
129 parent = nxsched_get_tcb(ptcb->group->tg_pid);
130 if (parent == NULL)
131 {
132 ret = -ENOENT;
133 goto errout;
134 }
135 }
136 }
137
138 /* Allocate a TCB for the child task. */
139
140 child = kmm_zalloc(sizeof(struct tcb_s));
141 if (!child)
142 {
143 serr("ERROR: Failed to allocate TCB\n");
144 ret = -ENOMEM;
145 goto errout;
146 }
147
148 child->flags |= TCB_FLAG_FREE_TCB;
149
150 /* Initialize the task join */
151
152 nxtask_joininit(child);
153

Callers 7

sim_forkFunction · 0.85
riscv_forkFunction · 0.85
mips_forkFunction · 0.85
ceva_forkFunction · 0.85
arm64_forkFunction · 0.85
arm_forkFunction · 0.85
x86_64_forkFunction · 0.85

Calls 15

this_taskFunction · 0.85
nxsched_get_tcbFunction · 0.85
kmm_zallocFunction · 0.85
nxtask_joininitFunction · 0.85
group_allocateFunction · 0.85
addrenv_joinFunction · 0.85
env_dupFunction · 0.85
group_setuptaskfilesFunction · 0.85
nxsched_get_stackargsFunction · 0.85
nxtask_setup_nameFunction · 0.85
nxtask_setup_schedulerFunction · 0.85
tls_dup_infoFunction · 0.85

Tested by

no test coverage detected