Bitmap can be used as efficient data structure. Where each bit can be used as information.
Let’s say we have a large stock of items. We can use a long variable to represent status (used / unused) of all items. Each bit represents one item.
If bit is 0 -> item is free,
If bit is 1-> item is busy.
We can keep track count of used/unused item using variable.
We have bitwise operations, which can use to manipulate Bitmaps. Few bitwise operations are listed below:
void set_bit(int pos, volatile unsigned long * addr)
sets the bit at position pos ; counting begins at addr.
int test_bit(int pos , const volatile unsigned long * addr)
checks whether the specified bit is set.
void clear_bit(int pos, volatile unsigned long * addr)
Deletes the bit at position pos (counting begins at addr).
void change_bit(int pos, volatile unsigned long * addr)
Toggle the bit value at position pos (counting begins at addr); in other words, a set bit is unset and vice versa.