You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/02/09 13:21:53 UTC

[incubator-nuttx] branch master updated (845640b -> ef3219e)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 845640b  serial/pty: Decouple SUSv1 style from pseudo fs operation
     new 6814b14  Revert "pthread: Avoid recursive pthread_exit call"
     new c0a0de9  Revert "libc: Call pthread_exit in user-space by up_pthread_exit"
     new 8bf7f94  pthread: Call cleanup callback while asyncrhonous cancel
     new 9d91d69  arch/risc-v/mpfs: Remove riscv_pthread_exit.c in Make.defs
     new ef3219e  boards: Refresh all configs

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/a1x/Make.defs                         |  1 -
 arch/arm/src/am335x/Make.defs                      |  1 -
 arch/arm/src/armv6-m/arm_svcall.c                  | 43 ++------------
 arch/arm/src/armv6-m/svcall.h                      |  6 +-
 arch/arm/src/armv7-a/arm_syscall.c                 | 43 +++++---------
 arch/arm/src/armv7-a/svcall.h                      | 11 +---
 arch/arm/src/armv7-m/arm_svcall.c                  | 41 ++------------
 arch/arm/src/armv7-m/svcall.h                      | 13 +----
 arch/arm/src/armv7-r/arm_syscall.c                 | 47 ++++++---------
 arch/arm/src/armv8-m/arm_svcall.c                  | 43 ++------------
 arch/arm/src/common/arm_pthread_exit.c             | 66 ----------------------
 arch/arm/src/cxd56xx/Make.defs                     |  1 -
 arch/arm/src/efm32/Make.defs                       |  1 -
 arch/arm/src/eoss3/Make.defs                       |  1 -
 arch/arm/src/imx6/Make.defs                        |  1 -
 arch/arm/src/imxrt/Make.defs                       |  1 -
 arch/arm/src/kinetis/Make.defs                     |  1 -
 arch/arm/src/kl/Make.defs                          |  1 -
 arch/arm/src/lc823450/Make.defs                    |  1 -
 arch/arm/src/lpc17xx_40xx/Make.defs                |  1 -
 arch/arm/src/lpc43xx/Make.defs                     |  1 -
 arch/arm/src/lpc54xx/Make.defs                     |  1 -
 arch/arm/src/max326xx/Make.defs                    |  1 -
 arch/arm/src/nrf52/Make.defs                       |  1 -
 arch/arm/src/nuc1xx/Make.defs                      |  1 -
 arch/arm/src/rp2040/Make.defs                      |  1 -
 arch/arm/src/s32k1xx/Make.defs                     |  1 -
 arch/arm/src/sam34/Make.defs                       |  1 -
 arch/arm/src/sama5/Make.defs                       |  1 -
 arch/arm/src/samd2l2/Make.defs                     |  1 -
 arch/arm/src/samd5e5/Make.defs                     |  1 -
 arch/arm/src/samv7/Make.defs                       |  1 -
 arch/arm/src/stm32/Make.defs                       |  2 +-
 arch/arm/src/stm32f0l0g0/Make.defs                 |  1 -
 arch/arm/src/stm32f7/Make.defs                     |  1 -
 arch/arm/src/stm32h7/Make.defs                     |  1 -
 arch/arm/src/stm32l4/Make.defs                     |  1 -
 arch/arm/src/stm32l5/Make.defs                     |  1 -
 arch/arm/src/tiva/Make.defs                        |  1 -
 arch/arm/src/tms570/Make.defs                      |  1 -
 arch/arm/src/xmc4/Make.defs                        |  1 -
 arch/or1k/src/common/up_pthread_start.c            |  2 +-
 arch/risc-v/src/c906/Make.defs                     |  1 -
 arch/risc-v/src/common/riscv_pthread_exit.c        | 64 ---------------------
 arch/risc-v/src/common/riscv_swint.c               | 45 +++------------
 arch/risc-v/src/common/svcall.h                    | 15 ++---
 arch/risc-v/src/k210/Make.defs                     |  3 +-
 arch/risc-v/src/mpfs/Make.defs                     |  2 +-
 .../arm/imxrt/imxrt1050-evk/configs/knsh/defconfig |  2 +-
 .../arm/imxrt/imxrt1060-evk/configs/knsh/defconfig |  2 +-
 .../arm/imxrt/imxrt1064-evk/configs/knsh/defconfig |  2 +-
 .../lc823450/lc823450-xgevk/configs/knsh/defconfig |  2 +-
 .../lc823450-xgevk/configs/kostest/defconfig       |  2 +-
 .../lc823450-xgevk/configs/krndis/defconfig        |  2 +-
 .../lpc4088-devkit/configs/knsh/defconfig          |  2 +-
 .../lpc4088-quickstart/configs/knsh/defconfig      |  2 +-
 .../lpc17xx_40xx/open1788/configs/knsh/defconfig   |  2 +-
 .../open1788/configs/knxterm/defconfig             |  2 +-
 .../lpc17xx_40xx/pnev5180b/configs/knsh/defconfig  |  2 +-
 .../lpc43xx/bambino-200e/configs/knsh/defconfig    |  2 +-
 boards/arm/sam34/sam3u-ek/configs/knsh/defconfig   |  2 +-
 boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig |  2 +-
 .../arm/samv7/samv71-xult/configs/knsh/defconfig   |  2 +-
 .../stm32/clicker2-stm32/configs/knsh/defconfig    |  2 +-
 .../stm32/mikroe-stm32f4/configs/kostest/defconfig |  2 +-
 .../stm32/olimex-stm32-p407/configs/kelf/defconfig |  2 +-
 .../olimex-stm32-p407/configs/kmodule/defconfig    |  2 +-
 .../stm32/olimex-stm32-p407/configs/knsh/defconfig |  2 +-
 .../stm32/stm3240g-eval/configs/knxwm/defconfig    |  2 +-
 .../stm32f4discovery/configs/kostest/defconfig     |  2 +-
 .../stm32l476vg-disco/configs/knsh/defconfig       |  2 +-
 .../stm32l4r9ai-disco/configs/knsh/defconfig       |  2 +-
 .../lm3s6965-ek/configs/qemu-protected/defconfig   |  2 +-
 .../risc-v/c906/smartl-c906/configs/knsh/defconfig |  2 +-
 boards/risc-v/k210/maix-bit/configs/knsh/defconfig |  2 +-
 .../k210/maix-bit/configs/knsh_smp/defconfig       |  2 +-
 .../risc-v/k210/maix-bit/configs/kostest/defconfig |  2 +-
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig   |  2 +-
 include/nuttx/arch.h                               | 23 +-------
 include/nuttx/pthread.h                            |  8 +--
 include/nuttx/sched.h                              |  4 +-
 include/pthread.h                                  |  2 -
 include/sys/syscall_lookup.h                       |  2 +-
 libs/libc/pthread/pthread_cleanup.c                |  6 +-
 libs/libc/pthread/pthread_create.c                 |  2 +-
 libs/libc/pthread/pthread_exit.c                   |  3 +-
 sched/pthread/pthread_cancel.c                     | 18 +++---
 sched/pthread/pthread_create.c                     | 19 ++-----
 sched/signal/sig_default.c                         |  9 +--
 sched/task/task_cancelpt.c                         | 15 -----
 sched/task/task_setcancelstate.c                   |  7 ---
 sched/task/task_setcanceltype.c                    |  7 ---
 syscall/syscall.csv                                |  2 +-
 93 files changed, 127 insertions(+), 538 deletions(-)
 delete mode 100644 arch/arm/src/common/arm_pthread_exit.c
 delete mode 100644 arch/risc-v/src/common/riscv_pthread_exit.c

[incubator-nuttx] 04/05: arch/risc-v/mpfs: Remove riscv_pthread_exit.c in Make.defs

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 9d91d69ee010cbdb369ad6e6aea8a0d572d67d1e
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Thu Jan 27 14:19:02 2022 +0800

    arch/risc-v/mpfs: Remove riscv_pthread_exit.c in Make.defs
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 arch/risc-v/src/mpfs/Make.defs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/risc-v/src/mpfs/Make.defs b/arch/risc-v/src/mpfs/Make.defs
index d9e5ea3..83b0e16 100755
--- a/arch/risc-v/src/mpfs/Make.defs
+++ b/arch/risc-v/src/mpfs/Make.defs
@@ -61,7 +61,7 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS  += riscv_task_start.c
-CMN_CSRCS  += riscv_pthread_start.c riscv_pthread_exit.c
+CMN_CSRCS  += riscv_pthread_start.c
 CMN_CSRCS  += riscv_signal_dispatch.c
 
 CMN_UASRCS += riscv_signal_handler.S

[incubator-nuttx] 03/05: pthread: Call cleanup callback while asyncrhonous cancel

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 8bf7f94d39c9ca1293cf1d7d5739e7e771fe1416
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Wed Jan 26 21:01:14 2022 +0800

    pthread: Call cleanup callback while asyncrhonous cancel
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 include/nuttx/pthread.h             | 4 ++--
 libs/libc/pthread/pthread_cleanup.c | 6 ++----
 libs/libc/pthread/pthread_exit.c    | 3 ++-
 sched/pthread/pthread_cancel.c      | 9 +++++++++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h
index 3170586..a9ebf50 100644
--- a/include/nuttx/pthread.h
+++ b/include/nuttx/pthread.h
@@ -176,7 +176,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
  *   within the pthread_exit() and pthread_cancellation() logic
  *
  * Input Parameters:
- *   None
+ *   tls - The local storage info of the exiting thread
  *
  * Returned Value:
  *   None
@@ -184,7 +184,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
  ****************************************************************************/
 
 #ifdef CONFIG_PTHREAD_CLEANUP
-void pthread_cleanup_popall(void);
+void pthread_cleanup_popall(FAR struct tls_info_s *tls);
 #endif
 
 #undef EXTERN
