summaryrefslogtreecommitdiff
path: root/nuttx/mm/mm_granfree.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-11 21:39:39 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-11 21:39:39 +0000
commit3192d123fd3fabeac0a58eadb90ccd86411910d4 (patch)
treec5d73a8df2e0ca85da53ba8ab344f19e34466663 /nuttx/mm/mm_granfree.c
parent63240531781806cb440108ebd5ad0c3dc62510d3 (diff)
downloadpx4-nuttx-3192d123fd3fabeac0a58eadb90ccd86411910d4.tar.gz
px4-nuttx-3192d123fd3fabeac0a58eadb90ccd86411910d4.tar.bz2
px4-nuttx-3192d123fd3fabeac0a58eadb90ccd86411910d4.zip
Fixes for granule allocator
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5131 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/mm/mm_granfree.c')
-rw-r--r--nuttx/mm/mm_granfree.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/nuttx/mm/mm_granfree.c b/nuttx/mm/mm_granfree.c
index e359cded8..96fdda87e 100644
--- a/nuttx/mm/mm_granfree.c
+++ b/nuttx/mm/mm_granfree.c
@@ -79,6 +79,10 @@ static inline void gran_common_free(FAR struct gran_s *priv,
DEBUGASSERT(priv && memory && size <= 32 * (1 << priv->log2gran));
+ /* Get exclusive access to the GAT */
+
+ gran_semtake(priv);
+
/* Determine the granule number of the first granule in the allocation */
granno = ((uintptr_t)memory - priv->heapstart) >> priv->log2gran;
@@ -102,21 +106,22 @@ static inline void gran_common_free(FAR struct gran_s *priv,
{
priv->gat[gatidx] &= ~(0xffffffff << gatbit);
ngranules -= avail;
+
+ /* Clear bits in the second GAT entry */
+
+ gatmask = 0xffffffff >> (32 - ngranules);
+ priv->gat[gatidx+1] &= ~(gatmask << gatbit);
}
- /* Handle the cae where where all of the granules came from one entry */
+ /* Handle the case where where all of the granules came from one entry */
else
{
gatmask = 0xffffffff >> (32 - ngranules);
priv->gat[gatidx] &= ~(gatmask << gatbit);
- return;
}
- /* Clear bits in the second GAT entry */
-
- gatmask = 0xffffffff >> (32 - ngranules);
- priv->gat[gatidx+1] &= ~(gatmask << gatbit);
+ gran_semgive(priv);
}
/****************************************************************************