From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 14 23:29:38 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF25E16A4CE for ; Sat, 14 Feb 2004 23:29:38 -0800 (PST) Received: from siue.dnsalias.net (student143-123.bh.siue.edu [146.163.143.123]) by mx1.FreeBSD.org (Postfix) with ESMTP id C89F543D1D for ; Sat, 14 Feb 2004 23:29:38 -0800 (PST) (envelope-from wgrim@siue.edu) Received: from siue.edu (unknown [192.168.0.98]) by siue.dnsalias.net (Postfix) with ESMTP id 24ACA233D1C; Sun, 15 Feb 2004 01:29:32 -0600 (CST) Message-ID: <402F1FDB.8020907@siue.edu> Date: Sun, 15 Feb 2004 01:29:31 -0600 From: "William M. Grim" Organization: SIUE User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3 X-Accept-Language: en MIME-Version: 1.0 To: eirikn@kerneled.com References: <20040214092308.GA15818@eirikn.net> In-Reply-To: <20040214092308.GA15818@eirikn.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: machine/atmoic.h X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2004 07:29:39 -0000 Atomic functions often serve purposes in mutexes and SMP. You want to be able to lock a mutex in one cycle (at least few enough cycles guaranteed to be executed before another process is scheduled). If you try to lock a mutex without using atomic functions, then two processes might try to lock a mutex at the same time and both get stuck in a deadlock. This would sorta suck. Eirik Nygaard wrote: >Hi... > >I am just wondering what the atomic_* functions in machine/atmoic.h does. >I have read the assembly code and more or less understood it, but I still >don't see the need for it. So if anyone would enlighten me that would be >great. > > > > -- William Michael Grim Student, Southern Illinois University at Edwardsville Unix Network Administrator, SIUE, Computer Science dept. Phone: (217) 341-6552 Email: wgrim@siue.edu