🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing same variable from multiple threads

#7494
From: Remy Lebeau (TeamB)
Date: Tue, 25 Jan 2005 00:32
36 lines
2567 bytes
"roladdon" <roladdon@PutMyServerHere.ca> wrote in message
news:41f58ffe@newsgroups.borland.com...

> 1) Could anything else happen besides a corrupt value ? (like
> a system crash..., exception...)

Yes, depending on how the value is actually used.

> like in a scenario where the value does not matter and is
> used for informational purpose only, example for display only

If you are only displaying the value, not evaluating the value for anything,
then at the least all you may get is a the messed up display.  But if you
are processing the value for anything (calculations, pointer access, array
indexes, etc), then you could potentially crash the code.  Just saying that
any unprotected access will crash is too vague.  It depends on the context
in which the data is actually being used.

> 2) In case of checking for  true or false of a shared var:

Booleans are atomic, they are only 1 byte in size, and CPU operations work
with individual bytes as the smallest block of data accessible.  Anything
greater than 1 byte in size could potentially require multiple CPU cycles to
access, especially if the value straddles both sides of an alignment
boundary.

>         I thought it guarantied that the processor writes -
uninterrupted -
> at least one byte to memory?

The issue is not with single-byte data types.  It is with multi-byte types
(short, int, pointers, __int64, etc).


Gambit
Technical Details
Message-ID: <41f59319@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41edea6b@newsgroups.borland.com> <41ee9aae$1@newsgroups.borland.com> <41ef3506@newsgroups.borland.com> <41eff001$1@newsgroups.borland.com> <41f57030$1@newsgroups.borland.com> <41f57ff8$1@newsgroups.borland.com> <41f58ffe@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> <41ee9aae$1@newsgroups.borland.com> <41ef3506@newsgroups.borland.com> <41eff001$1@newsgroups.borland.com> <41f57030$1@newsgroups.borland.com> <41f57ff8$1@newsgroups.borland.com> <41f58ffe@newsgroups.borland.com>
Subject: Re: Accessing same variable from multiple threads
Date: Mon, 24 Jan 2005 16:32:55 -0800
Lines: 38
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: <41f59319@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106613017 68.69.17.41 (24 Jan 2005 16:30:17 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail