🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7558
From: Remy Lebeau (TeamB)
Date: Wed, 19 Jan 2005 21:35
20 lines
2024 bytes
"Alan Bellingham" <alanb@episys.com> wrote in message
news:qu9tu0hgv4gqnlvv65nqq70ua4v73jv0mu@4ax.com...

> Otherwise, the writing thread may have partially updated it when
> a reading thread attempts to read it. If it's a primitive, and you
> only have a single processor machine with no ability to actually
> execute more than one thread at a time, then I don't think you
> will see thread switching in the middle of the write.

That depends on not only the nature of the shared data itself, but also its
alignment in memory.  For instance, a 32-bit integer aligned on a 32-bit
memory boundary can be read from and written to atomically, so the access
can be implicitally synchronized by the CPU directly.  But that is usually
not the case, unless you make the extra effort to specifically set up your
code to ensure that scenerio.  Any other time, you usually have to provide
your own synchronizing in your own code.


Gambit
Technical Details
Message-ID: <41eed226@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!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> <qu9tu0hgv4gqnlvv65nqq70ua4v73jv0mu@4ax.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> <qu9tu0hgv4gqnlvv65nqq70ua4v73jv0mu@4ax.com>
Subject: Re: Accessing same variable from multiple threads
Date: Wed, 19 Jan 2005 13:35:39 -0800
Lines: 22
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: <41eed226@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106170406 68.69.17.41 (19 Jan 2005 13:33:26 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail