Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Mon, 3 Jun 2002 14:43:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Mon, 3 Jun 2002 14:43:35 -0400 Received: from neon-gw-l3.transmeta.com ([63.209.4.196]:48656 "EHLO neon-gw.transmeta.com") by vger.kernel.org with ESMTP id ; Mon, 3 Jun 2002 14:43:33 -0400 To: linux-kernel@vger.kernel.org From: "H. Peter Anvin" Subject: Re: Atomic operations Date: 3 Jun 2002 11:43:07 -0700 Organization: Transmeta Corporation, Santa Clara CA Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Disclaimer: Not speaking for Transmeta in any way, shape, or form. Copyright: Copyright 2002 H. Peter Anvin - All Rights Reserved Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Followup to: By author: Gregory Giguashvili In newsgroup: linux.dev.kernel > > Could you, please, clarify what you meant saying that there was no way of > doing so. I admit, I'm no expert in i386 assembly, but this operation seems > so simple to me... > That doesn't mean the hardware is going to provide it atomically. > > Could you, please, suggest some other implementation (with waiting and > trying again - whatever this means)? > Very simple: - Set a spinlock (note: you need a spinlock variable) - Read - Add - Clear spinlock This is called "bootstrapping" -- using a more primitive atomic operation to get what you need. -hpa -- at work, in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/