[Info-vax] yet another sys$qiow question

Craig A. Berry craigberry at nospam.mac.com
Thu Aug 20 10:42:23 EDT 2015


On 8/20/15 7:48 AM, Simon Clubley wrote:
> On 2015-08-20, Craig A. Berry <craigberry at nospam.mac.com> wrote:
>> On 8/19/15 8:17 AM, Simon Clubley wrote:
>>
>>> Although I don't write empty loops for non-volatile variables, gcc can
>>> (silently) optimise out other chunks of code that it thinks will never
>>> be reached or is otherwise redundant so I would have to consider the
>>> possibility that LLVM will do the same as well and that in some
>>> circumstances it might do it with empty non-volatile while loops as well.
>>
>> Since the current Ada on VMS is based on gcc, how can it do concurrency
>> if gcc can't? Does it generate lots of volatile statements or just
>> disable optimizations?
>
> I was talking about optimisations performed at compile time based on the
> structure of the code.
>
> Example 1:
>
> 	while(1)
> 		{
> 		{whatever}
> 		}
>
> 	while(1)
> 		{
> 		{another bunch of whatever}
> 		}
>
> Example 2:
>
> 	{some code}
> 	while(i == 0)	/* i is _not_ volatile */
> 		{	/* This is an empty loop */
> 		}
> 	{some more code}
>
> In example 1, I've seen gcc remove the code for the second while loop
> completely because it will never be reached. (I sometimes use this
> construct during debugging by adding the first while loop in front of
> the real while loop to dump some registers and to stop the real while
> loop from executing).
>
> I've never written code in the style of example 2, at least when using
> _non-volatile_ variables, but I can see an aggressive optimiser
> (especially when it's been told to optimise for size) actually removing
> that while loop when only non-volatile variables are involved.
>
> Example 2 could cause a poorly written program to break if it was
> busy-waiting on a non-volatile IOSB block.

I think the emphasis here should be on "poorly written program"; I
certainly don't see any examples of what you're talking about in
SYS$EXAMPLES and I don't see how anyone using the documented methods for
making sure the I/O is complete before checking the IOSB would get into
this kind of trouble.




More information about the Info-vax mailing list