bitops or mutex

Prashant Shah pshah.mumbai at gmail.com
Mon Jan 21 08:46:47 EST 2013


Hi,

There is a bitmap that needs to be locked across many threads for test
/ set bit operations. Which one is faster - bitops or mutex ?

1. Bitops :
set_bit(5, (long unsigned *)&tmp);

2. Mutex :
mutex_lock(&m);
*tmp = (*tmp) | (1 << 5);
mutex_unlock(&m);

Regards.



More information about the Kernelnewbies mailing list