diff --git a/libs/libc/pthread/pthread_cleanup.c b/libs/libc/pthread/pthread_cleanup.c
index 8d4ba7f..6aabcb4 100644
--- a/libs/libc/pthread/pthread_cleanup.c
+++ b/libs/libc/pthread/pthread_cleanup.c
@@ -172,17 +172,15 @@ void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
  *   within the pthread_exit() and pthread_cancellation() logic
  *
  * Input Parameters:
- *   None
+ *   tls - The local storage info of the exiting thread
  *
  * Returned Value:
  *   None
  *
  ****************************************************************************/
 
-void pthread_cleanup_popall(void)
+void pthread_cleanup_popall(FAR struct tls_info_s *tls)
 {
-  FAR struct tls_info_s *tls = up_tls_info();
-
   DEBUGASSERT(tls != NULL);
 
   sched_lock();
diff --git a/libs/libc/pthread/pthread_exit.c b/libs/libc/pthread/pthread_exit.c
index 22d684e..fce8f3e 100644
--- a/libs/libc/pthread/pthread_exit.c
+++ b/libs/libc/pthread/pthread_exit.c
@@ -28,6 +28,7 @@
 #include <debug.h>
 #include <sched.h>
 
+#include <nuttx/arch.h>
 #include <nuttx/pthread.h>
 #include <nuttx/tls.h>
 
@@ -54,7 +55,7 @@
 void pthread_exit(FAR void *exit_value)
 {
 #ifdef CONFIG_PTHREAD_CLEANUP
-  pthread_cleanup_popall();
+  pthread_cleanup_popall(up_tls_info());
 #endif
 
 #if CONFIG_TLS_NELEM > 0
diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c
index 1a4ef23..469847a 100644
--- a/sched/pthread/pthread_cancel.c
+++ b/sched/pthread/pthread_cancel.c
@@ -30,6 +30,9 @@
 #include <assert.h>
 #include <errno.h>
 
+#include <nuttx/tls.h>
+#include <nuttx/pthread.h>
+
 #include "sched/sched.h"
 #include "task/task.h"
 #include "pthread/pthread.h"
@@ -86,6 +89,12 @@ int pthread_cancel(pthread_t thread)
       pthread_exit(PTHREAD_CANCELED);
     }
 
+  /* Refer to up_tls_info() */
+
+#ifdef CONFIG_PTHREAD_CLEANUP
+  pthread_cleanup_popall(tcb->stack_alloc_ptr);
+#endif
+
   /* Complete pending join operations */
 
   pthread_completejoin((pid_t)thread, PTHREAD_CANCELED);

[incubator-nuttx] 05/05: boards: Refresh all configs

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ef3219e83df02c4182258a0de0e73fa3d1557540
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Thu Jan 27 21:11:31 2022 +0800

    boards: Refresh all configs
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 boards/arm/samv7/samv71-xult/configs/knsh/defconfig | 2 +-
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
index 09ff632..39c2076 100644
--- a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
@@ -82,4 +82,4 @@ CONFIG_SYSTEM_I2CTOOL=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_RAMTEST=y
 CONFIG_SYS_RESERVED=8
-CONFIG_UART3_SERIAL_CONSOLE=y
+CONFIG_USART1_SERIAL_CONSOLE=y
diff --git a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
index dadf67d..b2e6910 100644
--- a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
+++ b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
@@ -74,7 +74,7 @@ CONFIG_SYSTEM_CLE_CMD_HISTORY=y
 CONFIG_SYSTEM_COLOR_CLE=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_TIME64=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=20
 CONFIG_TESTING_GETPRIME=y
 CONFIG_TESTING_OSTEST=y

[incubator-nuttx] 02/05: Revert "libc: Call pthread_exit in user-space by up_pthread_exit"

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c0a0de97ce99c58a64fcfc968d816bf7eb4cd17f
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Tue Jan 25 17:22:17 2022 +0800

    Revert "libc: Call pthread_exit in user-space by up_pthread_exit"
    
    This reverts commit f4a0b7aedd01ac3f39a88d62dbafaf367ae399f2.
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 arch/arm/src/a1x/Make.defs                         |  1 -
 arch/arm/src/am335x/Make.defs                      |  1 -
 arch/arm/src/armv6-m/arm_svcall.c                  | 43 ++------------
 arch/arm/src/armv6-m/svcall.h                      |  6 +-
 arch/arm/src/armv7-a/arm_syscall.c                 | 43 +++++---------
 arch/arm/src/armv7-a/svcall.h                      | 11 +---
 arch/arm/src/armv7-m/arm_svcall.c                  | 41 ++------------
 arch/arm/src/armv7-m/svcall.h                      | 13 +----
 arch/arm/src/armv7-r/arm_syscall.c                 | 47 ++++++---------
 arch/arm/src/armv8-m/arm_svcall.c                  | 43 ++------------
 arch/arm/src/common/arm_pthread_exit.c             | 66 ----------------------
 arch/arm/src/cxd56xx/Make.defs                     |  1 -
 arch/arm/src/efm32/Make.defs                       |  1 -
 arch/arm/src/eoss3/Make.defs                       |  1 -
 arch/arm/src/imx6/Make.defs                        |  1 -
 arch/arm/src/imxrt/Make.defs                       |  1 -
 arch/arm/src/kinetis/Make.defs                     |  1 -
 arch/arm/src/kl/Make.defs                          |  1 -
 arch/arm/src/lc823450/Make.defs                    |  1 -
 arch/arm/src/lpc17xx_40xx/Make.defs                |  1 -
 arch/arm/src/lpc43xx/Make.defs                     |  1 -
 arch/arm/src/lpc54xx/Make.defs                     |  1 -
 arch/arm/src/max326xx/Make.defs                    |  1 -
 arch/arm/src/nrf52/Make.defs                       |  1 -
 arch/arm/src/nuc1xx/Make.defs                      |  1 -
 arch/arm/src/rp2040/Make.defs                      |  1 -
 arch/arm/src/s32k1xx/Make.defs                     |  1 -
 arch/arm/src/sam34/Make.defs                       |  1 -
 arch/arm/src/sama5/Make.defs                       |  1 -
 arch/arm/src/samd2l2/Make.defs                     |  1 -
 arch/arm/src/samd5e5/Make.defs                     |  1 -
 arch/arm/src/samv7/Make.defs                       |  1 -
 arch/arm/src/stm32/Make.defs                       |  2 +-
 arch/arm/src/stm32f0l0g0/Make.defs                 |  1 -
 arch/arm/src/stm32f7/Make.defs                     |  1 -
 arch/arm/src/stm32h7/Make.defs                     |  1 -
 arch/arm/src/stm32l4/Make.defs                     |  1 -
 arch/arm/src/stm32l5/Make.defs                     |  1 -
 arch/arm/src/tiva/Make.defs                        |  1 -
 arch/arm/src/tms570/Make.defs                      |  1 -
 arch/arm/src/xmc4/Make.defs                        |  1 -
 arch/or1k/src/common/up_pthread_start.c            |  2 +-
 arch/risc-v/src/c906/Make.defs                     |  1 -
 arch/risc-v/src/common/riscv_pthread_exit.c        | 64 ---------------------
 arch/risc-v/src/common/riscv_swint.c               | 45 +++------------
 arch/risc-v/src/common/svcall.h                    | 15 ++---
 arch/risc-v/src/k210/Make.defs                     |  3 +-
 .../arm/imxrt/imxrt1050-evk/configs/knsh/defconfig |  2 +-
 .../arm/imxrt/imxrt1060-evk/configs/knsh/defconfig |  2 +-
 .../arm/imxrt/imxrt1064-evk/configs/knsh/defconfig |  2 +-
 .../lc823450/lc823450-xgevk/configs/knsh/defconfig |  2 +-
 .../lc823450-xgevk/configs/kostest/defconfig       |  2 +-
 .../lc823450-xgevk/configs/krndis/defconfig        |  2 +-
 .../lpc4088-devkit/configs/knsh/defconfig          |  2 +-
 .../lpc4088-quickstart/configs/knsh/defconfig      |  2 +-
 .../lpc17xx_40xx/open1788/configs/knsh/defconfig   |  2 +-
 .../open1788/configs/knxterm/defconfig             |  2 +-
 .../lpc17xx_40xx/pnev5180b/configs/knsh/defconfig  |  2 +-
 .../lpc43xx/bambino-200e/configs/knsh/defconfig    |  2 +-
 boards/arm/sam34/sam3u-ek/configs/knsh/defconfig   |  2 +-
 boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig |  2 +-
 .../arm/samv7/samv71-xult/configs/knsh/defconfig   |  4 +-
 .../stm32/clicker2-stm32/configs/knsh/defconfig    |  2 +-
 .../stm32/mikroe-stm32f4/configs/kostest/defconfig |  2 +-
 .../stm32/olimex-stm32-p407/configs/kelf/defconfig |  2 +-
 .../olimex-stm32-p407/configs/kmodule/defconfig    |  2 +-
 .../stm32/olimex-stm32-p407/configs/knsh/defconfig |  2 +-
 .../stm32/stm3240g-eval/configs/knxwm/defconfig    |  2 +-
 .../stm32f4discovery/configs/kostest/defconfig     |  2 +-
 .../stm32l476vg-disco/configs/knsh/defconfig       |  2 +-
 .../stm32l4r9ai-disco/configs/knsh/defconfig       |  2 +-
 .../lm3s6965-ek/configs/qemu-protected/defconfig   |  2 +-
 .../risc-v/c906/smartl-c906/configs/knsh/defconfig |  2 +-
 boards/risc-v/k210/maix-bit/configs/knsh/defconfig |  2 +-
 .../k210/maix-bit/configs/knsh_smp/defconfig       |  2 +-
 .../risc-v/k210/maix-bit/configs/kostest/defconfig |  2 +-
 include/nuttx/arch.h                               | 23 +-------
 include/nuttx/pthread.h                            |  4 +-
 include/nuttx/sched.h                              |  4 +-
 include/pthread.h                                  |  2 -
 include/sys/syscall_lookup.h                       |  2 +-
 libs/libc/pthread/pthread_create.c                 |  2 +-
 sched/pthread/pthread_cancel.c                     | 10 ----
 sched/pthread/pthread_create.c                     | 19 ++-----
 sched/signal/sig_default.c                         | 10 +---
 sched/task/task_cancelpt.c                         | 17 ------
 sched/task/task_setcancelstate.c                   |  8 ---
 sched/task/task_setcanceltype.c                    | 10 +---
 syscall/syscall.csv                                |  2 +-
 89 files changed, 112 insertions(+), 537 deletions(-)

diff --git a/arch/arm/src/a1x/Make.defs b/arch/arm/src/a1x/Make.defs
index 924c970..ab1b1b5 100644
--- a/arch/arm/src/a1x/Make.defs
+++ b/arch/arm/src/a1x/Make.defs
@@ -78,7 +78,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_KERNEL),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c
-CMN_CSRCS += arm_pthread_exit.c
 endif
 
 ifeq ($(CONFIG_ARCH_ADDRENV),y)
diff --git a/arch/arm/src/am335x/Make.defs b/arch/arm/src/am335x/Make.defs
index 3d76623..e1f4619 100644
--- a/arch/arm/src/am335x/Make.defs
+++ b/arch/arm/src/am335x/Make.defs
@@ -74,7 +74,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_KERNEL),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c
-CMN_CSRCS += arm_pthread_exit.c
 endif
 
 ifeq ($(CONFIG_ARCH_ADDRENV),y)
diff --git a/arch/arm/src/armv6-m/arm_svcall.c b/arch/arm/src/armv6-m/arm_svcall.c
index 6517b4c..0339ccc 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -298,28 +298,26 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
       /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
        *   R0 = SYS_pthread_start
-       *   R1 = startup
-       *   R2 = entrypt
-       *   R3 = arg
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
           /* Set up to return to the user-space pthread start-up function in
            * unprivileged mode.
            */
 
-          regs[REG_PC]         = (uint32_t)regs[REG_R1] & ~1;  /* startup */
+          regs[REG_PC]         = (uint32_t)regs[REG_R1]; /* startup */
           regs[REG_EXC_RETURN] = EXC_RETURN_UNPRIVTHR;
 
           /* Change the parameter ordering to match the expectation of the
@@ -330,35 +328,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
           regs[REG_R1]         = regs[REG_R3]; /* arg */
         }
         break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        FAR void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
-
-      case SYS_pthread_exit:
-        {
-          /* Set up to return to the user-space pthread start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)regs[REG_R1] & ~1;  /* startup */
-          regs[REG_EXC_RETURN] = EXC_RETURN_UNPRIVTHR;
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R2]; /* exit_value */
-        }
-        break;
 #endif
 
       /* R0=SYS_signal_handler:  This a user signal handler callback
diff --git a/arch/arm/src/armv6-m/svcall.h b/arch/arm/src/armv6-m/svcall.h
index 0b0f8d7..a790f58 100644
--- a/arch/arm/src/armv6-m/svcall.h
+++ b/arch/arm/src/armv6-m/svcall.h
@@ -45,9 +45,9 @@
 #ifdef CONFIG_LIB_SYSCALL
 #  ifdef CONFIG_BUILD_PROTECTED
 #    ifndef CONFIG_SYS_RESERVED
-#      error "CONFIG_SYS_RESERVED must be defined to have the value 9"
-#    elif CONFIG_SYS_RESERVED != 9
-#      error "CONFIG_SYS_RESERVED must have the value 9"
+#      error "CONFIG_SYS_RESERVED must be defined to have the value 8"
+#    elif CONFIG_SYS_RESERVED != 8
+#      error "CONFIG_SYS_RESERVED must have the value 8"
 #    endif
 #  else
 #    ifndef CONFIG_SYS_RESERVED
diff --git a/arch/arm/src/armv7-a/arm_syscall.c b/arch/arm/src/armv7-a/arm_syscall.c
index d38a8e7..5e61aa4 100644
--- a/arch/arm/src/armv7-a/arm_syscall.c
+++ b/arch/arm/src/armv7-a/arm_syscall.c
@@ -278,48 +278,33 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
       /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
        *   R0 = SYS_pthread_start
-       *   R1 = startup
-       *   R2 = entrypt
-       *   R3 = arg
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
-          regs[REG_PC]   = regs[REG_R0];
-          regs[REG_R0]   = regs[REG_R1];
-          regs[REG_R1]   = regs[REG_R2];
-
-          cpsr           = regs[REG_CPSR] & ~PSR_MODE_MASK;
-          regs[REG_CPSR] = cpsr | PSR_MODE_USR;
-        }
-        break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        FAR void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
+          /* Set up to enter the user-space pthread start-up function in
+           * unprivileged mode. We need:
+           *
+           *   R0   = entrypt
+           *   R1   = arg
+           *   PC   = startup
+           *   CSPR = user mode
+           */
 
-      case SYS_pthread_exit:
-        {
           regs[REG_PC]   = regs[REG_R0];
           regs[REG_R0]   = regs[REG_R1];
+          regs[REG_R1]   = regs[REG_R2];
 
           cpsr           = regs[REG_CPSR] & ~PSR_MODE_MASK;
           regs[REG_CPSR] = cpsr | PSR_MODE_USR;
diff --git a/arch/arm/src/armv7-a/svcall.h b/arch/arm/src/armv7-a/svcall.h
index d22fde1..27dc875 100644
--- a/arch/arm/src/armv7-a/svcall.h
+++ b/arch/arm/src/armv7-a/svcall.h
@@ -44,8 +44,8 @@
 
 #ifdef CONFIG_BUILD_KERNEL
 #  ifndef CONFIG_SYS_RESERVED
-#    error "CONFIG_SYS_RESERVED must be defined to have the value 7"
-#  elif CONFIG_SYS_RESERVED != 7
+#    error "CONFIG_SYS_RESERVED must be defined to have the value 6"
+#  elif CONFIG_SYS_RESERVED != 6
 #    error "CONFIG_SYS_RESERVED must have the value 6"
 #  endif
 #else
@@ -109,13 +109,6 @@
 
 #define SYS_pthread_start         (3)
 
-/* SYS call 8:
- *
- * void up_pthread_exit(pthread_exitroutine_t exit, FAR void *exit_value)
- */
-
-#define SYS_pthread_exit         (6)
-
 #endif /* CONFIG_BUILD_KERNEL */
 
 /****************************************************************************
diff --git a/arch/arm/src/armv7-m/arm_svcall.c b/arch/arm/src/armv7-m/arm_svcall.c
index ca38d1b..6119ee6 100644
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ b/arch/arm/src/armv7-m/arm_svcall.c
@@ -312,21 +312,19 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
       /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
        *   R0 = SYS_pthread_start
-       *   R1 = startup
-       *   R2 = entrypt
-       *   R3 = arg
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
           /* Set up to return to the user-space pthread start-up function in
@@ -344,35 +342,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
           regs[REG_R1]         = regs[REG_R3]; /* arg */
         }
         break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        FAR void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
-
-      case SYS_pthread_exit:
-        {
-          /* Set up to return to the user-space pthread start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)regs[REG_R1] & ~1;  /* startup */
-          regs[REG_EXC_RETURN] = EXC_RETURN_UNPRIVTHR;
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R2]; /* exit_value */
-        }
-        break;
 #endif
 
       /* R0=SYS_signal_handler:  This a user signal handler callback
diff --git a/arch/arm/src/armv7-m/svcall.h b/arch/arm/src/armv7-m/svcall.h
index 1fd56ea..98a574e 100644
--- a/arch/arm/src/armv7-m/svcall.h
+++ b/arch/arm/src/armv7-m/svcall.h
@@ -45,9 +45,9 @@
 #ifdef CONFIG_LIB_SYSCALL
 #  ifdef CONFIG_BUILD_PROTECTED
 #    ifndef CONFIG_SYS_RESERVED
-#      error "CONFIG_SYS_RESERVED must be defined to have the value 9"
-#    elif CONFIG_SYS_RESERVED != 9
-#      error "CONFIG_SYS_RESERVED must have the value 9"
+#      error "CONFIG_SYS_RESERVED must be defined to have the value 8"
+#    elif CONFIG_SYS_RESERVED != 8
+#      error "CONFIG_SYS_RESERVED must have the value 8"
 #    endif
 #  else
 #    ifndef CONFIG_SYS_RESERVED
@@ -126,13 +126,6 @@
 
 #define SYS_pthread_start         (5)
 
-/* SYS call 8:
- *
- * void up_pthread_exit(pthread_exitroutine_t exit, FAR void *exit_value)
- */
-
-#define SYS_pthread_exit         (8)
-
 #endif /* !CONFIG_BUILD_FLAT */
 #endif /* CONFIG_LIB_SYSCALL */
 
diff --git a/arch/arm/src/armv7-r/arm_syscall.c b/arch/arm/src/armv7-r/arm_syscall.c
index dde0ac4..32b48b2 100644
--- a/arch/arm/src/armv7-r/arm_syscall.c
+++ b/arch/arm/src/armv7-r/arm_syscall.c
@@ -273,48 +273,33 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
       /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
        *   R0 = SYS_pthread_start
