I have a bitmap
uint64_t bitmap[10000]
to keep track of the resources allocated in the system. Now the question is how do efficiently I
If you are using a 32 bit cpu then you do not want to do that. Rather use arrays of 32 bit ints. The loop over the array will be faster.
Also you can encode every value for 1 byte and then pre-store which is the first bit set in the byte. So when you find an integer that is not all 0xFFFFFFFF you can then simply compare the bytes. If the first byte is not 0xFF then it is in that byte and so on.
So if a byte is not 0xFF it means it is one of the 255 possible values for the byte. And each value has a first bit set.
Another way of looking at the problem is to divide it up into chunks if possible. I do not know what your resource is so I cannot say.
Also consider that on the previous scan for the unset bit that it looped forward. If you store the index of the previous result, then you can simply start from the same index on the next search. Call this index the pos and use it each time.
You can also create a small array of "free" indexes each time you set a bit to zero, so when your "pos" reaches the end of the array just start again from one of the saved indexes.
In other words you really do not want to be running such a long loop each time. That is your problem, not the final instruction to get the bit. Use the index tracking as outlined above and it will go hundreds of times faster.