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-01 13:01

OP, I'm fucking uneducated piece of shit. But at school they told me that reading/writing integers on x86 is atomic.

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