Re: A bit resistant to disruption
Stefan Ram a écrit :
> Francois Grieu <fgrieu@gmail.com> writes:
>
> Given:
>
>> extern int eRead(int j);
>> extern void eErase(int j);
>> extern void eProgram(int j);
>> void mySafeProgram(int j)
>
> Wanted:
>
>> the result given by any two undisrupted bRead() is the same
>> unless bToggle() was invoked in-between.
>
> So, what about the following implementation?
>
> int bRead( int const j )
> { int const value = eRead( j );
> if( value )mySafeProgram( j ); else eErase( j );
> return value; }
>
Assume bRead() just has returned 1.
A disruption occurs.
bRead() is called again.
A disruption occurs during that bRead(), while it is doing
mySafeProgram(), sometime during eErase() or eProgram(); say, in between
to simplify.
bRead() is called again without disruption, and returns 0.
Property a) is violated, regardless of how you implement bToggle, which
you did not specify BTW.
Francois Grieu
|