In all implementations of _exit(), use enter_critical_section() vs. disabling local interrupts.

This commit is contained in:
Gregory Nutt 2017-01-13 11:08:24 -06:00
parent a51b5b7e17
commit 3ed091376c
11 changed files with 74 additions and 69 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* common/up_exit.c
*
* Copyright (C) 2007-2009, 201-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 201-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,10 +41,11 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -141,14 +142,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next task is
* started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
#ifdef CONFIG_SMP
(void)spin_trylock(&g_cpu_irqlock);
#endif
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/avr/src/common/up_exit.c
*
* Copyright (C) 2010, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,10 +41,11 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -140,11 +141,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/hc/src/common/up_exit.c
*
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,10 +41,11 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -140,11 +141,11 @@ void _exit(int status)
{
struct tcb_s* tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/mips/src/common/up_exit.c
*
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,10 +43,11 @@
#include <syscall.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -142,11 +143,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,9 +1,9 @@
/****************************************************************************
* arch/misoc/src/lm32/lm32_exit.c
*
* Copyright (C) 2010, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Ramtin Amin <keytwo@gmail.com>
* Ramtin Amin <keytwo@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -42,8 +42,9 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
# include <nuttx/fs/fs.h>
#endif
@ -139,11 +140,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/renesas/src/=common/up_exit.c
*
* Copyright (C) 2008-2009, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,9 +43,9 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -141,11 +141,11 @@ void _exit(int status)
{
struct tcb_s* tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/risc-v/src/common/up_exit.c
*
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,10 +43,11 @@
#include <syscall.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -142,11 +143,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* common/up_exit.c
*
* Copyright (C) 2011, 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,10 +41,11 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -140,11 +141,11 @@ void _exit(int status)
{
struct tcb_s* tcb;
/* Disable interrupts. They will be restored when the next
* task is started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/xtensa/src/common/xtensa_exit.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,10 +43,11 @@
#include <syscall.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "task/task.h"
@ -142,11 +143,11 @@ void _exit(int status)
{
struct tcb_s *tcb;
/* Disable interrupts. They will be restored when the next task is
* started.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", this_task());

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/z16/src/common/up_exit.c
*
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,9 +43,9 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "chip/chip.h"
@ -141,11 +141,11 @@ void _exit(int status)
{
FAR struct tcb_s* tcb;
/* Disable interrupts. Interrupts will remain disabled until
* the new task is resumed below.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", tcb);

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/z80/src/common/up_exit.c
*
* Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2013-2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,9 +44,9 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#ifdef CONFIG_DUMP_ON_EXIT
#include <nuttx/fs/fs.h>
# include <nuttx/fs/fs.h>
#endif
#include "chip/chip.h"
@ -143,11 +143,11 @@ void _exit(int status)
{
FAR struct tcb_s* tcb;
/* Disable interrupts. Interrupts will remain disabled until
* the new task is resumed below.
/* Make sure that we are in a critical section with local interrupts.
* The IRQ state will be restored when the next task is started.
*/
(void)up_irq_save();
(void)enter_critical_section();
sinfo("TCB=%p exiting\n", tcb);