diff --git a/binfmt/binfmt_exec.c b/binfmt/binfmt_exec.c index e58d0ad8913b0..f97adfcb8a35b 100644 --- a/binfmt/binfmt_exec.c +++ b/binfmt/binfmt_exec.c @@ -81,7 +81,6 @@ static int exec_internal(FAR const char *filename, FAR const posix_spawnattr_t *attr, bool spawn) { FAR struct binary_s *bin; - irqstate_t flags; int pid; int ret; #ifndef CONFIG_BINFMT_LOADABLE @@ -133,14 +132,6 @@ static int exec_internal(FAR const char *filename, #endif } - /* Disable pre-emption so that the executed module does - * not return until we get a chance to connect the on_exit - * handler. - */ - - flags = enter_critical_section(); - sched_lock(); - /* Then start the module */ pid = exec_module(bin, filename, argv, envp, actions, attr, spawn); @@ -152,27 +143,9 @@ static int exec_internal(FAR const char *filename, goto errout_with_lock; } -#ifdef CONFIG_BINFMT_LOADABLE - /* Set up to unload the module (and free the binary_s structure) - * when the task exists. - */ - - ret = group_exitinfo(pid, bin); - if (ret < 0) - { - berr("ERROR: Failed to schedule unload '%s': %d\n", filename, ret); - goto errout_with_lock; - } - -#endif - - sched_unlock(); - leave_critical_section(flags); return pid; errout_with_lock: - sched_unlock(); - leave_critical_section(flags); unload_module(bin); errout_with_bin: #ifdef CONFIG_BINFMT_LOADABLE diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index 424678a1ec44e..c8cd9f7b753ff 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -354,6 +354,10 @@ int exec_module(FAR struct binary_s *binp, } } +#ifdef CONFIG_BINFMT_LOADABLE + tcb->group->tg_bininfo = binp; +#endif + /* Then activate the task at the provided priority */ nxtask_activate(tcb); diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index facbff4d5c4f2..d73cae8bc08d7 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -1168,31 +1168,6 @@ void nxtask_abort_fork(FAR struct tcb_s *child, int errcode); size_t nxtask_argvstr(FAR struct tcb_s *tcb, FAR char *args, size_t size); -/**************************************************************************** - * Name: group_exitinfo - * - * Description: - * This function may be called to when a task is loaded into memory. It - * will setup the to automatically unload the module when the task exits. - * - * Input Parameters: - * pid - The task ID of the newly loaded task - * bininfo - This structure allocated with kmm_malloc(). This memory - * persists until the task exits and will be used unloads - * the module from memory. - * - * 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. - * - ****************************************************************************/ - -#ifdef CONFIG_BINFMT_LOADABLE -struct binary_s; /* Forward reference */ -int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo); -#endif - /**************************************************************************** * Name: nxsched_get_param * diff --git a/sched/group/CMakeLists.txt b/sched/group/CMakeLists.txt index cec78f235132f..c1e445b567f29 100644 --- a/sched/group/CMakeLists.txt +++ b/sched/group/CMakeLists.txt @@ -56,10 +56,6 @@ if(CONFIG_SIG_SIGSTOP_ACTION) list(APPEND SRCS group_suspendchildren.c group_continue.c) endif() -if(CONFIG_BINFMT_LOADABLE) - list(APPEND SRCS group_exitinfo.c) -endif() - if(CONFIG_MM_KERNEL_HEAP) list(APPEND SRCS group_malloc.c group_realloc.c group_zalloc.c group_free.c) endif() diff --git a/sched/group/Make.defs b/sched/group/Make.defs index 61f0a03ec9a21..e65a883e1f018 100644 --- a/sched/group/Make.defs +++ b/sched/group/Make.defs @@ -43,10 +43,6 @@ ifeq ($(CONFIG_SIG_SIGSTOP_ACTION),y) CSRCS += group_suspendchildren.c group_continue.c endif -ifeq ($(CONFIG_BINFMT_LOADABLE),y) -CSRCS += group_exitinfo.c -endif - ifeq ($(CONFIG_MM_KERNEL_HEAP),y) CSRCS += group_malloc.c group_realloc.c group_zalloc.c group_free.c endif diff --git a/sched/group/group_exitinfo.c b/sched/group/group_exitinfo.c deleted file mode 100644 index e82a72e420cea..0000000000000 --- a/sched/group/group_exitinfo.c +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** - * sched/group/group_exitinfo.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "sched/sched.h" -#include "group/group.h" - -#ifdef CONFIG_BINFMT_LOADABLE - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: group_exitinfo - * - * Description: - * This function may be called to when a task is loaded into memory. It - * will setup the to automatically unload the module when the task exits. - * - * Input Parameters: - * pid - The task ID of the newly loaded task - * bininfo - This structure allocated with kmm_malloc(). This memory - * persists until the task exits and will be used unloads - * the module from memory. - * - * 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 group_exitinfo(pid_t pid, FAR struct binary_s *bininfo) -{ - FAR struct tcb_s *tcb; - FAR struct task_group_s *group; - irqstate_t flags; - - DEBUGASSERT(bininfo != NULL); - flags = enter_critical_section(); - - /* Get the TCB associated with the PID */ - - tcb = nxsched_get_tcb(pid); - if (tcb == NULL) - { - leave_critical_section(flags); - return -ESRCH; - } - - /* Get the group that this task belongs to */ - - group = tcb->group; - DEBUGASSERT(group != NULL && group->tg_bininfo == NULL); - - /* Save the binary info for use when the task exits */ - - group->tg_bininfo = bininfo; - - leave_critical_section(flags); - return OK; -} - -#endif /* CONFIG_BINFMT_LOADABLE */