summaryrefslogtreecommitdiffstats
path: root/cpukit/libblock/src/bdbuf.c
diff options
context:
space:
mode:
authorThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2009-11-02 09:50:06 +0000
committerThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2009-11-02 09:50:06 +0000
commit6c9b39012d2bf1a495ca5282489066ca5cd7b94d (patch)
tree9eb8e2eafe64273c15bffcf28d922bd766917e73 /cpukit/libblock/src/bdbuf.c
parent2009-01-02 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-6c9b39012d2bf1a495ca5282489066ca5cd7b94d.tar.bz2
Fixed buffer recycling
Wake-up access waiters after sync
Diffstat (limited to 'cpukit/libblock/src/bdbuf.c')
-rw-r--r--cpukit/libblock/src/bdbuf.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c
index 3007b16d40..600ae1b26b 100644
--- a/cpukit/libblock/src/bdbuf.c
+++ b/cpukit/libblock/src/bdbuf.c
@@ -1134,24 +1134,30 @@ rtems_bdbuf_get_next_bd (size_t bds_per_group,
bd->group->bds_per_group, bds_per_group);
/*
- * If this bd is already part of a group that supports the same number of
- * BDs per group return it. If the bd is part of another group check the
- * number of users and if 0 we can take this group and resize it.
+ * If nobody waits for this BD, we may recycle it.
*/
- if (bd->group->bds_per_group == bds_per_group)
- {
- rtems_chain_extract (node);
- return bd;
- }
-
- if (bd->group->users == 0)
+ if (bd->waiters == 0)
{
/*
- * We use the group to locate the start of the BDs for this group.
+ * If this bd is already part of a group that supports the same number of
+ * BDs per group return it. If the bd is part of another group check the
+ * number of users and if 0 we can take this group and resize it.
*/
- rtems_bdbuf_group_realloc (bd->group, bds_per_group);
- bd = (rtems_bdbuf_buffer*) rtems_chain_get (&bdbuf_cache.ready);
- return bd;
+ if (bd->group->bds_per_group == bds_per_group)
+ {
+ rtems_chain_extract (node);
+ return bd;
+ }
+
+ if (bd->group->users == 0)
+ {
+ /*
+ * We use the group to locate the start of the BDs for this group.
+ */
+ rtems_bdbuf_group_realloc (bd->group, bds_per_group);
+ bd = (rtems_bdbuf_buffer*) rtems_chain_get (&bdbuf_cache.ready);
+ return bd;
+ }
}
node = rtems_chain_next (node);
@@ -2159,6 +2165,9 @@ rtems_bdbuf_sync (rtems_bdbuf_buffer* bd)
rtems_chain_append (&bdbuf_cache.sync, &bd->link);
+ if (bd->waiters)
+ rtems_bdbuf_wake (&bdbuf_cache.access_waiters);
+
rtems_bdbuf_wake_swapper ();
available = false;