You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2023/02/02 19:25:28 UTC

[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8355: arch/addrenv: Refactor address environment handling, by moving tg_addrenv out of the group structure

xiaoxiang781216 commented on code in PR #8355:
URL: https://github.com/apache/nuttx/pull/8355#discussion_r1094979080


##########
arch/arm/src/armv7-a/arm_addrenv.c:
##########
@@ -98,8 +98,6 @@
 #include <assert.h>
 #include <debug.h>
 
-#include <nuttx/addrenv.h>

Review Comment:
   move to the first patch



##########
include/nuttx/sched.h:
##########
@@ -532,6 +526,12 @@ struct tcb_s
 
   FAR struct task_group_s *group;      /* Pointer to shared task group data */
 
+  /* Address Environment ****************************************************/
+
+#ifdef CONFIG_ARCH_ADDRENV
+  FAR struct addrenv_s *mm_own;         /* Task (group) own memory mappings */

Review Comment:
   mm_own->addrenv



##########
include/nuttx/addrenv.h:
##########
@@ -359,6 +367,117 @@ int addrenv_switch(FAR struct tcb_s *tcb);
 int addrenv_attach(FAR struct tcb_s *tcb,
                    FAR const struct arch_addrenv_s *addrenv);
 
+/****************************************************************************
+ * Name: addrenv_join
+ *
+ * Description:
+ *   Join the parent process's address environment.
+ *
+ * Input Parameters:
+ *   ptcb - The tcb of the parent process.
+ *   tcb  - The tcb of the child process.
+ *
+ * Returned Value:
+ *   This is a NuttX internal function so it follows the convention that
+ *   0 (OK) is returned on success and a negated errno is returned on
+ *   failure.
+ *
+ ****************************************************************************/
+
+int addrenv_join(FAR struct tcb_s *ptcb, FAR struct tcb_s *tcb);
+
+/****************************************************************************
+ * Name: addrenv_leave
+ *
+ * Description:
+ *   Leave a process's address environment.
+ *
+ * Input Parameters:
+ *   tcb  - The tcb of the process.
+ *
+ * Returned Value:
+ *   This is a NuttX internal function so it follows the convention that
+ *   0 (OK) is returned on success and a negated errno is returned on
+ *   failure.
+ *
+ ****************************************************************************/
+
+int addrenv_leave(FAR struct tcb_s *tcb);
+
+/****************************************************************************
+ * Name: addrenv_take
+ *
+ * Description:
+ *   Take a reference to an address environment.
+ *
+ * Input Parameters:
+ *   addrenv - The address environment.
+ *
+ * Returned Value:
+ *   This is a NuttX internal function so it follows the convention that
+ *   0 (OK) is returned on success and a negated errno is returned on
+ *   failure.
+ *
+ ****************************************************************************/
+
+void addrenv_take(FAR struct addrenv_s *addrenv);
+
+/****************************************************************************
+ * Name: addrenv_take
+ *
+ * Description:
+ *   Take a reference to an address environment.
+ *
+ * Input Parameters:
+ *   addrenv - The address environment.
+ *
+ * Returned Value:
+ *   This is a NuttX internal function so it follows the convention that
+ *   0 (OK) is returned on success and a negated errno is returned on
+ *   failure.
+ *
+ ****************************************************************************/
+
+void addrenv_take(FAR struct addrenv_s *addrenv);

Review Comment:
   remove dup with line 423



##########
sched/addrenv/addrenv.c:
##########
@@ -52,6 +53,39 @@
 
 static FAR struct addrenv_s *g_addrenv[CONFIG_SMP_NCPUS];
 
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: addrenv_dsr
+ *
+ * Description:
+ *   Deferred service routine for destroying an address environment. This is
+ *   so that the heavy lifting is not done when the context is switching, or
+ *   from ISR.
+ *
+ * Input Parameters:
+ *   arg - Contains pointer to the address environment that is freed.
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void addrenv_dsr(FAR void *arg)

Review Comment:
   addrenv_dsr->addrenv_destroy



##########
sched/sched/sched_releasetcb.c:
##########
@@ -154,7 +154,11 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t ttype)
 #ifdef CONFIG_ARCH_ADDRENV
       /* Release this thread's reference to the address environment */
 
-      ret = up_addrenv_detach(tcb->group, tcb);
+      ret = up_addrenv_detach(tcb);
+      if (ttype == TCB_FLAG_TTYPE_TASK)

Review Comment:
   how to handle the main thread exit before other threads in the same task



-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org