Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

is pointer assignment always atomic?

Name: Anonymous 2012-03-01 3:17

Is pointer assignment always atomic?

Will this always work:


struct list {
  int n;
  struct list* next;
};

struct stack {
  struct list* top;
};

thread one does:
for(;;) {
  print_list(stack->top);
  // read after write race condition for stack->top.
}

thread two does:
for(int count = 0; true; count++) {
  stack->top = new_int_list(count, stack->top);
}


Will the assignments and reads to stack->top always be atomic? Will the pointer value ever be half written or something, on some architecture?

Name: Anonymous 2012-03-03 16:44

>>18
true. It would probably be better to have explicit lock free data structure implementations for each supported platform (the differences probably wouldn't be very severe) and then provide a mutex using data structure, which could possibly use a very different approach than the lock free ones.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List