From owner-freebsd-questions Wed May 12 12:47:27 1999 Delivered-To: freebsd-questions@freebsd.org Received: from resnet.uoregon.edu (resnet.uoregon.edu [128.223.144.32]) by hub.freebsd.org (Postfix) with ESMTP id 4861F153C4 for ; Wed, 12 May 1999 12:47:24 -0700 (PDT) (envelope-from dwhite@resnet.uoregon.edu) Received: from localhost (dwhite@localhost) by resnet.uoregon.edu (8.8.8/8.8.8) with ESMTP id MAA28020; Wed, 12 May 1999 12:47:22 -0700 (PDT) (envelope-from dwhite@resnet.uoregon.edu) Date: Wed, 12 May 1999 12:47:21 -0700 (PDT) From: Doug White To: Rahul Dhesi Cc: freebsd-questions@FreeBSD.ORG Subject: Re: looking for test-and-set or atomic swap instruction In-Reply-To: <199905062251.AA19855@bolero-x.rahul.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 6 May 1999, Rahul Dhesi wrote: > I am looking for a machine instruction that could be used to implement > mutual exclusion in software, similar to the traditional test-and-set or > atomic swap instructions, and some way of invoking it from within C code > from within FreeBSD 3.x. Any suggestions? More info below. > > I don't expect to be using a multiprocessing system, so perhaps that > should make things easier. > > I can't use any lock that requires a system call. I am making accesses > to common shared memory from multiple processes, and a system call would > be too costly. The rate of shared memory access will be high but > conflicts will be very rare, so a spin lock will do just fine. Pthreads? Doug White Internet: dwhite@resnet.uoregon.edu | FreeBSD: The Power to Serve http://gladstone.uoregon.edu/~dwhite | www.freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message