[comp.lang.c] Volatile global variable

harbis@b8.ingr.com (Randy Harbison) (03/22/91)

I have a program that runs interactively with a remote host through a
TTY rs-232 device.  The program uses getc() to capture information flow.
When the remote machine dies or just locks up, so does my program. 

I would like to know if/how to have a variable that can be altered apart
from the normal execution routines of the code.
	Example: A pointer which is pointing to the address of the
		 system clock.  This variable would change in relation to
		 the clock in runtime.  (I am specifically interested
		 in the variable incrementing as the seconds increase).

Questions:
	1. What TYPE would the variable be?

	2. How would I find the address of the clock (seconds)?

	3. How would I assign the variable to the clock's address?

	4. If I'm way out in left field, what would be the reasonable options?

torek@elf.ee.lbl.gov (Chris Torek) (03/22/91)

In article <1991Mar21.160849.1520@b8.ingr.com> harbis@b8.ingr.com
(Randy Harbison) writes:
>	Example: A pointer which is pointing to the address of the
>		 system clock.  This variable would change in relation to
>		 the clock in runtime.  (I am specifically interested
>		 in the variable incrementing as the seconds increase).
>	1. What TYPE would the variable be?
>	2. How would I find the address of the clock (seconds)?
>	3. How would I assign the variable to the clock's address?
>	4. If I'm way out in left field, what would be the reasonable options?

Well, you are definitely way out in machine-dependent territory (though us
southpaws think `left field' is normal :-) ).  Questions 1 through 3
*require* machine details in order to be answered.  You have given none,
and comp.lang.c is not the proper newsgroup for them anyway, so what
you need to do is decide which machine(s) you need answers for and
find appropriate machine-specific newsgroups.

ANSI C provides the `volatile' qualifier specifically as an escape hatch
to do this sort of thing, but (of necessity) does not pin down exactly
what `volatile' does.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov