Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 1996 09:44:10 -0800
From:      John Polstra <jdp@polstra.com>
To:        michaelh@cet.co.jp
Cc:        hackers@freebsd.org
Subject:   Re: Programming technique for non-forking servers?
Message-ID:  <199611141744.JAA08935@austin.polstra.com>
In-Reply-To: <Pine.SV4.3.95.961114113713.18257A-100000@parkplace.cet.co.jp>
References:  <Pine.SV4.3.95.961114113713.18257A-100000@parkplace.cet.co.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
> mset and mclear would be implemented as lib functions because Intel does
> have an atomic test and set.

Yes it does: the "xchg" instruction.  Load 1 into a register, then "xchg"
the register with the memory location containing the lock.  Look at the
new value of the register to find out whether the lock was already
locked.  It even works in a multiprocessor system.  According to the
Intel book:

  If a memory operand is involved, the LOCK# signal is asserted for the
  duration of the exchange, regardless of the presence or absence of the
  LOCK prefix or of the value of the IOPL.
--
   John Polstra                                       jdp@polstra.com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth



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