Article View: borland.public.cppbuilder.nativeapi
Article #7585Re: Accessing same variable from multiple threads
From: Vladimir Afanasyev
Date: Fri, 21 Jan 2005 10:10
Date: Fri, 21 Jan 2005 10:10
38 lines
2731 bytes
2731 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >> Really because one variable can be changed to some variables or >> structure via refactoring the using semephors and critical sections >> preferable. If think that better way will be if reading thread creates >> another thread that will have sole task - listen/watch for >> variables. > >That just complicates the design even more, and doesn't even solve the >problem at all. You still have to synchronize, and now you've introduced >another thread that still has to synchronize as well > You can't track all changes of variables and do another work in the one thread. >> This thread (in my opinion) must use semaphor for watching for >variable(s). > >You just contradicted yourself. First you said that synchronization is not >needed, but then you offer an approach that uses synchronization. I didn't contradicted. I talked about easist case. Intel has operation that executed as primitives and in easist case no need to use critical sections. You said before about Win32 functions that represent this operations (InterlockedExchange, InterlockedExchangeAdd). >But it >still won't work. A critical section or semaphor wil not work unless ALL >threads accessing the shared data use them. Otherwise they do not provide >any protection at all. Off course, it is no problem there and I said about it in one my message before. Vladimir.
Technical Details
Message-ID:
<41f0d501$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com> <41ee8f57$1@newsgroups.borland.com> <41ee9bd1$1@newsgroups.borland.com> <41eea799$1@newsgroups.borland.com> <41eed116$1@newsgroups.borland.com> <41efa03e$1@newsgroups.borland.com> <41efed8e$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> <41ee8f57$1@newsgroups.borland.com> <41ee9bd1$1@newsgroups.borland.com> <41eea799$1@newsgroups.borland.com> <41eed116$1@newsgroups.borland.com> <41efa03e$1@newsgroups.borland.com> <41efed8e$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <41f0d501$1@newsgroups.borland.com> Date: 21 Jan 2005 02:10:09 -0800 X-Trace: newsgroups.borland.com 1106302209 207.105.83.66 (21 Jan 2005 02:10:09 -0800) Lines: 38 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail