lkml.org 
[lkml]   [1998]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] 498+ days uptime
Date
Followup to:  <19980825141946.A2198@tantalophile.demon.co.uk>
By author: Jamie Lokier <lkd@tantalophile.demon.co.uk>
In newsgroup: linux.dev.kernel
>
> Incrementing a 64-bit value on i386 is fast and simple. It's arithmetic
> done in GCC, especially with temporaries that you have to worry about.
>
> The instruction sequence is:
>
> incl counter
> adcl $0,counter+4
>
> This could be made into a kernel macro. Because the carry is so rare,
> you could safely use a lock prefix before the incl and put this in a
> macro called atomic_count or something.
>

This is wrong: INC doesn't update CF; one of the many quirks of the
x86 architecture. You need:

addl $1,counter
adcl $0,counter+4

-hpa

--
PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD 1E DF FE 69 EE 35 BD 74
See http://www.zytor.com/~hpa/ for web page and full PGP public key
I am Bahá'í -- ask me about it or see http://www.bahai.org/
"To love another person is to see the face of God." -- Les Misérables

-
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.altern.org/andrebalsa/doc/lkml-faq.html

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