xiaoxiang781216 commented on code in PR #10380:
URL: https://github.com/apache/nuttx/pull/10380#discussion_r1317012001
##########
binfmt/binfmt_exec.c:
##########
@@ -36,6 +36,98 @@
#ifndef CONFIG_BINFMT_DISABLE
+/****************************************************************************
+ * Internel Functions
Review Comment:
```suggestion
* Private Functions
```
##########
binfmt/binfmt_exec.c:
##########
@@ -36,6 +36,98 @@
#ifndef CONFIG_BINFMT_DISABLE
+/****************************************************************************
+ * Internel Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: update_attr
+ *
+ * Description:
+ * Update the bin spawn attribute.
+ *
+ * Input Parameters:
+ * bin - The binrary information.
+ * attr - The spawn attributes.
+ *
+ * Returned Value:
+ * none
+ *
+ ****************************************************************************/
+
+static inline void update_attr(FAR struct binary_s *bin,
+ FAR const posix_spawnattr_t *attr)
+{
+ if (bin != NULL && attr != NULL)
+ {
+ if (attr->priority > 0)
+ {
+ bin->priority = attr->priority;
+ }
+
+ if (attr->stacksize > 0)
+ {
+ bin->stacksize = attr->stacksize;
+ }
+
+#ifndef CONFIG_BUILD_KERNEL
+ if (attr->stackaddr != NULL)
+ {
+ bin->stackaddr = attr->stackaddr;
+ }
+#endif
+ }
+}
+
+/****************************************************************************
+ * Internel Functions
Review Comment:
remove
##########
binfmt/binfmt_execmodule.c:
##########
@@ -292,6 +379,11 @@ int exec_module(FAR struct binary_s *binp,
}
#endif
+ if (spawn)
Review Comment:
```suggestion
if (!spawn)
```
##########
binfmt/binfmt_exec.c:
##########
@@ -141,25 +215,115 @@ int exec_spawn(FAR const char *filename, FAR char *
const *argv,
goto errout_with_lock;
}
-#ifdef CONFIG_BINFMT_LOADABLE
- /* Set up to unload the module (and free the binary_s structure)
- * when the task exists.
- */
+ /* Release the bin memory */
- ret = group_exitinfo(pid, bin);
+ ret = release_bin(bin, pid);
+
+ sched_unlock();
+ leave_critical_section(flags);
+ return pid;
+
+errout_with_lock:
+ sched_unlock();
+ leave_critical_section(flags);
+ unload_module(bin);
+errout_with_bin:
+ kmm_free(bin);
+errout:
+ return ret;
+}
+
+/****************************************************************************
+ * Internel Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: exec_spawn_internel
Review Comment:
move to private section
##########
binfmt/binfmt_exec.c:
##########
@@ -141,25 +215,115 @@ int exec_spawn(FAR const char *filename, FAR char *
const *argv,
goto errout_with_lock;
}
-#ifdef CONFIG_BINFMT_LOADABLE
- /* Set up to unload the module (and free the binary_s structure)
- * when the task exists.
- */
+ /* Release the bin memory */
- ret = group_exitinfo(pid, bin);
+ ret = release_bin(bin, pid);
+
+ sched_unlock();
+ leave_critical_section(flags);
+ return pid;
+
+errout_with_lock:
+ sched_unlock();
+ leave_critical_section(flags);
+ unload_module(bin);
+errout_with_bin:
+ kmm_free(bin);
+errout:
+ return ret;
+}
+
+/****************************************************************************
+ * Internel Functions
Review Comment:
remove
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]