Messages in this thread | | | Date | Thu, 6 Jan 2000 17:42:55 +0000 | From | Jamie Lokier <> | Subject | Re: (*(unsigned long *)&jiffies)++; |
| |
Andrea Arcangeli wrote: > >(*(unsigned long *)&jiffies)++; > > > >why not just jiffies++; ? It works fine with jiffies++ but I assume there > >is a reason... > > No reason. It won't make any difference. > > You could as well do jiffies++. jiffies is volatile so it can't be > reodered across other `;' and it won't be cached into registers.
There was a thread on the egcs list about this a few months ago. GCC does not guarantee that incrementing a volatile will do it in a single instruction, even if a single instruction is available.
The value won't be cached (mod. compiler bugs), but it may be loaded, incremented and then stored. And the store may be deferred past other non-volatile operations and function calls.
As we all know "incl" is not atomic between competing processors, but it is atomic w.r.t. interrupts on the same processor as the increment. Maybe that's why someone thought it was important.
But as Andrea says: > The only "jiffies" writer is the timer irq handler that as an irq handler > is single threaded by the linux irq design. So there's no point at all to > even think about atomicity.
So jiffies++ would be fine.
-- Jamie
- 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/
| |