-       *   R1 = startup
-       *   R2 = entrypt
-       *   R3 = arg
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
-          regs[REG_PC]   = regs[REG_R0];
-          regs[REG_R0]   = regs[REG_R1];
-          regs[REG_R1]   = regs[REG_R2];
-
-          cpsr           = regs[REG_CPSR] & ~PSR_MODE_MASK;
-          regs[REG_CPSR] = cpsr | PSR_MODE_USR;
-        }
-        break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        FAR void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
+          /* Set up to enter the user-space pthread start-up function in
+           * unprivileged mode. We need:
+           *
+           *   R0   = startup
+           *   R1   = arg
+           *   PC   = entrypt
+           *   CSPR = user mode
+           */
 
-      case SYS_pthread_exit:
-        {
-          regs[REG_PC]   = regs[REG_R0];
-          regs[REG_R0]   = regs[REG_R1];
+          regs[REG_PC]   = regs[REG_R1];
+          regs[REG_R0]   = regs[REG_R2];
+          regs[REG_R1]   = regs[REG_R3];
 
           cpsr           = regs[REG_CPSR] & ~PSR_MODE_MASK;
           regs[REG_CPSR] = cpsr | PSR_MODE_USR;
diff --git a/arch/arm/src/armv8-m/arm_svcall.c b/arch/arm/src/armv8-m/arm_svcall.c
index 4f57fb3..f0757c7 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/armv8-m/arm_svcall.c
@@ -311,21 +311,19 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
       /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
        *   R0 = SYS_pthread_start
-       *   R1 = startup
-       *   R2 = entrypt
-       *   R3 = arg
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
           /* Set up to return to the user-space pthread start-up function in
@@ -340,36 +338,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg)
            */
 
           regs[REG_R0]         = regs[REG_R2]; /* pthread entry */
-          regs[REG_R1]         = regs[REG_R3]; /* arg */
-        }
-        break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        FAR void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
-
-      case SYS_pthread_exit:
-        {
-          /* Set up to return to the user-space pthread start-up function in
-           * unprivileged mode.
-           */
-
-          regs[REG_PC]         = (uint32_t)regs[REG_R1] & ~1;  /* startup */
-          regs[REG_EXC_RETURN] = EXC_RETURN_UNPRIVTHR;
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_startup:
-           */
-
-          regs[REG_R0]         = regs[REG_R2]; /* exit_value */
+          regs[REG_R1]         = regs[REG_R2]; /* arg */
         }
         break;
 #endif
diff --git a/arch/arm/src/common/arm_pthread_exit.c b/arch/arm/src/common/arm_pthread_exit.c
deleted file mode 100644
index 22e2fbd..0000000
--- a/arch/arm/src/common/arm_pthread_exit.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/arm_pthread_exit.c
- *
- * 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 <nuttx/config.h>
-#include <pthread.h>
-#include <nuttx/arch.h>
-
-#include "svcall.h"
-#include "arm_internal.h"
-
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \
-    !defined(CONFIG_DISABLE_PTHREAD)
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_pthread_exit
- *
- * Description:
- *   In this kernel mode build, this function will be called to execute a
- *   pthread in user-space. This kernel-mode stub will then be called
- *   transfer control to the user-mode pthread_exit.
- *
- * Input Parameters:
- *   exit       - The user-space pthread_exit function
- *   exit_value - The pointer of the pthread exit parameter
- *
- * Returned Value:
- *   None
- ****************************************************************************/
-
-void up_pthread_exit(pthread_exitroutine_t exit, FAR void *exit_value)
-{
-  /* Let sys_call2() do all of the work */
-
-  sys_call2(SYS_pthread_exit, (uintptr_t)exit, (uintptr_t)exit_value);
-
-  /* Suppress "'noreturn' function does return" warning */
-
-  while (1);
-}
-
-#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ && !CONFIG_DISABLE_PTHREAD */
diff --git a/arch/arm/src/cxd56xx/Make.defs b/arch/arm/src/cxd56xx/Make.defs
index 351477c..097f189 100644
--- a/arch/arm/src/cxd56xx/Make.defs
+++ b/arch/arm/src/cxd56xx/Make.defs
@@ -51,7 +51,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/efm32/Make.defs b/arch/arm/src/efm32/Make.defs
index 55e6d6e..987e2a4 100644
--- a/arch/arm/src/efm32/Make.defs
+++ b/arch/arm/src/efm32/Make.defs
@@ -44,7 +44,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/eoss3/Make.defs b/arch/arm/src/eoss3/Make.defs
index d17309d..b183722 100644
--- a/arch/arm/src/eoss3/Make.defs
+++ b/arch/arm/src/eoss3/Make.defs
@@ -44,7 +44,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/imx6/Make.defs b/arch/arm/src/imx6/Make.defs
index 207fcb9..e0062a2 100644
--- a/arch/arm/src/imx6/Make.defs
+++ b/arch/arm/src/imx6/Make.defs
@@ -94,7 +94,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_KERNEL),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c
-CMN_CSRCS += arm_pthread_exit.c
 endif
 
 ifeq ($(CONFIG_ARCH_ADDRENV),y)
diff --git a/arch/arm/src/imxrt/Make.defs b/arch/arm/src/imxrt/Make.defs
index 70c1bc2..398ba1a 100644
--- a/arch/arm/src/imxrt/Make.defs
+++ b/arch/arm/src/imxrt/Make.defs
@@ -56,7 +56,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs
index e799856..5336b84 100644
--- a/arch/arm/src/kinetis/Make.defs
+++ b/arch/arm/src/kinetis/Make.defs
@@ -51,7 +51,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/kl/Make.defs b/arch/arm/src/kl/Make.defs
index 9a88724..c99f902 100644
--- a/arch/arm/src/kl/Make.defs
+++ b/arch/arm/src/kl/Make.defs
@@ -33,7 +33,6 @@ CMN_CSRCS += arm_switchcontext.c
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/lc823450/Make.defs b/arch/arm/src/lc823450/Make.defs
index f0ba8bd..962d711 100644
--- a/arch/arm/src/lc823450/Make.defs
+++ b/arch/arm/src/lc823450/Make.defs
@@ -43,7 +43,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/lpc17xx_40xx/Make.defs b/arch/arm/src/lpc17xx_40xx/Make.defs
index 41236ba..deabc2f 100644
--- a/arch/arm/src/lpc17xx_40xx/Make.defs
+++ b/arch/arm/src/lpc17xx_40xx/Make.defs
@@ -54,7 +54,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/lpc43xx/Make.defs b/arch/arm/src/lpc43xx/Make.defs
index 8db0e72..73d0c74 100644
--- a/arch/arm/src/lpc43xx/Make.defs
+++ b/arch/arm/src/lpc43xx/Make.defs
@@ -47,7 +47,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/lpc54xx/Make.defs b/arch/arm/src/lpc54xx/Make.defs
index 154243f..e901d21 100644
--- a/arch/arm/src/lpc54xx/Make.defs
+++ b/arch/arm/src/lpc54xx/Make.defs
@@ -47,7 +47,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/max326xx/Make.defs b/arch/arm/src/max326xx/Make.defs
index 1b3545a..dc0e238 100644
--- a/arch/arm/src/max326xx/Make.defs
+++ b/arch/arm/src/max326xx/Make.defs
@@ -46,7 +46,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/nrf52/Make.defs b/arch/arm/src/nrf52/Make.defs
index 603819d..de4bdbc 100644
--- a/arch/arm/src/nrf52/Make.defs
+++ b/arch/arm/src/nrf52/Make.defs
@@ -52,7 +52,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/nuc1xx/Make.defs b/arch/arm/src/nuc1xx/Make.defs
index ab53a2e..f8492ac 100644
--- a/arch/arm/src/nuc1xx/Make.defs
+++ b/arch/arm/src/nuc1xx/Make.defs
@@ -33,7 +33,6 @@ CMN_CSRCS += arm_switchcontext.c arm_puts.c
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/rp2040/Make.defs b/arch/arm/src/rp2040/Make.defs
index 9ad3929..9fe6bf3 100644
--- a/arch/arm/src/rp2040/Make.defs
+++ b/arch/arm/src/rp2040/Make.defs
@@ -37,7 +37,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/s32k1xx/Make.defs b/arch/arm/src/s32k1xx/Make.defs
index 06e3fa1..47ab398 100644
--- a/arch/arm/src/s32k1xx/Make.defs
+++ b/arch/arm/src/s32k1xx/Make.defs
@@ -31,7 +31,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 endif
 
 # Source files common to all S32K1xx chip families.
diff --git a/arch/arm/src/sam34/Make.defs b/arch/arm/src/sam34/Make.defs
index 55c8012..2628a45 100644
--- a/arch/arm/src/sam34/Make.defs
+++ b/arch/arm/src/sam34/Make.defs
@@ -59,7 +59,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/sama5/Make.defs b/arch/arm/src/sama5/Make.defs
index 74c5704..2bbc835 100644
--- a/arch/arm/src/sama5/Make.defs
+++ b/arch/arm/src/sama5/Make.defs
@@ -80,7 +80,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_KERNEL),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c
-CMN_CSRCS += arm_pthread_exit.c
 endif
 
 ifeq ($(CONFIG_ARCH_ADDRENV),y)
diff --git a/arch/arm/src/samd2l2/Make.defs b/arch/arm/src/samd2l2/Make.defs
index 0d5558f..8695218 100644
--- a/arch/arm/src/samd2l2/Make.defs
+++ b/arch/arm/src/samd2l2/Make.defs
@@ -33,7 +33,6 @@ CMN_CSRCS += arm_switchcontext.c arm_puts.c
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/samd5e5/Make.defs b/arch/arm/src/samd5e5/Make.defs
index f55e157..27f7ae8 100644
--- a/arch/arm/src/samd5e5/Make.defs
+++ b/arch/arm/src/samd5e5/Make.defs
@@ -49,7 +49,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/samv7/Make.defs b/arch/arm/src/samv7/Make.defs
index eb0831b..f549a48 100644
--- a/arch/arm/src/samv7/Make.defs
+++ b/arch/arm/src/samv7/Make.defs
@@ -67,7 +67,6 @@ ifeq ($(CONFIG_ARM_MPU),y)
 CMN_CSRCS += arm_mpu.c
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs
index e484536..468b2bf 100644
--- a/arch/arm/src/stm32/Make.defs
+++ b/arch/arm/src/stm32/Make.defs
@@ -54,7 +54,7 @@ CMN_CSRCS += arm_mpu.c
 endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
-CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_pthread_exit.c
+CMN_CSRCS += arm_task_start.c arm_pthread_start.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32f0l0g0/Make.defs b/arch/arm/src/stm32f0l0g0/Make.defs
index 04da3dc..07efcf6 100644
--- a/arch/arm/src/stm32f0l0g0/Make.defs
+++ b/arch/arm/src/stm32f0l0g0/Make.defs
@@ -33,7 +33,6 @@ CMN_CSRCS += arm_switchcontext.c
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32f7/Make.defs b/arch/arm/src/stm32f7/Make.defs
index 5ed5c2f..72122f1 100644
--- a/arch/arm/src/stm32f7/Make.defs
+++ b/arch/arm/src/stm32f7/Make.defs
@@ -73,7 +73,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs
index b10ff69..4c12448 100644
--- a/arch/arm/src/stm32h7/Make.defs
+++ b/arch/arm/src/stm32h7/Make.defs
@@ -72,7 +72,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32l4/Make.defs b/arch/arm/src/stm32l4/Make.defs
index 42c3a74..88c50ca 100644
--- a/arch/arm/src/stm32l4/Make.defs
+++ b/arch/arm/src/stm32l4/Make.defs
@@ -64,7 +64,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/stm32l5/Make.defs b/arch/arm/src/stm32l5/Make.defs
index a87fd6d..452f643 100644
--- a/arch/arm/src/stm32l5/Make.defs
+++ b/arch/arm/src/stm32l5/Make.defs
@@ -65,7 +65,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/tiva/Make.defs b/arch/arm/src/tiva/Make.defs
index 3ae3f77..cc1d931 100644
--- a/arch/arm/src/tiva/Make.defs
+++ b/arch/arm/src/tiva/Make.defs
@@ -65,7 +65,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
   CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-  CMN_CSRCS += arm_pthread_exit.c
   CMN_CSRCS += arm_signal_dispatch.c
   CMN_UASRCS += arm_signal_handler.S
 else
diff --git a/arch/arm/src/tms570/Make.defs b/arch/arm/src/tms570/Make.defs
index b587b7c..b289b86 100644
--- a/arch/arm/src/tms570/Make.defs
+++ b/arch/arm/src/tms570/Make.defs
@@ -60,7 +60,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/arm/src/xmc4/Make.defs b/arch/arm/src/xmc4/Make.defs
index bf02e9e..ca64e24 100644
--- a/arch/arm/src/xmc4/Make.defs
+++ b/arch/arm/src/xmc4/Make.defs
@@ -51,7 +51,6 @@ endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS += arm_task_start.c arm_pthread_start.c
-CMN_CSRCS += arm_pthread_exit.c
 CMN_CSRCS += arm_signal_dispatch.c
 CMN_UASRCS += arm_signal_handler.S
 endif
diff --git a/arch/or1k/src/common/up_pthread_start.c b/arch/or1k/src/common/up_pthread_start.c
index 31a8541..77481ec 100644
--- a/arch/or1k/src/common/up_pthread_start.c
+++ b/arch/or1k/src/common/up_pthread_start.c
@@ -64,7 +64,7 @@
 
 void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg)
 {
-  /* Let sys_call3() do all of the work */
+  /* Let sys_call2() do all of the work */
 
   sinfo("entry %p arg %p\n", entrypt, arg);
 
diff --git a/arch/risc-v/src/c906/Make.defs b/arch/risc-v/src/c906/Make.defs
index 3b47ac3..f2a982e 100644
--- a/arch/risc-v/src/c906/Make.defs
+++ b/arch/risc-v/src/c906/Make.defs
@@ -59,7 +59,6 @@ CHIP_CSRCS += c906_start.c c906_timerisr.c
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CMN_CSRCS  += riscv_task_start.c riscv_pthread_start.c
-CMN_CSRCS  += riscv_pthread_exit.c
 CMN_CSRCS  += riscv_signal_dispatch.c riscv_pmp.c
 CMN_UASRCS += riscv_signal_handler.S
 
diff --git a/arch/risc-v/src/common/riscv_pthread_exit.c b/arch/risc-v/src/common/riscv_pthread_exit.c
deleted file mode 100644
index 11348d9..0000000
--- a/arch/risc-v/src/common/riscv_pthread_exit.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
- * arch/risc-v/src/common/riscv_pthread_exit.c
- *
- * 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 <nuttx/config.h>
-#include <pthread.h>
-#include <nuttx/arch.h>
-
-#include "svcall.h"
-#include "riscv_internal.h"
-
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \
-    !defined(CONFIG_DISABLE_PTHREAD)
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_pthread_exit
- *
- * Description:
- *   In this kernel mode build, this function will be called to execute a
- *   pthread in user-space. This kernel-mode stub will then be called
- *   transfer control to the user-mode pthread_exit.
- *
- * Input Parameters:
- *   exit       - The user-space pthread_exit function
- *   exit_value - The pointer of the pthread exit parameter
- *
- * Returned Value:
- *   None
- ****************************************************************************/
-
-void up_pthread_exit(pthread_exitroutine_t exit, void *exit_value)
-{
-  sys_call2(SYS_pthread_exit, (uintptr_t)exit, (uintptr_t)exit_value);
-
-  /* Suppress "'noreturn' function does return" warning */
-
-  while (1);
-}
-
-#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ && !CONFIG_DISABLE_PTHREAD */
diff --git a/arch/risc-v/src/common/riscv_swint.c b/arch/risc-v/src/common/riscv_swint.c
index 7d507e1..de174f6 100644
--- a/arch/risc-v/src/common/riscv_swint.c
+++ b/arch/risc-v/src/common/riscv_swint.c
@@ -311,21 +311,19 @@ int riscv_swint(int irq, void *context, void *arg)
         break;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
-
-      /* A0=SYS_pthread_start:  This a user pthread start
+      /* R0=SYS_pthread_start:  This a user pthread start
        *
-       *   void up_pthread_start(pthread_trampoline_t startup,
-       *          pthread_startroutine_t entrypt, pthread_addr_t arg)
+       *   void up_pthread_start(pthread_startroutine_t entrypt,
+       *                         pthread_addr_t arg) noreturn_function;
        *
        * At this point, the following values are saved in context:
        *
-       *   A0 = SYS_pthread_start
-       *   A1 = startup
-       *   A2 = entrypt
-       *   A3 = arg
+       *   R0 = SYS_pthread_start
+       *   R1 = entrypt
+       *   R2 = arg
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
           /* Set up to return to the user-space pthread start-up function in
@@ -343,35 +341,6 @@ int riscv_swint(int irq, void *context, void *arg)
           regs[REG_INT_CTX] &= ~MSTATUS_MPPM; /* User mode */
         }
         break;
-
-      /* R0=SYS_pthread_exit:  This pthread_exit call in user-space
-       *
-       *   void up_pthread_exit(pthread_exitroutine_t exit,
-       *                        void *exit_value)
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_pthread_exit
-       *   R1 = pthread_exit trampoline routine
-       *   R2 = exit_value
-       */
-
-      case SYS_pthread_exit:
-        {
-          /* Set up to enter the user-space pthread exit function in
-           * unprivileged mode.
-           */
-
-          regs[REG_EPC]      = (uintptr_t)regs[REG_A1] & ~1;  /* exit */
-
-          /* Change the parameter ordering to match the expectation of the
-           * user space pthread_exit:
-           */
-
-          regs[REG_A0]       = regs[REG_A2];  /* exit_value */
-          regs[REG_INT_CTX] &= ~MSTATUS_MPPM; /* User mode */
-        }
-        break;
 #endif
 
       /* R0=SYS_signal_handler:  This a user signal handler callback
diff --git a/arch/risc-v/src/common/svcall.h b/arch/risc-v/src/common/svcall.h
index 9562999..06d4ab9 100644
--- a/arch/risc-v/src/common/svcall.h
+++ b/arch/risc-v/src/common/svcall.h
@@ -46,9 +46,9 @@
 #ifdef CONFIG_LIB_SYSCALL
 #  ifdef CONFIG_BUILD_PROTECTED
 #    ifndef CONFIG_SYS_RESERVED
-#      error "CONFIG_SYS_RESERVED must be defined to have the value 9"
-#    elif CONFIG_SYS_RESERVED != 9
-#      error "CONFIG_SYS_RESERVED must have the value 9"
+#      error "CONFIG_SYS_RESERVED must be defined to have the value 8"
+#    elif CONFIG_SYS_RESERVED != 8
+#      error "CONFIG_SYS_RESERVED must have the value 8"
 #    endif
 #  else
 #    ifndef CONFIG_SYS_RESERVED
@@ -118,20 +118,13 @@
 
 /* SYS call 5:
  *
- * void up_pthread_start(pthread_trampoline_t startup,
+ * void up_pthread_start(pthread_startroutine_t startup,
  *                       pthread_startroutine_t entrypt, pthread_addr_t arg)
  *        noreturn_function
  */
 
 #define SYS_pthread_start         (5)
 
-/* SYS call 8:
- *
- * void up_pthread_exit(pthread_exitroutine_t exit, void *exit_value)
- */
-
-#define SYS_pthread_exit          (8)
-
 #endif /* !CONFIG_BUILD_FLAT */
 #endif /* CONFIG_LIB_SYSCALL */
 
