From owner-freebsd-questions Fri Jan 14 10:34:44 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mx2.x-treme.gr (mx2.x-treme.gr [212.120.192.15]) by hub.freebsd.org (Postfix) with ESMTP id B818615B66 for ; Fri, 14 Jan 2000 10:21:28 -0800 (PST) (envelope-from keramida@diogenis.ceid.upatras.gr) Received: from hades.hell.gr (pat53.x-treme.gr [212.120.197.245]) by mx2.x-treme.gr (8.9.3/8.9.3/IPNG-ADV-ANTISPAM-0.1) with ESMTP id UAA17856; Fri, 14 Jan 2000 20:21:12 +0200 Received: (from charon@localhost) by hades.hell.gr (8.9.3/8.9.3) id TAA43061; Fri, 14 Jan 2000 19:40:13 +0200 (EET) (envelope-from keramida@diogenis.ceid.upatras.gr) Date: Fri, 14 Jan 2000 19:40:12 +0200 From: Giorgos Keramidas To: Mikhail Evstiounin Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Volatile variables Message-ID: <20000114194012.B31079@hades.hell.gr> Reply-To: keramida@ceid.upatras.gr References: <010701bf5e3b$a6dac5e0$a9353018@evstiouninadelphia.net.pit.adelphia.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: <010701bf5e3b$a6dac5e0$a9353018@evstiouninadelphia.net.pit.adelphia.net> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Jan 13, 2000 at 10:01:27PM -0500, Mikhail Evstiounin wrote: > > > When I tried this a few seconds ago it gave: > > > > % cat hello.c > > volatile int k; > > Could you try to use atomic instead of int - I don't have FreeBSD > under my hand and just want to see a generated code. Actually, in /usr/include/machine/signal.h of FreeBSD 3.4-STABLE, the definition of sig_atomic_t is `int', as in: typedef int sig_atomic_t; I did try to change `volatile int k' to `volatile sig_atomic_t k' and the generated code did not have any difference from before. The same sequence of `movl $0,k ; movl $1,k' statements was produced. Since in FreeBSD, the sizeof(int) returns 4, and the system runs on a machine with 32-bits, the size of a word is apparently the largest value that can be atomically set from the underlying hardware. Ciao. -- Giorgos Keramidas, < keramida @ ceid . upatras . gr > "What we have to learn to do, we learn by doing." [Aristotle] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message