tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 64-bit masks

On Fri, Nov 27, 2009 at 02:41:30PM +0000, Mindaugas Rasiukevicius wrote:
> > 2. I have an array of 64 objects that I need to keep track of. I keep  
> > their state (i.e. busy/free) in a 64-bit mask, 1 for busy, 0 for free.
> > 
> > unit64_t state;
> How about uint32_t state[2]; ?  To mark/unmark bit, it would be a matter
> of shifting and masking.  In a case you would want to use ffs()/ffs32(),
> popcount(), atomic operations or similar routines - it might be better.

If only 64bit platforms are desirable (in the sense of 64bit pointers),
than using uint64_t is normally better. On 32bit platforms it might be
more efficient to split into two 32bit words. It might be required to be
able to use atomic ops as well.


Home | Main Index | Thread Index | Old Index