diff --git a/arch/risc-v/src/k210/Make.defs b/arch/risc-v/src/k210/Make.defs
index 2ac5eff..05ff580 100644
--- a/arch/risc-v/src/k210/Make.defs
+++ b/arch/risc-v/src/k210/Make.defs
@@ -62,8 +62,7 @@ CHIP_CSRCS += k210_cpuidlestack.c
 endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
-CMN_CSRCS  += riscv_task_start.c
-CMN_CSRCS  += riscv_pthread_start.c riscv_pthread_exit.c
+CMN_CSRCS  += riscv_task_start.c riscv_pthread_start.c
 CMN_CSRCS  += riscv_signal_dispatch.c
 CMN_UASRCS += riscv_signal_handler.S
 
diff --git a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig
index 67f4565..4582402 100644
--- a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig
+++ b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig
@@ -40,4 +40,4 @@ CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=8
 CONFIG_START_MONTH=6
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
diff --git a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig
index 3b8a7ea..fde23c3 100644
--- a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig
+++ b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig
@@ -40,4 +40,4 @@ CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=8
 CONFIG_START_MONTH=6
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
diff --git a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig
index 48269bf..d9568cb 100644
--- a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig
+++ b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig
@@ -40,4 +40,4 @@ CONFIG_SCHED_WAITPID=y
 CONFIG_START_DAY=8
 CONFIG_START_MONTH=6
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
index 5b0ae71..edcde6d 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig
@@ -110,7 +110,7 @@ CONFIG_START_YEAR=2013
 CONFIG_SYSTEM_I2CTOOL=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_TIME64=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=24
 CONFIG_UART0_RXBUFSIZE=512
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/kostest/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/kostest/defconfig
index 1eac99b..6175b52 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/kostest/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/kostest/defconfig
@@ -40,7 +40,7 @@ CONFIG_START_MONTH=10
 CONFIG_START_YEAR=2013
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_TIME64=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TESTING_OSTEST=y
 CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3
 CONFIG_TESTING_OSTEST_STACKSIZE=2048
diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
index d402856..7e6c85e 100644
--- a/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
+++ b/boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig
@@ -174,7 +174,7 @@ CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME="g_nsymbols"
 CONFIG_SYSTEM_NXPLAYER=y
 CONFIG_SYSTEM_PING=y
 CONFIG_SYSTEM_TIME64=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=24
 CONFIG_TELNET_CHARACTER_MODE=y
 CONFIG_TESTING_OSTEST=y
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/defconfig b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/defconfig
index 95b2555..d45340e 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/defconfig
+++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/defconfig
@@ -56,6 +56,6 @@ CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2013
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/defconfig b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/defconfig
index ac0eef8..e068060 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/defconfig
+++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/defconfig
@@ -52,6 +52,6 @@ CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2013
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/defconfig b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/defconfig
index 325fc37..4f47d2e 100644
--- a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/defconfig
+++ b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/defconfig
@@ -56,6 +56,6 @@ CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2013
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/defconfig b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/defconfig
index d7eb83c..b8719cc 100644
--- a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/defconfig
+++ b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/defconfig
@@ -67,6 +67,6 @@ CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2019
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_CLE=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/defconfig b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/defconfig
index a16f6f7..e9229c5 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/defconfig
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/defconfig
@@ -22,5 +22,5 @@ CONFIG_PASS1_BUILDIR="boards/arm/lpc17xx_40xx/pnev5180b/kernel"
 CONFIG_RAM_SIZE=32768
 CONFIG_RAM_START=0x10000000
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/lpc43xx/bambino-200e/configs/knsh/defconfig b/boards/arm/lpc43xx/bambino-200e/configs/knsh/defconfig
index 65bf1d2..0204a73 100644
--- a/boards/arm/lpc43xx/bambino-200e/configs/knsh/defconfig
+++ b/boards/arm/lpc43xx/bambino-200e/configs/knsh/defconfig
@@ -48,7 +48,7 @@ CONFIG_START_MONTH=7
 CONFIG_START_YEAR=2012
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_TIMER=y
 CONFIG_UART1_SERIAL_CONSOLE=y
diff --git a/boards/arm/sam34/sam3u-ek/configs/knsh/defconfig b/boards/arm/sam34/sam3u-ek/configs/knsh/defconfig
index 4efbe41..fdf13ff 100644
--- a/boards/arm/sam34/sam3u-ek/configs/knsh/defconfig
+++ b/boards/arm/sam34/sam3u-ek/configs/knsh/defconfig
@@ -47,6 +47,6 @@ CONFIG_START_DAY=10
 CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2013
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig b/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
index 0efc437..2685ee3 100644
--- a/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
+++ b/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
@@ -84,5 +84,5 @@ CONFIG_SCHED_WAITPID=y
 CONFIG_SDIO_BLOCKSETUP=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_NSH_PROGNAME="init"
-CONFIG_SYS_RESERVED=7
+CONFIG_SYS_RESERVED=6
 CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
index b15bf04..09ff632 100644
--- a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
@@ -81,5 +81,5 @@ CONFIG_START_YEAR=2015
 CONFIG_SYSTEM_I2CTOOL=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_RAMTEST=y
-CONFIG_SYS_RESERVED=9
-CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_SYS_RESERVED=8
+CONFIG_UART3_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32/clicker2-stm32/configs/knsh/defconfig b/boards/arm/stm32/clicker2-stm32/configs/knsh/defconfig
index a04402e..fc3af2e 100644
--- a/boards/arm/stm32/clicker2-stm32/configs/knsh/defconfig
+++ b/boards/arm/stm32/clicker2-stm32/configs/knsh/defconfig
@@ -51,6 +51,6 @@ CONFIG_STM32_JTAG_SW_ENABLE=y
 CONFIG_STM32_PWR=y
 CONFIG_STM32_USART3=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=32
 CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig b/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
index 0155249..2b1f349 100644
--- a/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
+++ b/boards/arm/stm32/mikroe-stm32f4/configs/kostest/defconfig
@@ -81,7 +81,7 @@ CONFIG_STM32_USART2=y
 CONFIG_SYSLOG_CHAR=y
 CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=11
 CONFIG_TESTING_OSTEST=y
 CONFIG_USBDEV=y
diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/kelf/defconfig b/boards/arm/stm32/olimex-stm32-p407/configs/kelf/defconfig
index 68bb28b..e09191c 100644
--- a/boards/arm/stm32/olimex-stm32-p407/configs/kelf/defconfig
+++ b/boards/arm/stm32/olimex-stm32-p407/configs/kelf/defconfig
@@ -56,7 +56,7 @@ CONFIG_STM32_SDIO=y
 CONFIG_STM32_USART3=y
 CONFIG_STM32_USBHOST=y
 CONFIG_SYMTAB_ORDEREDBYNAME=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_USART3_SERIAL_CONSOLE=y
 CONFIG_USBHOST_ISOC_DISABLE=y
 CONFIG_USBHOST_MSC=y
diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig
index d362c68..df9462b 100644
--- a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig
+++ b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig
@@ -51,7 +51,7 @@ CONFIG_STM32_PWR=y
 CONFIG_STM32_USART3=y
 CONFIG_STM32_USBHOST=y
 CONFIG_SYMTAB_ORDEREDBYNAME=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_USART3_SERIAL_CONSOLE=y
 CONFIG_USBHOST_ISOC_DISABLE=y
 CONFIG_USBHOST_MSC=y
diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/knsh/defconfig b/boards/arm/stm32/olimex-stm32-p407/configs/knsh/defconfig
index 99fb798..f6247e9 100644
--- a/boards/arm/stm32/olimex-stm32-p407/configs/knsh/defconfig
+++ b/boards/arm/stm32/olimex-stm32-p407/configs/knsh/defconfig
@@ -51,6 +51,6 @@ CONFIG_STM32_JTAG_SW_ENABLE=y
 CONFIG_STM32_PWR=y
 CONFIG_STM32_USART3=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=32
 CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
index 1237e55..facd581 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig
@@ -92,7 +92,7 @@ CONFIG_STMPE811_THRESHX=39
 CONFIG_STMPE811_THRESHY=51
 CONFIG_SYMTAB_ORDEREDBYNAME=y
 CONFIG_SYSTEM_READLINE=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_USART3_RXBUFSIZE=128
 CONFIG_USART3_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32/stm32f4discovery/configs/kostest/defconfig b/boards/arm/stm32/stm32f4discovery/configs/kostest/defconfig
index a05b9a2..96d06ba 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/kostest/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/kostest/defconfig
@@ -38,7 +38,7 @@ CONFIG_START_YEAR=2013
 CONFIG_STM32_JTAG_SW_ENABLE=y
 CONFIG_STM32_USART2=y
 CONFIG_SYMTAB_ORDEREDBYNAME=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TESTING_OSTEST=y
 CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3
 CONFIG_TESTING_OSTEST_STACKSIZE=2048
diff --git a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/defconfig b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/defconfig
index 9522a42..4f4334a 100644
--- a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/defconfig
+++ b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/defconfig
@@ -68,6 +68,6 @@ CONFIG_STM32L4_RTC=y
 CONFIG_STM32L4_SAI1PLL=y
 CONFIG_STM32L4_USART2=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/defconfig b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/defconfig
index c9a8f26..79b2acd 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/defconfig
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/defconfig
@@ -73,7 +73,7 @@ CONFIG_STM32L4_SRAM2_HEAP=y
 CONFIG_STM32L4_UART4=y
 CONFIG_STM32L4_USART2=y
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=0
 CONFIG_UART4_BAUD=2000000
 CONFIG_UART4_RXBUFSIZE=512
