Bit operation Set_bit In-Place graphs, set a bit in an atom Void set_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is an atomic operation. If no atomic operation is required, the _ set_bit function is called. The NR can be any large, and the bitmap size is not limited to one word. _ Set_bit Set a bit in the in-place Graph Void _ set_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. Clear_bit Clear a bit in a bitmap Void clear_bit (int nr, volatile void * ADDR) Nr is the bit to be cleared, and ADDR is the starting address of the bitmap. This function is an atomic operation, but does not have the locking function. To use this function for locking, you should call the smp_mb _ before_clear_bit or smp_mb _ after_clear_bit function, to ensure that any changes are visible on other processors. _ Change_bit Change a position in the in-place Graph Void _ change_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. Unlike change_bit, this function is non-atomic. Change_bit Change a position in the in-place Graph Void change_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. Test_and_set_bit Set a certain bit and return the original value of this bit Int test_and_set_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is an atomic operation. _ Test_and_set_bit Set a certain bit and return the original value of this bit Int _ test_and_set_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is a non-atomic operation. If two instances of this operation compete, one is successful but the other fails. Therefore, one lock should be used to protect multiple accesses to a certain bit. Test_and_clear_bit Clears a digit and returns the original value. Int test_and_clear_bit (int nr, volatile void * ADDR ); Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is an atomic operation.
_ Test_and_clear_bit Clears a digit and returns the original value. Int _ test_and_clear_bit (int nr, volatile void * ADDR ); Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is not atomic.
Test_and_change_bit Change a bit and return the new value of this bit. Int test_and_change_bit (int nr, volatile void * ADDR) Nr is the bit to be set, and ADDR is the starting address of the bitmap. This function is an atomic operation. Test_bit Determine whether a user is set Int test_bit (int nr, const volatile void * ADDR) Nr is the number of bits to be tested, and ADDR is the starting address of the bitmap. Find_first_zero_bit In the memory area, find the first bit with a value of 0. Int find_first_zero_bit (void * ADDR, unsigned size) ADDR is the starting address of the memory zone, and size is the maximum length to be searched. Returns the bid 0 for the first bit. Find_next_zero_bit In the memory area, find the first bit with a value of 0. Int find_next_zero_bit (void * ADDR, int size, int offset) ADDR is the starting address of the memory area, size is the maximum length to be searched, and offset is the start bit number to start searching. Ffz Search for the first 0 in the word Unsigned long ffz (unsigned long word ); Word is the word to be searched. FFS Find the first bit that has been set Int FFs (int x) X indicates the word to be searched. This function is defined in the same way as in libc.
Hweight32 Returns the weighted equilibrium value of n characters. Hweight32 (X) X indicates the word to be weighted. The weighted balance of a number is the sum of all bits of this number. |