Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Sep 1996 16:50:49 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, tweten@frihet.com
Cc:        current@freebsd.org
Subject:   Re: fixing accesses to volatile variable `time'
Message-ID:  <199609060650.QAA22321@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>1. time.tv_sec is long, and accesses to longs are not guaranteed to 
>>   be atomic.  They happen to be atomic on i386's.
>
>To satisfy my curiosity, just who makes this "guarantee?"  Obviously, 

No one.  Accesses to ints and shorter types are just more likely to be
atomic because ints are supposed to be natural and efficient.

>access to a bit is inherently atomic, but I don't recall reading any C 
>language specification indicating that chars, shorts, or int accesses are 
>atomic whereas longs aren't.

The C standard only guarantees that accesses to sig_atomic_t's are atomic
(except in signal handlers, only write access is guaranteed - reading of
any non-local variable gives undefined behaviour!).

Bruce



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