diff --git a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig
index 97d6add..d13c05b 100644
--- a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig
+++ b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig
@@ -98,7 +98,7 @@ CONFIG_SYSTEM_NETDB=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_NTPC=y
 CONFIG_SYSTEM_PING=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=24
 CONFIG_TESTING_OSTEST=y
 CONFIG_TIVA_ETHERNET=y
diff --git a/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig b/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig
index 16810fe..bc710cb 100644
--- a/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig
+++ b/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig
@@ -58,7 +58,7 @@ CONFIG_START_DAY=7
 CONFIG_START_MONTH=3
 CONFIG_START_YEAR=2021
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=20
 CONFIG_TESTING_GETPRIME=y
 CONFIG_TESTING_OSTEST=y
diff --git a/boards/risc-v/k210/maix-bit/configs/knsh/defconfig b/boards/risc-v/k210/maix-bit/configs/knsh/defconfig
index 56e8cae..b3b2b3e 100644
--- a/boards/risc-v/k210/maix-bit/configs/knsh/defconfig
+++ b/boards/risc-v/k210/maix-bit/configs/knsh/defconfig
@@ -47,7 +47,7 @@ CONFIG_START_DAY=12
 CONFIG_START_MONTH=5
 CONFIG_START_YEAR=2020
 CONFIG_SYSTEM_NSH=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=20
 CONFIG_TESTING_GETPRIME=y
 CONFIG_TESTING_OSTEST=y
diff --git a/boards/risc-v/k210/maix-bit/configs/knsh_smp/defconfig b/boards/risc-v/k210/maix-bit/configs/knsh_smp/defconfig
index 796fe7e..bdd088b 100644
--- a/boards/risc-v/k210/maix-bit/configs/knsh_smp/defconfig
+++ b/boards/risc-v/k210/maix-bit/configs/knsh_smp/defconfig
@@ -52,7 +52,7 @@ CONFIG_START_YEAR=2021
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_SYSTEM=y
 CONFIG_SYSTEM_TASKSET=y
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=20
 CONFIG_TESTING_GETPRIME=y
 CONFIG_TESTING_OSTEST=y
diff --git a/boards/risc-v/k210/maix-bit/configs/kostest/defconfig b/boards/risc-v/k210/maix-bit/configs/kostest/defconfig
index e440989..bc86471 100644
--- a/boards/risc-v/k210/maix-bit/configs/kostest/defconfig
+++ b/boards/risc-v/k210/maix-bit/configs/kostest/defconfig
@@ -43,7 +43,7 @@ CONFIG_STACK_COLORATION=y
 CONFIG_START_DAY=14
 CONFIG_START_MONTH=2
 CONFIG_START_YEAR=2020
-CONFIG_SYS_RESERVED=9
+CONFIG_SYS_RESERVED=8
 CONFIG_TASK_NAME_SIZE=20
 CONFIG_TESTING_OSTEST=y
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 8728cfa..5b22d5b 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -589,8 +589,6 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[])
        noreturn_function;
 #endif
 
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \
-    !defined(CONFIG_DISABLE_PTHREAD)
 /****************************************************************************
  * Name: up_pthread_start
  *
@@ -616,28 +614,11 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[])
  *
  ****************************************************************************/
 
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \
+    !defined(CONFIG_DISABLE_PTHREAD)
 void up_pthread_start(pthread_trampoline_t startup,
                       pthread_startroutine_t entrypt, pthread_addr_t arg)
        noreturn_function;
-
-/****************************************************************************
- * Name: up_pthread_exit
- *
- * Description:
- *   In this kernel mode build, this function will be called to execute a
- *   pthread in user-space. This kernel-mode stub will then be called
- *   transfer control to the user-mode pthread_exit.
- *
- * Input Parameters:
- *   exit       - The user-space pthread_exit function
- *   exit_value - The pointer of the pthread exit parameter
- *
- * Returned Value:
- *   None
- ****************************************************************************/
-
-void up_pthread_exit(pthread_exitroutine_t exit, FAR void *exit_value)
-        noreturn_function;
 #endif
 
 /****************************************************************************
diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h
index 7c4b8ce..3170586 100644
--- a/include/nuttx/pthread.h
+++ b/include/nuttx/pthread.h
@@ -140,7 +140,6 @@ EXTERN const pthread_attr_t g_default_pthread_attr;
  *                 for the new thread
  *    entry      - The new thread starts execution by invoking entry
  *    arg        - It is passed as the sole argument of entry
- *    exit       - The user-space pthread exit function
  *
  * Returned Value:
  *   OK (0) on success; a (non-negated) errno value on failure. The errno
@@ -150,8 +149,7 @@ EXTERN const pthread_attr_t g_default_pthread_attr;
 
 int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
                       FAR const pthread_attr_t *attr,
-                      pthread_startroutine_t entry, pthread_addr_t arg,
-                      pthread_exitroutine_t exit);
+                      pthread_startroutine_t entry, pthread_addr_t arg);
 
 /****************************************************************************
  * Name: nx_pthread_exit
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 710c2ef..eff21d6 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -96,8 +96,7 @@
 #define TCB_FLAG_NONCANCELABLE     (1 << 2)                      /* Bit 2: Pthread is non-cancelable */
 #define TCB_FLAG_CANCEL_DEFERRED   (1 << 3)                      /* Bit 3: Deferred (vs asynch) cancellation type */
 #define TCB_FLAG_CANCEL_PENDING    (1 << 4)                      /* Bit 4: Pthread cancel is pending */
-#define TCB_FLAG_CANCEL_DOING      (1 << 5)                      /* Bit 4: Pthread cancel/exit is doing */
-#define TCB_FLAG_POLICY_SHIFT      (6)                           /* Bit 5-6: Scheduling policy */
+#define TCB_FLAG_POLICY_SHIFT      (5)                           /* Bit 5-6: Scheduling policy */
 #define TCB_FLAG_POLICY_MASK       (3 << TCB_FLAG_POLICY_SHIFT)
 #  define TCB_FLAG_SCHED_FIFO      (0 << TCB_FLAG_POLICY_SHIFT)  /* FIFO scheding policy */
 #  define TCB_FLAG_SCHED_RR        (1 << TCB_FLAG_POLICY_SHIFT)  /* Round robin scheding policy */
@@ -754,7 +753,6 @@ struct pthread_tcb_s
 
   pthread_trampoline_t trampoline;       /* User-space pthread startup function */
   pthread_addr_t arg;                    /* Startup argument                    */
-  pthread_exitroutine_t exit;            /* User-space pthread exit function    */
   FAR void *joininfo;                    /* Detach-able info to support join    */
 };
 #endif /* !CONFIG_DISABLE_PTHREAD */
diff --git a/include/pthread.h b/include/pthread.h
index c679e5c..a687153 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -210,8 +210,6 @@ typedef FAR void *pthread_addr_t;
 typedef CODE pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t);
 typedef pthread_startroutine_t pthread_func_t;
 
-typedef void (*pthread_exitroutine_t)(pthread_addr_t);
-
 typedef void (*pthread_trampoline_t)(pthread_startroutine_t, pthread_addr_t);
 
 struct pthread_attr_s
diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index 7da3fe8..5316efb 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -307,7 +307,7 @@ SYSCALL_LOOKUP(futimens,                   2)
   SYSCALL_LOOKUP(pthread_cond_broadcast,   1)
   SYSCALL_LOOKUP(pthread_cond_signal,      1)
   SYSCALL_LOOKUP(pthread_cond_wait,        2)
-  SYSCALL_LOOKUP(nx_pthread_create,        6)
+  SYSCALL_LOOKUP(nx_pthread_create,        5)
   SYSCALL_LOOKUP(pthread_detach,           1)
   SYSCALL_LOOKUP(nx_pthread_exit,          1)
   SYSCALL_LOOKUP(pthread_getschedparam,    3)
diff --git a/libs/libc/pthread/pthread_create.c b/libs/libc/pthread/pthread_create.c
index c46e36f..b9e8d69 100644
--- a/libs/libc/pthread/pthread_create.c
+++ b/libs/libc/pthread/pthread_create.c
@@ -87,5 +87,5 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
                    pthread_startroutine_t pthread_entry, pthread_addr_t arg)
 {
   return nx_pthread_create(pthread_startup, thread, attr, pthread_entry,
-                           arg, pthread_exit);
+                           arg);
 }
diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c
index 7b66b7c..1a4ef23 100644
--- a/sched/pthread/pthread_cancel.c
+++ b/sched/pthread/pthread_cancel.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <nuttx/arch.h>
-
 #include <sys/types.h>
 #include <unistd.h>
 #include <pthread.h>
@@ -85,15 +83,7 @@ int pthread_cancel(pthread_t thread)
 
   if (tcb == this_task())
     {
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-      tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-      tcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-      up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                      PTHREAD_CANCELED);
-#else
       pthread_exit(PTHREAD_CANCELED);
-#endif
     }
 
   /* Complete pending join operations */
diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c
index e58c91f..95b7bf4 100644
--- a/sched/pthread/pthread_create.c
+++ b/sched/pthread/pthread_create.c
@@ -79,7 +79,6 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
  *   tcb        - Address of the new task's TCB
  *   trampoline - User space pthread startup function
  *   arg        - The argument to provide to the pthread on startup.
- *   exit       - The user-space pthread exit function
  *
  * Returned Value:
  *  None
@@ -88,8 +87,7 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
 
 static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb,
                                      pthread_trampoline_t trampoline,
-                                     pthread_addr_t arg,
-                                     pthread_exitroutine_t exit)
+                                     pthread_addr_t arg)
 {
 #if CONFIG_TASK_NAME_SIZE > 0
   /* Copy the pthread name into the TCB */
@@ -104,7 +102,6 @@ static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb,
 
   ptcb->trampoline = trampoline;
   ptcb->arg        = arg;
-  ptcb->exit       = exit;
 }
 
 /****************************************************************************
@@ -196,12 +193,7 @@ static void pthread_start(void)
   /* The thread has returned (should never happen) */
 
   DEBUGPANIC();
