diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-11 21:39:39 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-11 21:39:39 +0000 |
commit | 3192d123fd3fabeac0a58eadb90ccd86411910d4 (patch) | |
tree | c5d73a8df2e0ca85da53ba8ab344f19e34466663 /nuttx/mm/mm_granalloc.c | |
parent | 63240531781806cb440108ebd5ad0c3dc62510d3 (diff) | |
download | px4-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_granalloc.c')
-rw-r--r-- | nuttx/mm/mm_granalloc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nuttx/mm/mm_granalloc.c b/nuttx/mm/mm_granalloc.c index a8802a6c5..0e94d464b 100644 --- a/nuttx/mm/mm_granalloc.c +++ b/nuttx/mm/mm_granalloc.c @@ -93,7 +93,7 @@ static inline void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc, ngranules -= avail; } - /* Handle the cae where where all of the granules come from one entry */ + /* Handle the case where where all of the granules come from one entry */ else { @@ -135,8 +135,13 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) int j; DEBUGASSERT(priv && size <= 32 * (1 << priv->log2gran)); + if (priv && size > 0) { + /* Get exclusive access to the GAT */ + + gran_semtake(priv); + /* How many contiguous granules we we need to find? */ tmpmask = (1 << priv->log2gran) - 1; @@ -186,6 +191,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) /* And return the allocation address */ + gran_semgive(priv); return (FAR void *)alloc; } @@ -207,6 +213,7 @@ static inline FAR void *gran_common_alloc(FAR struct gran_s *priv, size_t size) } } + gran_semgive(priv); return NULL; } |