TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: Craig Swanson
date: 1996-02-07 10:42:44
subject: thread safe

CS> Making code thread-safe usually involves the following:

 CS> 1) Avoid global variables

 CS> 2) Use local (i.e., auto or allocated on the stack) variables

 PC> Does this mean making sure that the compiler/optimizer
 PC> doesn't register any
 PC> local variables?  Someone mentioned a bug in Borland that it was ignoring
 PC> the command not to register local variables or something like that.

There is no prohibition against using variables allocated to registers. 
This is because every thread has its own stack and own set of registers.  I
don't use Borland C++, only TASM/2, so I'm not familiar with any bugs in
that product.

 PC> I know how to use mutex semaphores and I doubt anything I write will ever
 PC> run on an SMP system.

Personally, I want to run my code on SMP hardware even if it won't be used
this way in the field because in theory it should make it more likely to
fail if there are race conditions, improper use of mutex and event
semaphores, or failure to protection shared data structures.

Given how dual Pentium motherboards using the Intel Neptune chipset (with
no CPU chips) are under $600 now with a new round of them due out this
quarter using the cheaper (and better) Intel Triton II chipset, I fully
expect that dual Pentium 133MHz motherboards (including CPU chips) will be
available for under $1000 by the end of the year. That's cheaper than what
a single 486DX/50 EISA motherboard cost in 1992, and probably cheaper than
Pentium Pro motherboards (with CPU) will be until sometime in 1997 given
how the price for the Pentium Pro CPU alone is in the $1000 ballpark (or
closer to $2000 per chip for the ones with 512KB of level 2 cache).

When the Pentium Pro starts falling in price, expect to see a large
fraction of systems using it able to support two processors.  ALR and HP
already have such systems available.  Support for four processors sounds
like it is basically just a matter of time while Intel gets the bugs worked
out of their Orion chipset so it works properly with four processors rather
than just two.

Considering all of the above information, I wouldn't count on SMP systems
remaining as rare as they are today as they will be a practical way to bump
up speed on servers and high-end Pentium desktop PC's for people who don't
want to spend as much as Pentium Pro hardware costs or who are running lots
of 16-bit code that might perform better on a dual Pentium system than on a
single Pentium Pro system.  And the people who have the money to spend on a
Pentium Pro might think another $1000 for a second CPU is worthwhile.


--- Maximus/2 2.02
* Origin: OS/2 Connection {at} Mira Mesa, CA (1:202/354)
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: 202/354 300 777 3615/50 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™.