[Cfp-interest 2772] Re: CFP review of NB comments on CD2 - 20230602

Fred J. Tydeman tydeman at tybor.com
Tue Jun 6 15:22:35 PDT 2023


On Tue, 6 Jun 2023 11:35:26 -0700 Hans Boehm wrote:
>
>>  Could you give a specific example illustrating your concern? I'm
>currently confused.

Perhaps:

#define LOCK(S) while( ++S != 1){ --S ; }
#define UNLOCK(S) --S;

static _Atomic int state = 0;
static _Atomic int done = 0;
static double d = 0.0;

int main( void ){
.... start 2nd thread ...
.... this is 1st thread ...
  LOCK(state);
  done = 1;
  d /= 0.0;     /* without function call, this can be delayed after UNLOCK */
  UNLOCK(state);
...
    }

... 2nd thread ...
  for(int div_done=0; 0==div_done;){
    LOCK(state);
    if( done != 0 ){
      div_done = 1;
    }
    UNLOCK(state);
  }
  d = 1.0;      /* if d /= 0.0; is delayed, this could be concurrent  */
                /* d could be 1.0 or NaN or unknown value */
  if( 1.0 != d ){
...



---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of INCITS/C (ANSI "C")
Sample C17+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list