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

Craig Swanson wrote in a message to Mike Nice:

 CS> So what about the case where a program has two threads doing
 CS> I/O on two serial ports and the same code is used to do I/O
 CS> on both ports? It sounds like what you two are saying is
 CS> that it is not possible for both threads to be blocked on
 CS> the same DosRead() call in the code at the same time.  If
 CS> this is true, it seems to me this is a serious problem given
 CS> how it is very common for threads doing I/O to spend a lot
 CS> of time being blocked pending I/O completion. 

Application threads are blocked waiting for a device driver.  While a
device driver is reentrant, it is not multithreaded.  The application
threads can be on any processor, but the device driver (or at least its
interrupt service routine) must be running on the master processor.

 CS> I'm under the impression that LOCK does not get trapped, it
 CS> executes directly.  What is confusing me is what happens
 CS> regarding interrupts and LOCK.  For instance:

 CS>     LOCK
 CS>     
 CS>     INC     [ax]

 CS> Does the interrupt get serviced between the LOCK and INC, or
 CS> after the INC?  It seems to me that for LOCK to be truly
 CS> useful,the interrupt should be serviced after the INC.  But
 CS> so far I have not been able to find an answer for this
 CS> question.

It doesn't make any difference whether the interrupt occurs before or after
the INC instruction, as long as the interrupt cannot occur during the
instruction.  In fact, even in single processor systems, a one-pass
instruction such as INC can never be interrupted.  Such use of the LOCK
prefix is therefore basically pointless.  There is a purpose for the LOCK
prefix, but it is completely unrelated to this issue.
 
-- 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™.