🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: threads memory access

#6286
From: Oliver Rutsch
Date: Mon, 23 May 2005 11:59
17 lines
1716 bytes
Hi Jonathan Benedicto,

> 
> Now, when they need a buffer, they just loop through the vector, 
> finding one with its Locked == false, and then set the Locked to true, 
> fill the char* and int, and then send a pointer to it to the 3rd 
> thread. Once the 3rd thread is finished with it, it just sets the 
> Locked to false.

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.

Bye, Oliver
Technical Details
Message-ID: <4291c5b1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <428e4b3f$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
Date: Mon, 23 May 2005 13:59:38 +0200
From: Oliver Rutsch <orutsch@sympatec.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en-us, en, de-de
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: threads memory access
References: <428e4b3f$1@newsgroups.borland.com>
In-Reply-To: <428e4b3f$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 217.5.250.34
Message-ID: <4291c5b1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116849585 217.5.250.34 (23 May 2005 04:59:45 -0700)
Lines: 17
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail