From owner-freebsd-current Wed Jan 17 7:43:49 2001 Delivered-To: freebsd-current@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 36A9E37B404 for ; Wed, 17 Jan 2001 07:43:30 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id KAA18055; Wed, 17 Jan 2001 10:43:10 -0500 (EST) (envelope-from wollman) Date: Wed, 17 Jan 2001 10:43:10 -0500 (EST) From: Garrett Wollman Message-Id: <200101171543.KAA18055@khavrinen.lcs.mit.edu> To: Peter Jeremy Cc: current@FreeBSD.ORG Subject: Re: Atomic breakage? In-Reply-To: <20010117142654.A98607@gsmx07.alcatel.com.au> References: <3A64AA23.30035A1C@elischer.org> <20010116191009.E7240@fw.wintelcom.net> <20010117142654.A98607@gsmx07.alcatel.com.au> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG < 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. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message