Article View: borland.public.cppbuilder.nativeapi
Article #6299Re: threads memory access
From: Dennis Jones
Date: Tue, 24 May 2005 16:21
Date: Tue, 24 May 2005 16:21
27 lines
2209 bytes
2209 bytes
"Jonathan Benedicto" <incorrect@no.server> wrote in message news:4291ed05$1@newsgroups.borland.com... > "Oliver Rutsch" <orutsch@sympatec.com> wrote in message > news:4291c5b1$1@newsgroups.borland.com... > > > > I would never use boolean locks "by hand". Use instead a critical > > section for your structure. When we come to hyper threading and > > dual/multi core systems even a bool-write is not an atomic operation > > anymore. And what do you do if one thread finds the structure > > locked? It polls the bool and consumes time. A critical section > > manages this all for you. > > Thank you for this input. I could use critical sections, but I thought > that the bool would be enough. I really need as little delay as > possible when trying to find the unlocked buffer. A critical section is the most efficient (in terms of performance) kernel mode synchronization primitive. If you are looking for performance, a critical section is the way to go. Though it might seem slower than, say, a boolean lock, it is safe, while a boolean lock is not. On the other hand, depending on what the other threads are doing, it might be faster to lock the whole vector, do your search, and then unlock (as opposed to locking each element individually). - Dennis
Technical Details
Message-ID:
<429354a6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<428e4b3f$1@newsgroups.borland.com> <4291c5b1$1@newsgroups.borland.com> <4291ed05$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f662da50ec5f6f69 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dennis Jones" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <428e4b3f$1@newsgroups.borland.com> <4291c5b1$1@newsgroups.borland.com> <4291ed05$1@newsgroups.borland.com> Subject: Re: threads memory access Date: Tue, 24 May 2005 09:21:29 -0700 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 204.200.27.7 Message-ID: <429354a6@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1116951718 204.200.27.7 (24 May 2005 09:21:58 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail