🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7586
From: Remy Lebeau (TeamB)
Date: Fri, 21 Jan 2005 10:40
22 lines
2169 bytes
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:41f0d501$1@newsgroups.borland.com...

> Intel has operation that executed as primitives and in easist
> case no need to use critical sections.

What you describe only applies to cases where the operations can be
performed atomically.  That is not always the case.  Rather than assuming
the CPU can always handle it for you implicitally, which it can't, you shold
always provide your own synchronizing to ensure that it always gets done
properly regardless of the circumstances.

> You said before about Win32 functions that represent this
> operations (InterlockedExchange, InterlockedExchangeAdd).

Those functions only work under certain circumstances.  Which is why I also
provided the critical section approach as an alternative that is always
guaranteed to work.


Gambit
Technical Details
Message-ID: <41f0dba6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!spool-3.news.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
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> <41f0d501$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: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
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> <41f0d501$1@newsgroups.borland.com>
Subject: Re: Accessing same variable from multiple threads
Date: Fri, 21 Jan 2005 02:40:56 -0800
Lines: 24
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41f0dba6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106303910 68.69.17.41 (21 Jan 2005 02:38:30 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!spool-3.news.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail