Messages in this thread | | | From | (Alan Cox) | Subject | Re: Is this the right list? | Date | Mon, 7 Dec 1998 21:51:56 +0000 (GMT) |
| |
> synchronization mechanisms I am using. When is it safe and not safe to > use the start_bh_atomic() and end_bh_atomic() calls to try to guarantee
A bottom half handler (where is already implicit as bh's are currently atomic w.r.t each other and themselves), and user space where it will prevent a BH from executing during the marked section (and on SMP in 2.1.x wait for a BH to complete - since a BH could be running on another CPU in parallel in 2.1.x but not 2.0.x).
> I roll my own? Also, when I look at the defs for the > start/end_bh_atomic() calls, they reference a function called barrier() > that is #defined as: > > #define barrier() __asm__("": : :"memory")
The instruction is "" (ie nothing) and the "memory" is the thing it affects - so barrier is a null instruction that arbitarily affects memory space.
Its used to persuade gcc to write back and invalidate any register temporary variables
Without it something like
start_bh_atomic(); x=list->head; list->head=list->head->next; end_bh_atomic();
might be re-ordered by the compiler either so the x=list->head moves before the beginning of the atomic area or the list->head= is moved past the end. Its a better alternative than using volatile in most cases
Alan
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |