[linux-audio-dev] x86 atomic operations

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] x86 atomic operations
From: est_AT_hyperreal.org
Date: to syys   30 1999 - 14:51:08 EDT


Paul Barton-Davis discourseth:
>
> yes, they use compare-and-swap, which doesn't exist on the x86 (well,
> it didn't up to the 486 - did Intel come to their senses and add it ?)

Well, here's the 486+ implementation in LinuxThreads:

PT_EI int
__compare_and_swap (long int *p, long int oldval, long int newval)
{
  char ret;
  long int readval;

  __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
                        : "=q" (ret), "=m" (*p), "=a" (readval)
                        : "r" (newval), "m" (*p), "a" (oldval)
                        : "memory");
  return ret;
}

I *think* the lock operation makes everything up to the next write
atomic. I'd love it if someone could confirm this. Maybe I just need
to look at an intel manual online.

Eric


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:27:12 EST