David Howells wrote:
Nick Piggin <[email protected]> wrote:(2) Those that have CMPXCHG or equivalent: 68020, i486+, x86_64, ia64, sparc. (3) Those that have LL/SC or equivalent: mips (some), alpha, powerpc, arm6.cmpxchg is basically exactly equivalent to a store-conditional, so 2 and 3 are the same level.No, they're not. LL/SC is more flexible than CMPXCHG because under some circumstances, you can get away without doing the SC, and because sometimes you can do one LL/SC in lieu of two CMPXCHG's because LL/SC allows you to retrieve the value, consider it and then modify it if you want to. With CMPXCHG you have to anticipate, and so you're more likely to get it wrong.
I don't think that is more flexible, just different. For example with cmpxchg you may not have to do the explicit load if you anticipate an unlocked mutex as the fastpath. My point is that they are of semantically equal strength.
I don't know why you don't implement a "good" default implementation with atomic_cmpxchg.Because it wouldn't be a good default.
You were proposing a worse default, which is the reason I suggested it.
I'm thinking the best default is simply to wrap a counting semaphore.
Probably.Send instant messages to your online friends http://au.messenger.yahoo.com -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Nikita Danilov <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Russell King <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- References:
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Nick Piggin <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Arjan van de Ven <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: "Christopher Friesen" <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Arjan van de Ven <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Arjan van de Ven <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Alan Cox <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: Andrew Morton <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- From: David Howells <[email protected]>
- Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Prev by Date: raid over sata - write barrier
- Next by Date: Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- Previous by thread: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Next by thread: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
- Index(es):