Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!mips!rogerk From: rogerk@mips.COM (Roger B.A. Klorese) Newsgroups: comp.arch Subject: Re: test and set facility Keywords: MIPS Message-ID: <29566@servitude.mips.COM> Date: 16 Oct 89 20:26:57 GMT References: <200@rangkom.MY> <29463@obiwan.mips.COM> <18381@pasteur.Berkeley.EDU> Reply-To: rogerk@mips.COM (Roger B.A. Klorese) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 29 In article <18381@pasteur.Berkeley.EDU> jas@postgres.berkeley.edu (Jim Shankland) writes: >How do you do atomic test-and-set on a uniprocessor MIPS >system, without atomicity being broken by preemption? In kernel mode, >presumably you can always disable interrupts, do the test, do the set, >and re-enable interrupts. But what about in user mode? It's awfully >handy if user processes sharing memory can do atomic t&s without a >kernel call .... In our current release, you don't (despite the following entry in our documentation, which was entered too early). But in our forthcoming release, you would use the sysmips(MIPS_ATOMIC_SET,...) system call: SYSMIPS(2-SysV) RISC/os Reference Manual SYSMIPS(2-SysV) When cmd is MIPS_ATOMIC_SET, two arguments are expected. The first argument should be the address of an int variable, and the second argument should be an int value. This com- mand atomically sets the variable to the value supplied and returns the old value of the variable. Note that if the old value of the variable may be -1, it is not possible to dis- tinguish that return from an error return, except by setting the errno variable to 0 before calling sysmips() and testing whether errno is non-zero on return. -- ROGER B.A. KLORESE MIPS Computer Systems, Inc. phone: +1 408 720-2939 928 E. Arques Ave. Sunnyvale, CA 94086 rogerk@mips.COM {ames,decwrl,pyramid}!mips!rogerk "I want to live where it's always Saturday." -- Guadalcanal Diary