Re: using volatile ptrs ...

From: Michael Wojcik (mwojcik_at_newsguy.com)
Date: 11/11/04


Date: 11 Nov 2004 20:05:05 GMT


In article <623b574.0411101316.7886031f@posting.google.com>, lbj137@yahoo.com (LBJ) writes:
> lets say i have the following definition:
>
> volatile char* p = 0x0a0a0a;

Let's assume that you have the necessary cast as well.

> lets say p now points directly to cacheable memory, and lets also
> say that this memory is currently cached. when p is accessed, will the
> cache be hit, or will the program actually go out to DRAM (due to the
> volatile qualifier)?

Neither. Your program will stop with a program check condition, and
a message will be sent to the user message queue (or job message
queue, if it's running in a non-interactive subsystem) noting the
error. If the message queue is in auto-answer mode, the program will
be cancelled and its spool file will contain a description of the
failure; otherwise, it will wait for a reply to the message. Typically
you will have the option of cancelling the program, debugging it, or
ignoring the program check - but in the last case you'll simply get
an immediate machine check which will only let you cancel the
program, IIRC.

Of course I'm assuming that you're using one of the conforming C
implementations for OS/400 V3R7, as is often[1] the case. Other
implementations may behave differently.

In OS/400 V3, and in later versions of OS/400 except for certain
special cases,[2] the implementation always produces a trap repre-
sentation when converting from an integer to a pointer. That's a
specific, real-world example of a conforming C implementation where
you cannot cast an integer to a pointer and successfully dereference
the latter.

As for your question regarding the "volatile" qualifier: the C
standard actually makes very few guarantees about volatile, and its
behavior is almost entirely a Quality of Implementation issue. So
you'll have to ask whoever wrote your compiler.

[1] Under certain other assumptions we need not go into here.

[2] The exceptions are the Licensed Internal Code, which forms the
lowest level of the OS; and the PASE environment, which was created
to support ill-behaved C programs. PASE gives the executing program
a one-TB memory object as its "address space", in which it is free
to muck about as it likes.

-- 
Michael Wojcik                  michael.wojcik@microfocus.com
"Well, we're not getting a girl," said Marilla, as if poisoning wells were
a purely feminine accomplishment and not to be dreaded in the case of a boy.
 -- L. M. Montgomery,  _Anne of Green Gables_


Relevant Pages

  • Re: msgQReceive() Parameters
    ... I don't use VxWorks anymore, and don't have access to the manual to ... Consider the following attributes of a message queue. ... it must mallocmemory for the entire queue. ... Sending the pointer only works if the receiver is operating in the ...
    (comp.os.vxworks)
  • Re: UDP concept help please
    ... > watched the port and stuffed each UDP message into a message queue. ... I'd use shared memory to communicate the packets between the udp ...
    (comp.unix.programmer)
  • Re: Creating Modeless Dialogs continually causing application to grow
    ... Adding the timer to give the main application a moment of rest seems to remove the modelss dialog memory growth. ... MFC's definition of "idle time" is checking the message queue and finding no messages to dispatch. ... So if you are keeping the message queue continually busy, or the processor continually busy, the temporary objects will tend to build up, awaiting idle time. ...
    (microsoft.public.vc.mfc)
  • Re: RIP Charlton Heston
    ... do with facts, other than the fact that Charlton Heston decided that ... If memory serves simply cancelling was not an option for them. ... organization itself being on the hook for the convention facility and so on, ...
    (rec.music.gdead)
  • Is there a way to ...
    ... I need to restrict the ... new process can not access IPC resource (message queue, share memory, etc.), ...
    (comp.unix.programmer)