summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-14 18:58:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-14 18:58:21 +0000
commit78cbcfd2a16c0cf3763173ce0a14d656bede0135 (patch)
tree5fd6d76721ba77adb12c7fc265befb5cf264329f /nuttx/lib
parent9daf318dc8fbefa6d41c739fa53baa155b31887f (diff)
downloadpx4-nuttx-78cbcfd2a16c0cf3763173ce0a14d656bede0135.tar.gz
px4-nuttx-78cbcfd2a16c0cf3763173ce0a14d656bede0135.tar.bz2
px4-nuttx-78cbcfd2a16c0cf3763173ce0a14d656bede0135.zip
Add 8052 IRQ test; Fix places where IDLE task could try to wait on semaphoresnuttx-1.1
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@61 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-rw-r--r--nuttx/lib/lib_init.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/nuttx/lib/lib_init.c b/nuttx/lib/lib_init.c
index d6eb5f0a4..0527f921b 100644
--- a/nuttx/lib/lib_init.c
+++ b/nuttx/lib/lib_init.c
@@ -145,11 +145,17 @@ void lib_addreflist(FAR struct streamlist *list)
{
if (list)
{
- /* Increment the reference count on the list */
+ /* Increment the reference count on the list.
+ * NOTE: that we disable interrupts to do this
+ * (vs. taking the list semaphore). We do this
+ * because file cleanup operations often must be
+ * done from the IDLE task which cannot wait
+ * on semaphores.
+ */
- _lib_semtake(list);
+ register irqstate_t flags = irqsave();
list->sl_crefs++;
- _lib_semgive(list);
+ irqrestore(flags);
}
}
@@ -163,14 +169,22 @@ void lib_releaselist(FAR struct streamlist *list)
int crefs;
if (list)
{
- /* Decrement the reference count */
+ /* Decrement the reference count on the list.
+ * NOTE: that we disable interrupts to do this
+ * (vs. taking the list semaphore). We do this
+ * because file cleanup operations often must be
+ * done from the IDLE task which cannot wait
+ * on semaphores.
+ */
- _lib_semtake(list);
+ register irqstate_t flags = irqsave();
crefs = --(list->sl_crefs);
- _lib_semgive(list);
+ irqrestore(flags);
/* If the count decrements to zero, then there is no reference
- * to the structure and it should be deallocated.
+ * to the structure and it should be deallocated. Since there
+ * are references, it would be an error if any task still held
+ * a reference to the list's semaphore.
*/
if (crefs <= 0)