diff options
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/c5471/src/up_exit.c | 11 | ||||
-rw-r--r-- | nuttx/arch/dm320/src/up_exit.c | 11 | ||||
-rw-r--r-- | nuttx/arch/pjrc-8051/src/up_exit.c | 11 | ||||
-rw-r--r-- | nuttx/arch/sim/src/up_exit.c | 14 |
4 files changed, 46 insertions, 1 deletions
diff --git a/nuttx/arch/c5471/src/up_exit.c b/nuttx/arch/c5471/src/up_exit.c index c6f544776..2ef47bdfb 100644 --- a/nuttx/arch/c5471/src/up_exit.c +++ b/nuttx/arch/c5471/src/up_exit.c @@ -145,6 +145,13 @@ void _exit(int status) (void)sched_removereadytorun(tcb); + /* 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); @@ -159,6 +166,10 @@ void _exit(int status) (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 * head of the list. */ diff --git a/nuttx/arch/dm320/src/up_exit.c b/nuttx/arch/dm320/src/up_exit.c index e51180dc6..bb05b1c53 100644 --- a/nuttx/arch/dm320/src/up_exit.c +++ b/nuttx/arch/dm320/src/up_exit.c @@ -149,6 +149,13 @@ void _exit(int status) (void)sched_removereadytorun(tcb); + /* 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); @@ -163,6 +170,10 @@ void _exit(int status) (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 * head of the list. */ diff --git a/nuttx/arch/pjrc-8051/src/up_exit.c b/nuttx/arch/pjrc-8051/src/up_exit.c index a9b641bab..b938d9304 100644 --- a/nuttx/arch/pjrc-8051/src/up_exit.c +++ b/nuttx/arch/pjrc-8051/src/up_exit.c @@ -90,6 +90,13 @@ void _exit(int status) (void)sched_removereadytorun(tcb); + /* 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); @@ -104,6 +111,10 @@ void _exit(int status) (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 * head of the list. */ diff --git a/nuttx/arch/sim/src/up_exit.c b/nuttx/arch/sim/src/up_exit.c index a0a3bdc9a..0f9c4cc56 100644 --- a/nuttx/arch/sim/src/up_exit.c +++ b/nuttx/arch/sim/src/up_exit.c @@ -73,6 +73,7 @@ void _exit(int status) { _TCB* tcb = (_TCB*)g_readytorun.head; + irqstate_t flags; dbg("TCB=%p exitting\n", tcb); @@ -83,13 +84,20 @@ void _exit(int status) (void)sched_removereadytorun(tcb); + /* 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 + * task list now. */ if (g_pendingtasks.head) @@ -97,6 +105,10 @@ void _exit(int status) (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 * head of the list. */ |