MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_pgrp_move

Function lwp_pgrp_move

components/lwp/lwp_pgrp.c:237–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237int lwp_pgrp_move(rt_processgroup_t group, rt_lwp_t process)
238{
239 int retry = 1;
240 rt_processgroup_t old_group;
241
242 /* parameter check */
243 if (group == RT_NULL || process == RT_NULL)
244 {
245 return -EINVAL;
246 }
247
248 if (lwp_pgid_get_bypgrp(group) == lwp_pgid_get_byprocess(process))
249 {
250 return 0;
251 }
252
253 PGRP_LOCK(group);
254 while (retry)
255 {
256 retry = 0;
257 old_group = lwp_pgrp_find_and_inc_ref(lwp_pgid_get_byprocess(process));
258
259 PGRP_LOCK(old_group);
260 LWP_LOCK(process);
261
262 if (process->pgrp == old_group)
263 {
264 lwp_pgrp_remove(old_group, process);
265 lwp_pgrp_insert(group, process);
266 }
267 else
268 {
269 retry = 1;
270 }
271 PGRP_UNLOCK(old_group);
272 LWP_UNLOCK(process);
273
274 lwp_pgrp_dec_ref(old_group);
275 }
276 PGRP_UNLOCK(group);
277
278 return 0;
279}
280
281int lwp_pgrp_update_children_info(rt_processgroup_t group, pid_t sid, pid_t pgid)
282{

Callers 2

sys_setsidFunction · 0.85
sys_setpgidFunction · 0.85

Calls 6

lwp_pgid_get_bypgrpFunction · 0.85
lwp_pgid_get_byprocessFunction · 0.85
lwp_pgrp_removeFunction · 0.85
lwp_pgrp_insertFunction · 0.85
lwp_pgrp_dec_refFunction · 0.85

Tested by

no test coverage detected