TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: Mario Semo
date: 1996-01-23 11:28:48
subject: pdpclib

Hello Phil,

On Jan 21 17:55 96, Phil Crown of 1:124/1208 wrote:

 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... 

?? Whats the question? Thread safe means that the code runs ok even if used
in different threads at the same time.

the following code is not thread safe:

linkedList xxx;

threadFunc()
{
 ptr = xxx.firstelement;
 changeDatainPtr(ptr)
}

reason: a 2nd thread can do:

{
 deleteFirstElementInList(xxx);
}

and if the thread switching looks like:

thread1: ptr=....
thread2: deleteFirst....
thread1: modify *ptr. (this is invalid now, since ptr is already deleted!).

so, threadSafe means in this case, that the resource xxx must be lockt,
when someone is using it:

thread1:
{
 ...
 lock resource xxx
 ptr=...
 change ....
 unlock resource
 ....
}

thread2
{
 lock resource xxx
 ....
}

so, when thread1 is changing the first element in xxx, xxx is lockt and
thread2 have to wait until thread1 is done with xxx. 

 WARPED!, Mario

--- Msgedsq/2 2.2e
* Origin: LC/32 Development Team-Vienna-Austria (2:310/14.11)
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: 310/14 1 24/999 2/777 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™.