Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Dec 2000 17:37:02 -0800 (PST)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Mike Smith <msmith@FreeBSD.ORG>
Cc:        Julian Elischer <julian@elischer.org>, John Baldwin <jhb@FreeBSD.ORG>, current@FreeBSD.ORG
Subject:   Re: __asm help.. 
Message-ID:  <200012090137.eB91b2w25635@earth.backplane.com>
References:   <200012082356.eB8NukF02878@mass.osd.bsdi.com>

next in thread | previous in thread | raw e-mail | index | archive | help

:
:> 
:> Since all I WANT to do is 
:> pushf
:> disable intr
:> fiddle
:> popf (chache hit)
:> 
:> I am annoyed by the fact that I have all those extra bus cycles going on.
:> I can live with it for development but it still annoys me.
:
:You haven't yet explained how you plan to disable interrupts on the other 
:CPUs...
:
:-- 
:... every activity meets with opposition, everyone who acts has his

    Julian, I would recommend using the cmpxchgl instruction to implement
    atomic operations.  Look at /usr/src/sys/i386/i386/mplock.s for
    an example.  You will be in much better shape if you can avoid
    cli/sti (as Mike points out, it doesn't work across cpu's).

    mplock.s already has basic MP-compatible lock recursion and should
    provide a ready example on how you need to do the locking.

    There is a serious issue you need to consider when implementing
    an SMP-capable lock, and that is cpu-cpu synchronization.

    In order to synchronize an operation across multiple cpu's on IA32 you
    have to use the 'lock;' instruction prefix.  Typically, the cmpxchgl
    must be locked.  However, you only need to lock it when there is
    possible contention.. when you are aquiring the lock.  You do not need
    to lock it when you are releasing the lock.

    If your assembly gets too complex, just make the assembly a subroutine
    call.  Believe me, subroutine overhead is *nothing* compared to bus
    locking overhead.  For that matter, the cli/sti alone will have more
    overhead then a subroutine call.  Just write it in assembly and forget
    about trying to use the C __asm() directive.  You'll be happier.

						-Matt



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012090137.eB91b2w25635>