Content-Length: 12055 | pFad | http://lwn.net/Articles/71732/

No more 24-bit atomic_t [LWN.net]
|
|
Subscribe / Log in / New account

No more 24-bit atomic_t

The atomic_t type in the Linux kernel is a simple integer variable with a set of operations which are guaranteed to be atomic without the need for explicit locking. For years, atomic_t variables have operated under the constraint that they can be expected to hold no more than 24 bits; this limitation was forced by the Sparc32 architecture, which used the other eight bits to implement the atomic operations.

As of 2.6.3, this limitation no longer holds. This patch by Keith M Wesolowski has changed the Sparc32 implementation to a version (taken from the PA-RISC architecture) which provides full 32-bit atomic variables.

The new implementation works by creating a small array (four entries) of spinlocks. When an operation is to be performed on an atomic variable, one of those spinlocks is chosen by a hash function; the code holds the given lock while manipulating the variable. The result is proper locking for atomic operations without doubling the size of every atomic_t in the system. The patch was quickly picked up and merged, and kernel programmers have one less strange limitation to worry about.
Index entries for this article
Kernelatomic_t


to post comments

No more 24-bit atomic_t

Posted Feb 19, 2004 21:32 UTC (Thu) by xorbe (guest, #3165) [Link] (2 responses)

"a small array (four entries) of spinlocks"
4 spinlocks for the entire system's atomic variables?
Helloooooooooo deadlock!

No more 24-bit atomic_t

Posted Feb 20, 2004 20:39 UTC (Fri) by ptr (guest, #5885) [Link] (1 responses)

Well, without digging deep, there should not be any (additional) dead locks, since always only up to one of the four locks is used per thread... Additionally, the atomicity dead lock is always the last. If the locking order was robust before, it will be after the change.

No more 24-bit atomic_t

Posted Feb 21, 2004 4:09 UTC (Sat) by jzbiciak (guest, #5246) [Link]

Spinlocks disable preemption, right?


Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://lwn.net/Articles/71732/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy