Name: Anonymous 2012-03-01 3:17
Is pointer assignment always atomic?
Will this always work:
Will the assignments and reads to stack->top always be atomic? Will the pointer value ever be half written or something, on some architecture?
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?