From owner-freebsd-current Tue Mar 11 08:53:11 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id IAA18667 for current-outgoing; Tue, 11 Mar 1997 08:53:11 -0800 (PST) Received: from nic.follonett.no (nic.follonett.no [194.198.43.10]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA18634 for ; Tue, 11 Mar 1997 08:52:57 -0800 (PST) Received: (from uucp@localhost) by nic.follonett.no (8.8.5/8.8.3) with UUCP id RAA24987; Tue, 11 Mar 1997 17:50:13 +0100 (MET) Received: from oo7 (oo7.dimaga.com [192.0.0.65]) by dimaga.com (8.7.5/8.7.2) with SMTP id RAA25181; Tue, 11 Mar 1997 17:55:43 +0100 (MET) Message-Id: <3.0.32.19970311175431.00bf5900@dimaga.com> X-Sender: eivind@dimaga.com X-Mailer: Windows Eudora Pro Version 3.0 (32) Date: Tue, 11 Mar 1997 17:54:32 +0100 To: brian@utell.co.uk From: Eivind Eklund Subject: Re: ppp Cc: Bruce Evans , ache@nagual.ru, brian@awfulhak.demon.co.uk, brian@utell.co.uk, current@FreeBSD.ORG Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk At 03:44 PM 3/11/97 +0000, Brian Somers wrote: >&= ~ isn't guaranteed atomic ? Yeuch. I'd tend to go with Andrey's >suggestion that I use an int array rather than a bit array. I assume >that ++ and -- are guaranteed to be atomic (if they're not, I'm in *lots* >of trouble). You're in lots of trouble. The only operation even _likely_ to be atomic is storing a word. Remember, most RISC processors can't operate on values not in registrers - thus, they need a load, an operation and a store. To give examples close to what you were asking about: /* Pseudo-C syntax. Used on some DSPs. NOTE: All = operations must have a non-dereferenced register on at least one side of the operator; all operations more complex than = must have registers on both sides (&=, +=, etc). Only the x= and = operators are allowed; certain if-goto's can also be used. */ /* var &= 0x800; */ r0 = &var; /* Variable to operate on. */ r1 = 0x800; /* Immediate value */ r2 = *r0; /* Fetch contents of variable */ r2 &= r1; /* Do operation */ *r0 = r2; /* Store result */ /* var++ */ r0 = &var; r1 = 1; r2 = *r0; r2 += r1; *r0 = r2; Of course, this is close to as nasty as they come. Most processors will let you add/and immediate values directly to registers. But they are not all, and they still don't become any more atomic than the above. Besides, even a store is not guaranteed to be atomic - a friend of mine told of a guy he studied with who had made a computer with a single instruction (add and skip if zero), clocked it at a couple of gigaherz, and proved it to be Turing complete. This could be your next port ;-) Eivind Eklund perhaps@yes.no http://maybe.yes.no/perhaps/ eivind@freebsd.org