group/pintos/src/lib/kernel/bitmap.c
/* 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. */
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.
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 .
size_t
bitmap_scan (const struct bitmap *b, size_t start, size_t cnt, bool value)
{
  ASSERT (b != NULL);
  ASSERT (start <= b->bit_cnt);
  if (cnt <= b->bit_cnt)
    {
      size_t last = b->bit_cnt - cnt;
      size_t i;
      for (i = start; i <= last; i++)
        if (!bitmap_contains (b, i, cnt, !value))
          return i;
    }
  return BITMAP_ERROR;
}
size_t bitmap_scan ( const struct bitmap * b , size_t start , size_t cnt , bool value ) { ASSERT ( b != NULL ) ; ASSERT ( start <= b -> bit_cnt ) ; if ( cnt <= b -> bit_cnt ) { size_t last = b -> bit_cnt - cnt ; size_t i ; for ( i = start ; i <= last ; i ++ ) if ( ! bitmap_contains ( b , i , cnt , ! value ) ) return i ; } return BITMAP_ERROR ; }
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.
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 .