atomicity - .net System.MemberwiseClone and interlocked writes -
when performing memberwiseclone of array of value types:
var arr = new double[100];
if these doubles being modified using interlocked write on other threads, memberwisecloned copy @ risk of having torn doubles in it? i'm not concerned having stale values, tearing , interaction between interlocked , memberwiseclone (which guess translates memory blit type operation?)
yes. on 32bit operating systems guaranteed have risk of tearing. on 64bit implementation defined. wouldn't lightly risk because if test doesn't happen test on particular .net version , on particular hardware. you can't make sure.
on 64bit can reliably prevent tearing implementing own version of clone (which not slower).
Comments
Post a Comment