lkml.org 
[lkml]   [1999]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectxchg() vs test_and_set_bit()
Hi

A lot of drivers use {test_and_set,test,clear}_bit() to control access
to critical code sequences since these operations are guaranteed to be
atomic, ie. dev->tbusy is a classic example in the network drivers.

However, one could achieve the same effect by using xchg(), and looking
at the code sequences on the x86 and Alpha it actually looks shorter. Of
course I asume the atomicity of the instruction is the big issue, but
why not save a word in an instruction cache line if one can? ;-)
Besides, I can imagine that bitops are likely to be much more complex on
some architectures, there must be some that don't have bitops operating
directly on memory.

Jes

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.020 / U:2.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site