From owner-freebsd-current Wed Jan 17 8:40:39 2001 Delivered-To: freebsd-current@freebsd.org Received: from moby.geekhouse.net (moby.geekhouse.net [64.81.6.36]) by hub.freebsd.org (Postfix) with ESMTP id 1BE5C37B6A1 for ; Wed, 17 Jan 2001 08:40:16 -0800 (PST) Received: from laptop.baldwin.cx (john@dhcp150.geekhouse.net [192.168.1.150]) by moby.geekhouse.net (8.11.0/8.9.3) with ESMTP id f0HGi8s65704; Wed, 17 Jan 2001 08:44:08 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200101171543.KAA18055@khavrinen.lcs.mit.edu> Date: Wed, 17 Jan 2001 08:40:10 -0800 (PST) From: John Baldwin To: Garrett Wollman Subject: Re: Atomic breakage? Cc: current@FreeBSD.org, Peter Jeremy Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 17-Jan-01 Garrett Wollman wrote: > < said: > >> To support multiple masters, you need proper locks. > > On older processors, yes. On processors with the CX8 feature bit set, > you can do it without any sort of locking (indeed, this is a primitive > that semaphores can be built upon). Consider the following: > > atomic_increment: > ; prologue > ; get EA into %esi > movl (%esi), %eax > movl 4(%esi), %edx > 1: movl %eax, %ebx > movl %edx, %ecx > incl %ebx > adcl $0, %ecx > cmpxchg8b (%esi) ; generates a locked bus cycle > jne 1 > ; epilogue > > On pre-Pentium processors (which lack the CX8 feature) this sort of > sequence is impossible. OTOH, I don't think SMP works on any > pre-Pentium processor, so again this degenerates to: > > pushfl > cli > incl (%esi) > adcl $0, 4(%esi) > popfl > > ...in the non-SMP case. Early Pentiums (<= P90) don't support CX8 or so I've heard, which make this slightly more complicated, as for a pentium we would have to use a function pointer that we setup during probe. Also, during a SMP boot we would have to panic if CX8 wasn't enabled on all CPU's. > -GAWollman -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message