summaryrefslogtreecommitdiff
path: root/nuttx/sched/task_delete.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-31 23:39:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-31 23:39:12 +0000
commitd9e1bd9b855de8783076cddae7e17177d071a8b5 (patch)
tree4ec59e18f087faba4945cf1bb1d7855d44e82080 /nuttx/sched/task_delete.c
parentc0191ed21b7cb6f978fbde31d7e106a8c801ee03 (diff)
downloadpx4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.tar.gz
px4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.tar.bz2
px4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.zip
Add on_exit(); Re-order some logic in the task shutdown sequence. Sometimes some complex logic needs to execute when closing file descriptors and this needs to happen early while the task is still healthy
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4354 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/task_delete.c')
-rw-r--r--nuttx/sched/task_delete.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/nuttx/sched/task_delete.c b/nuttx/sched/task_delete.c
index 31715051a..4cd2b3ba7 100644
--- a/nuttx/sched/task_delete.c
+++ b/nuttx/sched/task_delete.c
@@ -140,6 +140,16 @@ int task_delete(pid_t pid)
PANIC(OSERR_BADDELETESTATE);
}
+ /* Perform common task termination logic (flushing streams, calling
+ * functions registered by at_exit/on_exit, etc.). We need to do
+ * this as early as possible so that higher level clean-up logic
+ * can run in a healthy tasking environment.
+ *
+ * I suppose EXIT_SUCCESS is an appropriate return value???
+ */
+
+ task_exithook(dtcb, EXIT_SUCCESS);
+
/* Remove the task from the OS's tasks lists. */
saved_state = irqsave();
@@ -151,13 +161,6 @@ int task_delete(pid_t pid)
sched_unlock();
- /* Perform common task termination logic (flushing streams, calling
- * functions registered by at_exit/on_exit, etc.). I suppose EXIT_SUCCESS
- * is an appropriate return value???
- */
-
- task_exithook(dtcb, EXIT_SUCCESS);
-
/* Deallocate its TCB */
sched_releasetcb(dtcb);