-#ifndef CONFIG_BUILD_FLAT
-  ptcb->cmn.flags &= ~TCB_FLAG_CANCEL_PENDING;
-  ptcb->cmn.flags |= TCB_FLAG_CANCEL_DOING;
-
-  up_pthread_exit(ptcb->exit, NULL);
-#endif
+  pthread_exit(NULL);
 }
 
 /****************************************************************************
@@ -223,7 +215,6 @@ static void pthread_start(void)
  *                 for the new thread
  *    entry      - The new thread starts execution by invoking entry
  *    arg        - It is passed as the sole argument of entry
- *    exit       - The user-space pthread exit function
  *
  * Returned Value:
  *   OK (0) on success; a (non-negated) errno value on failure. The errno
@@ -233,8 +224,7 @@ static void pthread_start(void)
 
 int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
                       FAR const pthread_attr_t *attr,
-                      pthread_startroutine_t entry, pthread_addr_t arg,
-                      pthread_exitroutine_t exit)
+                      pthread_startroutine_t entry, pthread_addr_t arg)
 {
   FAR struct pthread_tcb_s *ptcb;
   FAR struct tls_info_s *info;
@@ -247,7 +237,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
   bool group_joined = false;
 
   DEBUGASSERT(trampoline != NULL);
-  DEBUGASSERT(exit != NULL);
 
   /* If attributes were not supplied, use the default attributes */
 
@@ -467,7 +456,7 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
    * passed by value
    */
 
-  pthread_tcb_setup(ptcb, trampoline, arg, exit);
+  pthread_tcb_setup(ptcb, trampoline, arg);
 
   /* Join the parent's task group */
 
diff --git a/sched/signal/sig_default.c b/sched/signal/sig_default.c
index 4110ae4..2f9063a 100644
--- a/sched/signal/sig_default.c
+++ b/sched/signal/sig_default.c
@@ -217,15 +217,7 @@ static void nxsig_abnormal_termination(int signo)
        * REVISIT:  This will not work if HAVE_GROUP_MEMBERS is not set.
        */
 
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-      rtcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-      rtcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-      up_pthread_exit(((FAR struct pthread_tcb_s *)rtcb)->exit,
-                                  PTHREAD_CANCELED);
-#else
-      pthread_exit(PTHREAD_CANCELED);
-#endif
+      pthread_exit(NULL);
     }
   else
 #endif
diff --git a/sched/task/task_cancelpt.c b/sched/task/task_cancelpt.c
index 4955ab0..ddc94d4 100644
--- a/sched/task/task_cancelpt.c
+++ b/sched/task/task_cancelpt.c
@@ -58,7 +58,6 @@
 
 #include <nuttx/irq.h>
 #include <nuttx/cancelpt.h>
-#include <nuttx/pthread.h>
 
 #include "sched/sched.h"
 #include "semaphore/semaphore.h"
@@ -141,15 +140,7 @@ bool enter_cancellation_point(void)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-                  tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-                  tcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-                  up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                                  PTHREAD_CANCELED);
-#else
                   pthread_exit(PTHREAD_CANCELED);
-#endif
                 }
               else
 #endif
@@ -236,15 +227,7 @@ void leave_cancellation_point(void)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-                  tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-                  tcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-                  up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                                  PTHREAD_CANCELED);
-#else
                   pthread_exit(PTHREAD_CANCELED);
-#endif
                 }
               else
 #endif
diff --git a/sched/task/task_setcancelstate.c b/sched/task/task_setcancelstate.c
index 6b61632..bb08b54 100644
--- a/sched/task/task_setcancelstate.c
+++ b/sched/task/task_setcancelstate.c
@@ -112,15 +112,7 @@ int task_setcancelstate(int state, FAR int *oldstate)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-                  tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-                  tcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-                  up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                                  PTHREAD_CANCELED);
-#else
                   pthread_exit(PTHREAD_CANCELED);
-#endif
                 }
               else
 #endif
diff --git a/sched/task/task_setcanceltype.c b/sched/task/task_setcanceltype.c
index d57cc64..b14fec5 100644
--- a/sched/task/task_setcanceltype.c
+++ b/sched/task/task_setcanceltype.c
@@ -100,15 +100,7 @@ int task_setcanceltype(int type, FAR int *oldtype)
 #ifndef CONFIG_DISABLE_PTHREAD
           if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD)
             {
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-                  tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-                  tcb->flags |= TCB_FLAG_CANCEL_DOING;
-
-                  up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                                  PTHREAD_CANCELED);
-#else
-                  pthread_exit(PTHREAD_CANCELED);
-#endif
+              pthread_exit(PTHREAD_CANCELED);
             }
           else
 #endif
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index 46e467d..12785b7 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -72,7 +72,7 @@
 "munmap","sys/mman.h","defined(CONFIG_FS_RAMMAP)","int","FAR void *","size_t"
 "nx_mkfifo","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char *","mode_t","size_t"
 "nx_pipe","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|FAR int *","size_t","int"
-"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_trampoline_t","FAR pthread_t *","FAR const pthread_attr_t *","pthread_startroutine_t","pthread_addr_t","pthread_exitroutine_t"
+"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_trampoline_t","FAR pthread_t *","FAR const pthread_attr_t *","pthread_startroutine_t","pthread_addr_t"
 "nx_pthread_exit","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","noreturn","pthread_addr_t"
 "nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char *","FAR va_list *"
 "nxsched_get_stackinfo","nuttx/sched.h","","int","pid_t","FAR struct stackinfo_s *"

[incubator-nuttx] 01/05: Revert "pthread: Avoid recursive pthread_exit call"

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 6814b1416f225bb1c1aa6c07c186f19966c7dee7
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Wed Jan 26 10:46:31 2022 +0800

    Revert "pthread: Avoid recursive pthread_exit call"
    
    This reverts commit a2941532bdacba9b8e69dfae4b365aff33f0503a.
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 sched/pthread/pthread_cancel.c   |  3 ++-
 sched/signal/sig_default.c       |  3 ++-
 sched/task/task_cancelpt.c       |  6 ++++--
 sched/task/task_setcancelstate.c |  3 ++-
 sched/task/task_setcanceltype.c  | 11 ++++++-----
 5 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c
index 22d35f3..7b66b7c 100644
--- a/sched/pthread/pthread_cancel.c
+++ b/sched/pthread/pthread_cancel.c
@@ -85,9 +85,10 @@ int pthread_cancel(pthread_t thread)
 
   if (tcb == this_task())
     {
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
       tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
       tcb->flags |= TCB_FLAG_CANCEL_DOING;
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+
       up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
                       PTHREAD_CANCELED);
 #else
diff --git a/sched/signal/sig_default.c b/sched/signal/sig_default.c
index e66ad81..4110ae4 100644
--- a/sched/signal/sig_default.c
+++ b/sched/signal/sig_default.c
@@ -217,9 +217,10 @@ static void nxsig_abnormal_termination(int signo)
        * REVISIT:  This will not work if HAVE_GROUP_MEMBERS is not set.
        */
 
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
       rtcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
       rtcb->flags |= TCB_FLAG_CANCEL_DOING;
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+
       up_pthread_exit(((FAR struct pthread_tcb_s *)rtcb)->exit,
                                   PTHREAD_CANCELED);
 #else
diff --git a/sched/task/task_cancelpt.c b/sched/task/task_cancelpt.c
index c7c393f..4955ab0 100644
--- a/sched/task/task_cancelpt.c
+++ b/sched/task/task_cancelpt.c
@@ -141,9 +141,10 @@ bool enter_cancellation_point(void)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
                   tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
                   tcb->flags |= TCB_FLAG_CANCEL_DOING;
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+
                   up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
                                   PTHREAD_CANCELED);
 #else
@@ -235,9 +236,10 @@ void leave_cancellation_point(void)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
                   tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
                   tcb->flags |= TCB_FLAG_CANCEL_DOING;
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+
                   up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
                                   PTHREAD_CANCELED);
 #else
diff --git a/sched/task/task_setcancelstate.c b/sched/task/task_setcancelstate.c
index 63f3ef3..6b61632 100644
--- a/sched/task/task_setcancelstate.c
+++ b/sched/task/task_setcancelstate.c
@@ -112,9 +112,10 @@ int task_setcancelstate(int state, FAR int *oldstate)
               if ((tcb->flags & TCB_FLAG_TTYPE_MASK) ==
                   TCB_FLAG_TTYPE_PTHREAD)
                 {
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
                   tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
                   tcb->flags |= TCB_FLAG_CANCEL_DOING;
-#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+
                   up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
                                   PTHREAD_CANCELED);
 #else
diff --git a/sched/task/task_setcanceltype.c b/sched/task/task_setcanceltype.c
index f33aeb1..d57cc64 100644
--- a/sched/task/task_setcanceltype.c
+++ b/sched/task/task_setcanceltype.c
@@ -100,13 +100,14 @@ int task_setcanceltype(int type, FAR int *oldtype)
 #ifndef CONFIG_DISABLE_PTHREAD
           if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD)
             {
-              tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
-              tcb->flags |= TCB_FLAG_CANCEL_DOING;
 #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-              up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
-                               PTHREAD_CANCELED);
+                  tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
+                  tcb->flags |= TCB_FLAG_CANCEL_DOING;
+
+                  up_pthread_exit(((FAR struct pthread_tcb_s *)tcb)->exit,
+                                  PTHREAD_CANCELED);
 #else
-              pthread_exit(PTHREAD_CANCELED);
+                  pthread_exit(PTHREAD_CANCELED);
 #endif
             }
           else