[Cpu-users] Failed to find free UID
Brought to you by:
matheny
|
From: Edwin L. <el...@fl...> - 2004-02-04 04:09:55
|
I tried to let cpu find the first available UID but it
returned one that is alredy used. After poking into
the code, I think there might be a problem with the
functions bitvector_{set,unset,get}.
The structure member bitvector_s->bits is (uint32_t *),
but those functions assume it to be (uint8_t *). So
the references BV_BITS(b)[chunk] is going by every 4
bytes instead of every byte.
The function bitvector_firstunset_find() does not have
this problem as it does
uint8_t *bits = (uint8_t *)BV_BITS(b);
and uses bits[i] instead of BV_BITS(b)[i].
Cheers,
e.
P.S. If the three functions were tested with a only
few UIDs (e.g., 1000, 1001 and 1002 in a 1000-2000
range), it will appear work in little endian machines,
but won't work on big endian machines. It can be
demonstrated in the silly program attached:
Irix MIPS:
BV_CHUNKSIZE_BYTES=4
BV_CHUNKSIZE=32
0
0
0
1
Linux i386:
BV_CHUNKSIZE_BYTES=4
BV_CHUNKSIZE=32
1
0
0
0
|