pussuw commented on code in PR #7966: URL: https://github.com/apache/nuttx/pull/7966#discussion_r1060147291
########## include/nuttx/sched.h: ########## @@ -525,6 +526,9 @@ struct tcb_s /* Task Group *************************************************************/ +#ifdef CONFIG_ARCH_ADDRENV + FAR struct task_group_s *mm_group; /* Active memory mappings group */ Review Comment: I think one of my comments got lost, the reason we need mm_group and group separately, is that when a process is destroyed it detaches the group from tcb->group in group_leave.c ``` void group_leave(FAR struct tcb_s *tcb) { ... /* In any event, we can detach the group from the TCB so that we won't * do this again. */ tcb->group = NULL; } } ``` The address environment however might still be needed: - The process itself needs it if it is running (and it always is in this case). If a context switch (or IRQ!) happens after this, group_addrenv() crashes when the process is re-scheduled, because the ready-to-run head does not have a valid tcb->group any more. - If the next thread is a kernel thread, it will need this process's address environment to run This code is good and I would not modify it. So I added a safe reference "mm_group" that will contain the group whose address environment is in use. - For user processes this is always its own group. - For kernel threads this is NULL, if the thread is not running, and contains the last user process's group if it is running -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org