🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7542
From: Vladimir Afanasyev
Date: Wed, 19 Jan 2005 16:48
28 lines
2281 bytes
"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote:
>I am confused by the two critical sections.  What am I missing?
>
>I understand the idea is to block reading of a value that has been only
>partially altered.  Would it not work if a critical section were only
>established for that code which modifies the variable?

If both threads works asynchronously - one modifies when want, 
another reads when want then no need any critical sections and 
semaphors for both threads.

But may be second thread (read) must tracks any changes of variable. It is another case. And then semaphors can be a good solution.


As I understand critical section do not block access to 
sharing variable. Only code inside critical section is blocked. 
Another thread of the same process can't enter in the blocked critical critical section. So if threads can access to variable from critical section they do it by turn without conflicts.
Really no need to use it when one thread modify and another 
only read (it can be useful only if some threads make modifications).

So my answer was incorrect.

By the way. I search in Borland site and find no reference 
about Borland C# Builder product. I something missed and Borland 
does not sell and support it.

Vladimir.
Technical Details
Message-ID: <41ee8f57$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$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
From: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Sender: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Reply-To: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Subject: Re: Accessing same variable from multiple threads
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 83.218.237.46     
X-Forwarded-For: unknown
References:  <41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41ee8f57$1@newsgroups.borland.com>
Date: 19 Jan 2005 08:48:23 -0800
X-Trace: newsgroups.borland.com 1106153303 207.105.83.66 (19 Jan 2005 08:48:23 -0800)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail