🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #536

Re: observability

#536
From: Barry Margolin
Date: Thu, 07 Sep 1989 03:03
36 lines
1708 bytes
In article <1989Sep6.183349.2866@jarvis.csri.toronto.edu> flaps@dgp.toronto.edu (Alan J Rosenthal) writes:
>Many people claim that "volatile" is meaningless since it is not observable.

Here's a simple example where I think "volatile" is meaningful:

int global_variable;

handler() {
	global_variable = 2
}

main() {
	signal(SIGSOMETHING, handler);
	global_variable = 1;
	<expression that raises SIGSOMETHING>;
	printf("%d", global_variable);
}

I believe that it would be valid for an implementation to print either
1 or 2, because the lack of a "volatile" modifier permits
global_variable's value to be cached between the assignment and the
printf.  Adding a "volatile" modifier disallows this optimization, so
the program must print 2.

>bvs@light.uucp (Bakul Shah) writes:
>>Is a program with *no* output of any kind observable?

This reminds me of the old stories about an optimizing Fortran
compiler that was doing amazingly well on benchmarks because it
optimized away the entire program because it had no I/O statements.

Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar
Technical Details
Message-ID: <28946@news.Think.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!apple!oliveb!mintaka!think!barmar
References: <1237@gmdzi.UUCP> <10885@smoke.BRL.MIL> <242@ssp1.idca.tds.philips.nl> <10937@smoke.BRL.MIL> <1989Sep6.160709.4890@light.uucp> <1989Sep6.183349.2866@jarvis.csri.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!apple!oliveb!mintaka!think!barmar
From: barmar@think.COM (Barry Margolin)
Newsgroups: comp.std.c
Subject: Re: observability
Message-ID: <28946@news.Think.COM>
Date: 7 Sep 89 03:03:32 GMT
References: <1237@gmdzi.UUCP> <10885@smoke.BRL.MIL> <242@ssp1.idca.tds.philips.nl> <10937@smoke.BRL.MIL> <1989Sep6.160709.4890@light.uucp> <1989Sep6.183349.2866@jarvis.csri.toronto.edu>
Sender: news@Think.COM
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 36