🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7551
From: Alan Bellingham
Date: Wed, 19 Jan 2005 18:38
23 lines
2011 bytes
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote:

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

If there are _any_ threads that modify the variable, then all threads
must cooperate to ensure that it is only modified when none are also
trying to read it.

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.

However, some of us already have multi-processor PCs, and also
hyperthreading and multi-core CPUs will be increasingly common in the
near future. With these, I think even a primitive is no longer safe.

Alan Bellingham
-- 
ACCU Conference 2005 - 20-23 April, Randolph Hotel, Oxford, UK
Technical Details
Message-ID: <qu9tu0hgv4gqnlvv65nqq70ua4v73jv0mu@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.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> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com> <41ee8f57$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: Alan Bellingham <alanb@episys.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Accessing same variable from multiple threads
Date: Wed, 19 Jan 2005 18:38:19 +0000
Reply-To: alanb@episys.com
Message-ID: <qu9tu0hgv4gqnlvv65nqq70ua4v73jv0mu@4ax.com>
References: <41edea6b@newsgroups.borland.com> <41ee3727$1@newsgroups.borland.com> <41ee742e$1@newsgroups.borland.com> <41ee8f57$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 2.0/32.652
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.129.251.130
X-Trace: newsgroups.borland.com 1106159898 193.129.251.130 (19 Jan 2005 10:38:18 -0800)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail