🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7500

Re: Accessing same variable from multiple threads

#7500
From: roladdon
Date: Tue, 25 Jan 2005 16:08
41 lines
2865 bytes
I did not understand the reason for the discussion.

It is a fact and very clear that:
If writing a multibyte var is interrupted - that reading that same var  may 
not show the correct value.
No discussion needed about that.

But you are saying - answering the original question in this thread:
  >You still need to synchronize
  >regardless of what you are using the shared var for.

That confused me!

The only corruption possible - I think - is that
1) Each seperate  Byte  (inside a multibyte value)  may contain still is old 
or already it's new value.
So for example Byte3 may already have it's new value while Byte1 may still 
have it's old value.

Right? - nothing else beside that can happen - Right?

So - back to the original quesion in this Thread:
 >But an exact value of the var is not important for the 2nd thread.
 >The thread checks it for zero or not, i.e. "if (my_var)...".

I believe there is no need to use a sync. function!
  > "The thread checks it for zero"
probably some timed intervals.

So if a read and write happens at the same time - The worst that can happen 
is that the value is not zero yet.
The next time arround it will be zero - no beig deal - since he seems to be 
polling anyway.
I don't see how using a sync. function would make a difference.
He is polling - and may miss the value 0 anyway.

I would say that he would be probably better off to use - inside his 
Thread - one of the   WaitForObject() functions with i.e. an EventObject 
instead of polling for a value.

Roland
Technical Details
Message-ID: <41f66ee4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41edea6b@newsgroups.borland.com> <41ee9aae$1@newsgroups.borland.com> <41ef3506@newsgroups.borland.com> <41eff001$1@newsgroups.borland.com> <41f57030$1@newsgroups.borland.com> <41f57ff8$1@newsgroups.borland.com> <41f58ffe@newsgroups.borland.com> <41f59319@newsgroups.borland.com> <41f598ef$1@newsgroups.borland.com> <41f60090$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4809cdd9a7828fa7
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "roladdon" <roladdon@PutMyServerHere.ca>
From: "roladdon" <roladdon@PutMyServerHere.ca>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41edea6b@newsgroups.borland.com> <41ee9aae$1@newsgroups.borland.com> <41ef3506@newsgroups.borland.com> <41eff001$1@newsgroups.borland.com> <41f57030$1@newsgroups.borland.com> <41f57ff8$1@newsgroups.borland.com> <41f58ffe@newsgroups.borland.com> <41f59319@newsgroups.borland.com> <41f598ef$1@newsgroups.borland.com> <41f60090$1@newsgroups.borland.com>
Subject: Re: Accessing same variable from multiple threads
Date: Tue, 25 Jan 2005 11:08:02 -0500
Lines: 44
Organization: AddOn
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 64.231.67.179
Message-ID: <41f66ee4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106669284 64.231.67.179 (25 Jan 2005 08:08:04 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail