Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2000 19:40:12 +0200
From:      Giorgos Keramidas <charon@hades.hell.gr>
To:        Mikhail Evstiounin <evstiounin@adelphia.net>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Volatile variables
Message-ID:  <20000114194012.B31079@hades.hell.gr>
In-Reply-To: <010701bf5e3b$a6dac5e0$a9353018@evstiouninadelphia.net.pit.adelphia.net>
References:  <010701bf5e3b$a6dac5e0$a9353018@evstiouninadelphia.net.pit.adelphia.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000114194012.B31079>