diff --git a/arch/arm/src/common/up_exit.c b/arch/arm/src/common/up_exit.c index d46e1db585..8f0d2322dc 100644 --- a/arch/arm/src/common/up_exit.c +++ b/arch/arm/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * common/up_exit.c * - * Copyright (C) 2007-2009, 201-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 201-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -145,7 +146,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -153,13 +154,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -180,6 +185,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/avr/src/common/up_exit.c b/arch/avr/src/common/up_exit.c index a82c640d69..c6b8d9354f 100644 --- a/arch/avr/src/common/up_exit.c +++ b/arch/avr/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/avr/src/common/up_exit.c * - * Copyright (C) 2010, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -152,13 +153,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -179,6 +184,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/hc/src/common/up_exit.c b/arch/hc/src/common/up_exit.c index 9b20fc8aba..096d2c0a68 100644 --- a/arch/hc/src/common/up_exit.c +++ b/arch/hc/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/hc/src/common/up_exit.c * - * Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s* tcb; + struct tcb_s* tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -152,13 +153,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -179,6 +184,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/mips/src/common/up_exit.c b/arch/mips/src/common/up_exit.c index 936cf4f11a..06229bd393 100644 --- a/arch/mips/src/common/up_exit.c +++ b/arch/mips/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/mips/src/common/up_exit.c * - * Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -146,7 +147,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -154,13 +155,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -181,6 +186,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/misoc/src/lm32/lm32_exit.c b/arch/misoc/src/lm32/lm32_exit.c index 8dd96b0a3a..5995b94029 100644 --- a/arch/misoc/src/lm32/lm32_exit.c +++ b/arch/misoc/src/lm32/lm32_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/misoc/src/lm32/lm32_exit.c * - * Copyright (C) 2010, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * Ramtin Amin * @@ -56,10 +57,6 @@ #include "group/group.h" #include "lm32.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -143,7 +140,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -151,13 +148,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -178,6 +179,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/or1k/src/common/up_exit.c b/arch/or1k/src/common/up_exit.c index eef08e4c54..b7ab42a246 100644 --- a/arch/or1k/src/common/up_exit.c +++ b/arch/or1k/src/common/up_exit.c @@ -145,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -153,13 +153,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -180,6 +184,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/renesas/src/common/up_exit.c b/arch/renesas/src/common/up_exit.c index 81843c5ccc..9ad643d4fa 100644 --- a/arch/renesas/src/common/up_exit.c +++ b/arch/renesas/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/renesas/src/=common/up_exit.c * - * Copyright (C) 2008-2009, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s* tcb; + struct tcb_s* tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -152,13 +153,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -179,7 +184,11 @@ void _exit(int status) (void)group_addrenv(tcb); #endif - /* Then switch contexts */ + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); } diff --git a/arch/risc-v/src/common/up_exit.c b/arch/risc-v/src/common/up_exit.c index 0f4b56e7ef..c3fc430716 100644 --- a/arch/risc-v/src/common/up_exit.c +++ b/arch/risc-v/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/risc-v/src/common/up_exit.c * - * Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -146,7 +147,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -154,13 +155,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -181,6 +186,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/sim/src/up_exit.c b/arch/sim/src/up_exit.c index 2a17a8075b..18cc0339ca 100644 --- a/arch/sim/src/up_exit.c +++ b/arch/sim/src/up_exit.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sim/src/up_exit.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -65,10 +65,14 @@ void _exit(int status) { - FAR struct tcb_s *tcb; + FAR struct tcb_s *tcb = this_task(); sinfo("TCB=%p exiting\n", tcb); + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -80,6 +84,10 @@ void _exit(int status) tcb = this_task(); sinfo("New Active Task TCB=%p\n", tcb); + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* The way that we handle signals in the simulation is kind of * a kludge. This would be unsafe in a truly multi-threaded, interrupt * driven environment. diff --git a/arch/x86/src/common/up_exit.c b/arch/x86/src/common/up_exit.c index e5bcd30b46..434d16932a 100644 --- a/arch/x86/src/common/up_exit.c +++ b/arch/x86/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * common/up_exit.c * - * Copyright (C) 2011, 2013-2014, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013-2014, 2016-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s* tcb; + struct tcb_s* tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -152,13 +153,17 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -179,6 +184,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/xtensa/src/common/xtensa_exit.c b/arch/xtensa/src/common/xtensa_exit.c index 6d063c7ce3..a289dc950b 100644 --- a/arch/xtensa/src/common/xtensa_exit.c +++ b/arch/xtensa/src/common/xtensa_exit.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/xtensa/src/common/xtensa_exit.c * - * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -146,7 +146,7 @@ static void _xtensa_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - struct tcb_s *tcb; + struct tcb_s *tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -154,17 +154,20 @@ void _exit(int status) (void)enter_critical_section(); - sinfo("TCB=%p exiting\n", this_task()); + sinfo("TCB=%p exiting\n", tcb); #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); sched_foreach(_xtensa_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + #if XCHAL_CP_NUM > 0 /* Disable co-processor support for the task that is exit-ing. */ - tcb = this_task(); xtensa_coproc_disable(&tcb->xcp.cpstate, XTENSA_CP_ALLSET); #endif @@ -194,6 +197,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ xtensa_context_restore(tcb->xcp.regs); diff --git a/arch/z16/src/common/up_exit.c b/arch/z16/src/common/up_exit.c index 58b2a54286..807812d55d 100644 --- a/arch/z16/src/common/up_exit.c +++ b/arch/z16/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/z16/src/common/up_exit.c * - * Copyright (C) 2008-2009, 2013, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -144,7 +145,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - FAR struct tcb_s* tcb; + FAR struct tcb_s* tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -159,6 +160,10 @@ void _exit(int status) sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -170,6 +175,10 @@ void _exit(int status) tcb = this_task(); sinfo("New Active Task TCB=%p\n", tcb); + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(tcb); diff --git a/arch/z80/src/common/up_exit.c b/arch/z80/src/common/up_exit.c index 71e8ff5193..044bacb538 100644 --- a/arch/z80/src/common/up_exit.c +++ b/arch/z80/src/common/up_exit.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/z80/src/common/up_exit.c * - * Copyright (C) 2007-2009, 2013-2014, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013-2014, 2017-2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -146,7 +147,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) void _exit(int status) { - FAR struct tcb_s* tcb; + FAR struct tcb_s* tcb = this_task(); /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. @@ -161,6 +162,10 @@ void _exit(int status) sched_foreach(_up_dumponexit, NULL); #endif + /* Update scheduler parameters */ + + sched_suspend_scheduler(tcb); + /* Destroy the task at the head of the ready to run list. */ (void)task_exit(); @@ -182,6 +187,10 @@ void _exit(int status) (void)group_addrenv(tcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(tcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(tcb);