Re: (*(unsigned long *)&jiffies)++;

From: Tigran Aivazian (tigran@sco.COM)
Date: Thu Jan 06 2000 - 12:01:53 EST


On Thu, 6 Jan 2000, 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.

Andrea,

Thank you, I know what volatile means :) - the reason I asked the question
is because I suspected that some buggy versions of gcc ignore or mishandle
it (and some people seem to confirm that, if you read this thread).

But, as you say, irq handling is single-threaded so there is no need
for atomicity (and thus no need for my earlier suggestion of using
atomic_t jiffies). Therefore, the more economical way of writing is
jiffies++;

As for the lost_* variables I know they are unrelated to jiffies. But it
does not matter. Both are declared as volatile and yet jiffies were
incremented in a strange way but lost_* were incremented in a usual
way, so my confusion was justified.

Regards,
Tigran.

-
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/



This archive was generated by hypermail 2b29 : Fri Jan 07 2000 - 21:00:06 EST