From owner-freebsd-alpha@FreeBSD.ORG Thu Aug 7 12:15:52 2003 Return-Path: Delivered-To: freebsd-alpha@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D538A37B401; Thu, 7 Aug 2003 12:15:52 -0700 (PDT) Received: from zmamail04.zma.compaq.com (mailout.zma.compaq.com [161.114.64.104]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0C72643F3F; Thu, 7 Aug 2003 12:15:52 -0700 (PDT) (envelope-from peter.portante@hp.com) Received: from tayexg11.americas.cpqcorp.net (tayexg11.americas.cpqcorp.net [16.103.130.96]) by zmamail04.zma.compaq.com (Postfix) with ESMTP id 6B21C7C30; Thu, 7 Aug 2003 15:15:51 -0400 (EDT) Received: from tayexc17.americas.cpqcorp.net ([16.103.130.15]) by tayexg11.americas.cpqcorp.net with Microsoft SMTPSVC(5.0.2195.6673); Thu, 7 Aug 2003 15:15:50 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Thu, 7 Aug 2003 15:15:49 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Atomic swap Thread-Index: AcNdFuXivOgvVZlLTO+gkyfdPCLCkAAACCLEAABEQMU= From: "Portante, Peter" To: X-OriginalArrivalTime: 07 Aug 2003 19:15:50.0389 (UTC) FILETIME=[50465250:01C35D18] cc: alpha@freebsd.org cc: Marcel Moolenaar Subject: RE: Atomic swap X-BeenThere: freebsd-alpha@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Alpha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2003 19:15:53 -0000 > > > static __inline void > > > atomic_swap_long(volatile long *dst, long val, long *res) > > > { > > > __asm ( "1: ldq_l t0,%0\n" > > > " mov %1,t1\n" > >=20 > > If I swap the first 2 instructions: > >=20 > > __asm ( "1: mov %1,t1\n" > > ldq_l t0,%0\n" > >=20 > > that eliminates 1 instruction from between the locked > > instructions. Is there anything wrong with doing that? > >=20 > Actually, the processor has a chance to do something while waiting for = memory, so it does not hurt to have the mov inside the ldq_l/stq_c pair. >=20 And you should also consider that when the code loops, you want to issue = the memory operation as soon as possible, which means performing the mov = after the ldq_l. -Peter