summaryrefslogtreecommitdiff
path: root/nuttx/sched/atexit.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-12 03:42:08 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-12 03:42:08 +0000
commit95317af605c883b464a4c5b524632193614bfd24 (patch)
treee624625959a92777dd79d8949e46072752103ae9 /nuttx/sched/atexit.c
parentbf91815c3fd4be584af323447605624b33932f63 (diff)
downloadpx4-nuttx-95317af605c883b464a4c5b524632193614bfd24.tar.gz
px4-nuttx-95317af605c883b464a4c5b524632193614bfd24.tar.bz2
px4-nuttx-95317af605c883b464a4c5b524632193614bfd24.zip
Add SLIP driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3369 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/atexit.c')
-rw-r--r--nuttx/sched/atexit.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/nuttx/sched/atexit.c b/nuttx/sched/atexit.c
index 5ca6c5e0f..ca7ef58c4 100644
--- a/nuttx/sched/atexit.c
+++ b/nuttx/sched/atexit.c
@@ -1,7 +1,7 @@
/************************************************************************
* sched/atexit.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -37,14 +37,20 @@
* Included Files
************************************************************************/
+#include <nuttx/config.h>
+
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <debug.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+
#include "os_internal.h"
+#ifdef CONFIG_SCHED_ATEXT
+
/************************************************************************
* Definitions
************************************************************************/
@@ -83,7 +89,7 @@
* func
*
* Return Value:
- * zero on success.
+ * Zero on success. Non-zero on failure.
*
************************************************************************/
@@ -92,11 +98,19 @@ int atexit(void (*func)(void))
_TCB *tcb = (_TCB*)g_readytorun.head;
int ret = ERROR;
- if ((func) && (!tcb->exitfunc))
+ /* The following must be atomic */
+
+ sched_lock();
+ if (func && !tcb->exitfunc)
{
tcb->exitfunc = func;
ret = OK;
}
+
+ sched_unlock();
return ret;
}
+#endif /* CONFIG_SCHED_ATEXT */
+
+