<<On Wed, 17 Jan 2001 14:26:54 +1100, Peter Jeremy <[EMAIL PROTECTED]> said:

> To support multiple masters, you need proper locks.

On older processors, yes.  On processors with the CX8 feature bit set,
you can do it without any sort of locking (indeed, this is a primitive
that semaphores can be built upon).  Consider the following:

atomic_increment:
        ; prologue
        ; get EA into %esi
        movl (%esi), %eax
        movl 4(%esi), %edx
1:      movl %eax, %ebx
        movl %edx, %ecx
        incl %ebx
        adcl $0, %ecx
        cmpxchg8b (%esi)        ; generates a locked bus cycle
        jne 1
        ; epilogue

On pre-Pentium processors (which lack the CX8 feature) this sort of
sequence is impossible.  OTOH, I don't think SMP works on any
pre-Pentium processor, so again this degenerates to:

        pushfl
        cli
        incl (%esi)
        adcl $0, 4(%esi)
        popfl

...in the non-SMP case.

-GAWollman



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to