TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Craig Swanson
from: Mike Bilow
date: 1996-02-04 00:54:02
subject: mutex semaphores

Craig Swanson wrote in a message to Mike Bilow:

 CS> I agree, that is the point of mutex semaphores.  But for
 CS> counters that just need to count up or down atomically, LOCK
 CS> with INC or LOCK with DEC should be safe in an SMP
 CS> environment whereas INC and DEC without the LOCK would not
 CS> be safe.  Does this agree with your understanding?

No.  INC and DEC are atomic with or without a LOCK prefix.

 CS> But what you said above is that the LOCK and the DEC [eax]
 CS> would be executed atomically, in other words the interrupt
 CS> would not be serviced until AFTER the DEC [eax] instruction
 CS> completed.  Is this correct?

 CS> Or maybe this would be necessary?

 CS>     CLI
 CS>     LOCK
 CS>     DEC [EAX]
 CS>     STI

 CS> If that's the case, it basically blows my idea out of the
 CS> water for SMP systems because CLI/STI aren't supposed to be
 CS> used in ring 3 code in OS/2 applications.

No.  The DEC instruction is atomic.

 CS> DEC/INC instructions will do successive bus cycles, a read
 CS> followed by a write.  Doesn't this mean that if another
 CS> processor was trying to modify the same addresses that it
 CS> could insert a bus cycle between the read and write if they
 CS> are not both using the LOCK prefix?  That is how I
 CS> understood this, anyway. 

No.  The bus is synchronized among all processors.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 323/107 170/400 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.