diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-11 21:39:39 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-09-11 21:39:39 +0000 |
commit | 7bb74973bd7a1839c12ddf2b1d9221007f31ebc6 (patch) | |
tree | c5d73a8df2e0ca85da53ba8ab344f19e34466663 /nuttx/mm/mm_granfree.c | |
parent | 594b34a3564056f8f003ee9a19aa5837bcb1a4d4 (diff) | |
download | px4-firmware-7bb74973bd7a1839c12ddf2b1d9221007f31ebc6.tar.gz px4-firmware-7bb74973bd7a1839c12ddf2b1d9221007f31ebc6.tar.bz2 px4-firmware-7bb74973bd7a1839c12ddf2b1d9221007f31ebc6.zip |
Fixes for granule allocator
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5131 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/mm/mm_granfree.c')
-rw-r--r-- | nuttx/mm/mm_granfree.c | 17 |
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); } /**************************************************************************** |