TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: Mike Bilow
date: 1996-01-22 17:13:50
subject: pdpclib

Phil Crown wrote in a message to Paul Edwards:

 PF> Is it thread safe?  

 PE> I've no idea.  What is thread safe?

 PC> Good question.  I'll be watching for the answer to this...
 PC> :-) 

In the case of a library routine, Peter meant that it would be safe linking
the library with a multithreaded program which might have more than one
thread calling into the routine at the same time.  While re-entrant code is
always thread-safe, it is also possible to make code thread-safe using
mechanisms other than re-entrant code, such as semaphore guarding.

There was an article a few months ago in C++ Users Journal which proposed a
nice scheme for semaphore management in C++ under OS/2.  The idea was to
define a mutual exclusion class whose constructors and detructors would
manage the semaphore for you.  This allows simply instantiating the proper
mutual exclusion object as a compiler automatic when your routine is
entered, and then the compiler handles management of it for you.

Re-entrant code, on the other hand, implies that each instance of the
routine gets its own copy of all local data and resources, which is usually
maintained on the stack. This way, each instance runs without knowledge of
the other.  Unfortunately, sometimes it is impossible to make a local copy
of a resource because of the nature of the resource, either because it is
large, or because it might be associated with a piece of hardware such as a
serial port.
 
-- 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™.