diff options
-rw-r--r-- | cpukit/ChangeLog | 10 | ||||
-rw-r--r-- | cpukit/libblock/src/bdbuf.c | 37 |
2 files changed, 33 insertions, 14 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index b80eddb59b..a83d536a1f 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,13 @@ +2009-11-02 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libblock/src/bdbuf.c: Fixed buffer recycling. See test + "libtests/block03". + +2009-11-02 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libblock/src/bdbuf.c: Wake-up access waiters after sync. See test + "libtests/block04". + 2009-10-30 Glenn Humphrey <glenn.humphrey@oarcorp.com> PR pr1462/cpukit 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; |