Read/Write Lock and Order
Avoiding Lock
- Atomic operations
- Memory barrier
1) Any atomic operation is defined to act as a memory barrier (ie. as per the mb() macro).
2) Spinlock operations act as partial barriers(as acquire/release pair)
Locking a collection of objects
Lock for the data structure containing the objects
Lock for the objects: the manipulation of the object can be out of that of data structure
new->next = i->next;
wmb();
i->next = new;
new->next = i->next;
i->next = new;