lkml.org 
[lkml]   [2000]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: (*(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/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.650 / U:2.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site