errno was clobbered by mm_trysemaphore when task exists

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@591 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-01-30 18:49:31 +00:00
parent 241f70de7a
commit b5d9f23447
7 changed files with 142 additions and 324 deletions

View File

@ -58,17 +58,16 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Funtions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: _up_dumponexit * Name: _up_dumponexit
* *
* Description: * Description:
* Dump the state of all tasks whenever on task exits. This * Dump the state of all tasks whenever on task exits. This is debug
* is debug instrumentation that was added to check file- * instrumentation that was added to check file-related reference counting
* related reference counting but could be useful again * but could be useful again sometime in the future.
* sometime in the future.
* *
****************************************************************************/ ****************************************************************************/
@ -133,13 +132,15 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
****************************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
_TCB* tcb = (_TCB*)g_readytorun.head; _TCB* tcb;
/* Disable interrupts. They will be restored when the next /* Disable interrupts. They will be restored when the next
* task is started. * task is started.
@ -150,41 +151,13 @@ void _exit(int status)
lldbg("TCB=%p exitting\n", tcb); lldbg("TCB=%p exitting\n", tcb);
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
dbg("Other tasks:\n"); lldbg("Other tasks:\n");
sched_foreach(_up_dumponexit, NULL); sched_foreach(_up_dumponexit, NULL);
#endif #endif
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -1,7 +1,7 @@
/************************************************************ /****************************************************************************
* up_exit.c * up_exit.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Included Files * Included Files
************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
@ -49,28 +49,27 @@
#include <nuttx/fs.h> #include <nuttx/fs.h>
#endif #endif
/************************************************************ /****************************************************************************
* Private Definitions * Private Definitions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Data * Private Data
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Funtions * Private Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _up_dumponexit * Name: _up_dumponexit
* *
* Description: * Description:
* Dump the state of all tasks whenever on task exits. This * Dump the state of all tasks whenever on task exits. This is debug
* is debug instrumentation that was added to check file- * instrumentation that was added to check file-related reference counting
* related reference counting but could be useful again * but could be useful again sometime in the future.
* sometime in the future.
* *
************************************************************/ ****************************************************************************/
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg) static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
@ -113,23 +112,30 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
} }
#endif #endif
/************************************************************ /****************************************************************************
* Public Funtions * Public Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _exit * Name: _exit
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
_TCB* tcb = (_TCB*)g_readytorun.head; _TCB* tcb;
irqstate_t flags = irqsave();
/* Disable interrupts. They will be restored when the next
* task is started.
*/
(void)irqsave();
lldbg("TCB=%p exitting\n", tcb); lldbg("TCB=%p exitting\n", tcb);
@ -138,37 +144,9 @@ void _exit(int status)
sched_foreach(_up_dumponexit, NULL); sched_foreach(_up_dumponexit, NULL);
#endif #endif
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -1,7 +1,7 @@
/************************************************************ /****************************************************************************
* up_exit.c * up_exit.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Included Files * Included Files
************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
@ -49,28 +49,27 @@
#include <nuttx/fs.h> #include <nuttx/fs.h>
#endif #endif
/************************************************************ /****************************************************************************
* Private Definitions * Private Definitions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Data * Private Data
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Funtions * Private Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _up_dumponexit * Name: _up_dumponexit
* *
* Description: * Description:
* Dump the state of all tasks whenever on task exits. This * Dump the state of all tasks whenever on task exits. This is debug
* is debug instrumentation that was added to check file- * instrumentation that was added to check file-related reference counting
* related reference counting but could be useful again * but could be useful again sometime in the future.
* sometime in the future.
* *
************************************************************/ ****************************************************************************/
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg) static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
@ -112,22 +111,24 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
} }
#endif #endif
/************************************************************ /****************************************************************************
* Public Funtions * Public Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _exit * Name: _exit
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
_TCB* tcb = (_TCB*)g_readytorun.head; _TCB* tcb;
/* Disable interrupts. They will be restored when the next /* Disable interrupts. They will be restored when the next
* task is started. * task is started.
@ -138,41 +139,13 @@ void _exit(int status)
lldbg("TCB=%p exitting\n", tcb); lldbg("TCB=%p exitting\n", tcb);
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
dbg("Other tasks:\n"); lldbg("Other tasks:\n");
sched_foreach(_up_dumponexit, NULL); sched_foreach(_up_dumponexit, NULL);
#endif #endif
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -1,7 +1,7 @@
/************************************************************ /****************************************************************************
* up_exit.c * up_exit.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Included Files * Included Files
************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
@ -46,34 +46,36 @@
#include "os_internal.h" #include "os_internal.h"
#include "up_internal.h" #include "up_internal.h"
/************************************************************ /****************************************************************************
* Private Definitions * Private Definitions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Data * Private Data
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Funtions * Private Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Public Funtions * Public Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _exit * Name: _exit
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
FAR _TCB* tcb = (FAR _TCB*)g_readytorun.head; FAR _TCB* tcb;
dbg("TCB=%p exitting\n", tcb); dbg("TCB=%p exitting\n", tcb);
@ -83,37 +85,9 @@ void _exit(int status)
EA = 0; EA = 0;
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -1,7 +1,7 @@
/************************************************************ /****************************************************************************
* up_exit.c * up_exit.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Included Files * Included Files
************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
@ -45,68 +45,42 @@
#include "os_internal.h" #include "os_internal.h"
#include "up_internal.h" #include "up_internal.h"
/************************************************************ /****************************************************************************
* Private Definitions * Private Definitions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Data * Private Data
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Private Funtions * Private Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Public Funtions * Public Functions
************************************************************/ ****************************************************************************/
/************************************************************ /****************************************************************************
* Name: _exit * Name: _exit
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
_TCB* tcb = (_TCB*)g_readytorun.head; _TCB* tcb;
sdbg("TCB=%p exitting\n", tcb); sdbg("TCB=%p exitting\n", tcb);
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now.
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -69,10 +69,9 @@
* Name: _up_dumponexit * Name: _up_dumponexit
* *
* Description: * Description:
* Dump the state of all tasks whenever on task exits. This * Dump the state of all tasks whenever on task exits. This is debug
* is debug instrumentation that was added to check file- * instrumentation that was added to check file-related reference counting
* related reference counting but could be useful again * but could be useful again sometime in the future.
* sometime in the future.
* *
****************************************************************************/ ****************************************************************************/
@ -137,13 +136,15 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
****************************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
FAR _TCB* tcb = (FAR _TCB*)g_readytorun.head; FAR _TCB* tcb;
/* Disable interrupts. Interrupts will remain disabled until /* Disable interrupts. Interrupts will remain disabled until
* the new task is resumed below. * the new task is resumed below.
@ -158,37 +159,9 @@ void _exit(int status)
sched_foreach(_up_dumponexit, NULL); sched_foreach(_up_dumponexit, NULL);
#endif #endif
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.

View File

@ -69,10 +69,9 @@
* Name: _up_dumponexit * Name: _up_dumponexit
* *
* Description: * Description:
* Dump the state of all tasks whenever on task exits. This * Dump the state of all tasks whenever on task exits. This is debug
* is debug instrumentation that was added to check file- * instrumentation that was added to check file-related reference counting
* related reference counting but could be useful again * but could be useful again sometime in the future.
* sometime in the future.
* *
****************************************************************************/ ****************************************************************************/
@ -137,13 +136,15 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
* *
* Description: * Description:
* This function causes the currently executing task to cease * This function causes the currently executing task to cease
* to exist. This is a special case of task_delete(). * to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the the next ready to run task.
* *
****************************************************************************/ ****************************************************************************/
void _exit(int status) void _exit(int status)
{ {
FAR _TCB* tcb = (FAR _TCB*)g_readytorun.head; FAR _TCB* tcb;
/* Disable interrupts. Interrupts will remain disabled until /* Disable interrupts. Interrupts will remain disabled until
* the new task is resumed below. * the new task is resumed below.
@ -158,37 +159,9 @@ void _exit(int status)
sched_foreach(_up_dumponexit, NULL); sched_foreach(_up_dumponexit, NULL);
#endif #endif
/* Remove the tcb task from the ready-to-run list. We can /* Destroy the task at the head of the ready to run list. */
* ignore the return value because we know that a context
* switch is needed.
*/
(void)sched_removereadytorun(tcb); (void)task_deletecurrent();
/* We are not in a bad stack-- the head of the ready to run task list
* does not correspond to the thread that is running. Disabling pre-
* emption on this TCB should be enough to keep things stable.
*/
sched_lock();
/* Move the TCB to the specified blocked task list and delete it */
sched_addblocked(tcb, TSTATE_TASK_INACTIVE);
task_delete(tcb->pid);
/* If there are any pending tasks, then add them to the g_readytorun
* task list now
*/
if (g_pendingtasks.head)
{
(void)sched_mergepending();
}
/* Now calling sched_unlock() should have no effect */
sched_unlock();
/* Now, perform the context switch to the new ready-to-run task at the /* Now, perform the context switch to the new ready-to-run task at the
* head of the list. * head of the list.