🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7549
From: Vladimir Afanasyev
Date: Wed, 19 Jan 2005 18:31
25 lines
2277 bytes
>
>They do need to share a common instance of the critical section or semaphor,
>and they both need to use it in order to properly protect the shared data in
>a synchronized manner.  Without it, one thread could be reading the data at
>the exact same moment that another thread is altering the data.
>

It is not exactly because it's not clear from task when and how 
threads will work with variable.

For example both threads access to variable asynchronous. Look.

One thread modyfyes variable in 10:00 and 10:05.

Another thread may read in 9:58, 10:02, 10:07. In every of cases it 
will be various value of variables undependenly of using or 
not using critical sections. If this threads doesn't know 
exactly when data was changed it may read it in any time or 
it must carefully track for changes. Critical sections doesn't 
help for tracking changes (or it must be called continuously).
I only say that it is not important to enter in critical section if unknown when changes were. Reading thread can 
enter before first writing or after but really reading thread 
must all time "listen" variable via critical section or semaphor. Or it is incorrect?
Vladimir.
Technical Details
Message-ID: <41eea799$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.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> <41ee9bd1$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>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41eea799$1@newsgroups.borland.com>
Date: 19 Jan 2005 10:31:53 -0800
X-Trace: newsgroups.borland.com 1106159513 207.105.83.66 (19 Jan 2005 10:31:53 -0800)
Lines: 26
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.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