1 Modifies bitmap_scan() to return a random set of bits instead of the
2 first set. Helps to stress-test VM implementation.
4 diff -u pintos/src/lib/kernel/bitmap.c~ pintos/src/lib/kernel/bitmap.c
5 --- pintos/src/lib/kernel/bitmap.c~ 2004-10-06 14:29:56.000000000 -0700
6 +++ pintos/src/lib/kernel/bitmap.c 2004-11-03 14:35:22.000000000 -0800
14 #include "threads/malloc.h"
15 @@ -212,14 +213,25 @@ size_t
16 bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value)
22 ASSERT (start <= b->bit_cnt);
24 for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
25 if (!contains (b, idx, idx + cnt, !value))
28 + return BITMAP_ERROR;
31 + m = random_ulong () % n;
33 + for (idx = start, last = b->bit_cnt - cnt; idx <= last; idx++)
34 + if (!contains (b, idx, idx + cnt, !value) && m-- == 0)
36 - return BITMAP_ERROR;
41 /* Finds the first group of CNT consecutive bits in B at or after