Article View: borland.public.cppbuilder.nativeapi
Article #7732Re: Using InterlockedXXX family functions
From: Leo Havm�ller
Date: Thu, 23 Dec 2004 06:43
Date: Thu, 23 Dec 2004 06:43
17 lines
1762 bytes
1762 bytes
"Tumurbaatar S." <nospam_tumur@magicnet.mn> wrote in message news:41ca6807@newsgroups.borland.com... > Hello! > My program is 2-threaded and there's a shared variable. > The variable is something like a performance counter. > One thread constantly (about 20..50 times per second) > modifies (increments) this variable's value and the second thread > periodically (every 2..10 second) reads its value and resets it to zero. > Instead of using a critical section, I use InterlockedXXX() functions. > But I have to use these functions only in one thread (probably in > the 2nd thread, because it access the shared variable rarely) > or in both threads? Use InterlockedIncrement in the thread that increments the variable, and InterlockedExchange in the thread that resets it to zero. Leo Havm�ller.
Technical Details
Message-ID:
<41ca6903$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.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-mailReferences:
<41ca6807@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d3bc4ea7bb23fd1c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: "Leo Havm�ller" <leh@-nospam-rtx.dk> Newsgroups: borland.public.cppbuilder.nativeapi References: <41ca6807@newsgroups.borland.com> Subject: Re: Using InterlockedXXX family functions Date: Thu, 23 Dec 2004 07:43:17 +0100 Lines: 19 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 80.63.27.146 Message-ID: <41ca6903$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1103784195 80.63.27.146 (22 Dec 2004 22:43:15 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.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