Hi Tim, On Sun, May 12, 2002 at 12:24:57PM +0200, Tim Goetze wrote: > nevertheless, i went looking at the other archs and very much to my > surprise found corresponding code for ppc and sparc for example. to > my surprise because i assume it to be unused, otherwise there'd be an > implementation for every arch. i'm still thinking whether relying on > this unused code is a good idea. It looks safe in some cases. Most of them just implemented it, because it is possible and not included in the actual kernel code if never called (because it's inline ;-)). Some of these generalized the atomic inc/dec and test with them.
> can you specify which architectures use privileged instructions for > this purpose? Architectures, which use cli/sti to implement it. This is almost always an privileged instruction, so no user can stall interrupt processing of the kernel on sane architectures. arm and cris come to mind. > even if you make mutices faster, trying to acquire one while it's > being held by another thread must block (it would not be a mutex if > it did not for all i know). that's exactly what i'm trying to avoid. Use trylock and spin for a while to simulate "spinlocks" and avoid the schedule. But atomic operations are always better, that's where we agree. My basic hint was "look how the kernel does it, because there it's done right" ;-) Regards Ingo Oeser -- Science is what we can tell a computer. Art is everything else. --- D.E.Knuth