From: becker@super.org (Donald J. Becker) Subject: Re: .98.5 and .98.6: Infinite loop trying to init SMC Elite16 Date: Mon, 14 Dec 1992 02:19:08 GMT
In article <ADAMS.92Dec9171255@PDV2.pdv2.fmr.maschinenbau.th-darmstadt.de> adams@pdv2.fmr.maschinenbau.th-darmstadt.de (Adams) writes:
>>>I'd regard the code around we_rcv
>>> { struct wd_ring * ring;...; if (ring->status & 1)...}
>>>as at least "a little bit dangerous".
>> In this case the packet buffer shared memory was written before this
>> routine (a packet-received interrupt handler) was called, so there is no
>> possibility of the value changing in memory while you keep a copy in a
>> register.
>
>..But you have to force the C compiler to reevaluate
> (ring->status &1) on each invocation,
>indenpendent of any code around this expression.
>
>There is a chance the code just succeeds by luck, not by design.
But 'ring' is reassigned to a unknown (to the compiler) value each
time it goes through the loop -- the compiler is not allowed to assume
that 'ring->volatile' evaluates to the same value, it wouldn't even if
this were not "shared memory. In this case, a shared memory
8390-based ethernet card, the packet buffer you are interested in has
already been written and will not change until you move the 'boundary'
register forward -- which should only happen when you are finished
with that packet. In other words, 'ring->status' isn't polled to see
if the packet has been written which is the only case where 'volatile'
would be called for.
Donald Becker becker@super.org
Supercomputing Research Center
17100 Science Drive, Bowie MD 21114 301-805-7482
-- Donald Becker becker@super.org Supercomputing Research Center 17100 Science Drive, Bowie MD 21114 301-805-7482