--- /dev/null
+--- bitmap.c.~1.5.~ 2004-10-06 14:29:56.000000000 -0700
++++ bitmap.c 2004-11-03 14:35:22.000000000 -0800
+@@ -1,6 +1,7 @@
+ #include "bitmap.h"
+ #include <debug.h>
+ #include <limits.h>
++#include <random.h>
+ #include <round.h>
+ #include <stdio.h>
+ #include "threads/malloc.h"
+@@ -212,14 +213,25 @@ size_t
+ bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value)
+ {
+ size_t idx, last;
++ size_t n = 0, m;
+
+ ASSERT (b != NULL);
+ ASSERT (start <= b->bit_cnt);
+
+ for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
+ if (!contains (b, idx, idx + cnt, !value))
++ n++;
++ if (n == 0)
++ return BITMAP_ERROR;
++
++ random_init (0);
++ m = random_ulong () % n;
++
++ for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
++ if (!contains (b, idx, idx + cnt, !value) && m-- == 0)
+ return idx;
+- return BITMAP_ERROR;
++
++ NOT_REACHED ();
+ }
+
+ /* Finds the first group of CNT consecutive bits in B at or after