From: Ben Pfaff Date: Fri, 8 Dec 2006 16:06:31 +0000 (+0000) Subject: Revert the bitmap randomization change, which had the side effect of X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=cd61e4747c8d597c302f0ef3f1b0a2b6ed5ce890;hp=8008245440011d25307535c3bb6757eb72ae5abe Revert the bitmap randomization change, which had the side effect of causing enough disk fragmentation for the base (extent-based) file system that in some cases tests would fail. Also, it confused the hell out of everyone. Failed experiment. --- diff --git a/src/lib/kernel/bitmap.c b/src/lib/kernel/bitmap.c index 77edf22..d323b89 100644 --- a/src/lib/kernel/bitmap.c +++ b/src/lib/kernel/bitmap.c @@ -1,7 +1,6 @@ #include "bitmap.h" #include #include -#include #include #include #include "threads/malloc.h" @@ -290,7 +289,7 @@ bitmap_all (const struct bitmap *b, size_t start, size_t cnt) /* Finding set or unset bits. */ -/* Finds and returns the starting index of a group of CNT +/* Finds and returns the starting index of the first group of CNT consecutive bits in B at or after START that are all set to VALUE. If there is no such group, returns BITMAP_ERROR. */ @@ -303,20 +302,15 @@ bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value) if (cnt <= b->bit_cnt) { size_t last = b->bit_cnt - cnt; - size_t middle = start + random_ulong () % (last - start + 1); - size_t i = middle; - do - { - if (!bitmap_contains (b, i, cnt, !value)) - return i; - i = i != last ? i + 1 : start; - } - while (i != middle); + size_t i; + for (i = start; i <= last; i++) + if (!bitmap_contains (b, i, cnt, !value)) + return i; } return BITMAP_ERROR; } -/* Finds a group of CNT consecutive bits in B at or after +/* Finds the first group of CNT consecutive bits in B at or after START that are all set to VALUE, flips them all to !VALUE, and returns the index of the first bit in the group. If there is no such group, returns BITMAP_ERROR.