🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Multi-Thread Processing on Dual-Core CPU

#2336
From: Jonathan Benedicto
Date: Wed, 14 Mar 2007 16:12
41 lines
2761 bytes
Robert G. Hoover wrote:
> Yep, that did the trick. Makes sense, I suppose if you ignore the 
> "MM_TEXT"
> description???  ;)

Good :-)

> I'm now realizing how little I know about multi-thread processing as my 
> other
> threads in my program are crashing out. For example, my commport listening
> thread causes a program fault when I change the value of the indexing 
> variable.
> When I set RXSize to 0 in my main thread/process, the fault occurs, I 
> assume
> because it's fighting with the ReadFile() line below.

Possibly. I would use a critical section for that code.

> This code has no semaphores in it at all. If I place simple bool variables 
> like
> 'busy' and 'waiting' into the code, will I run into the same problem, 
> accessing the
> bool variables from both sides at once?

Possibly. I personally wouldn't take any risks, and would just use 
semaphores, critical sections or events here.

> Is this a good case for the Win32 Semaphore
> functions? Are they overkill for this little thing?

I would say it is a good case for the Win32 syncronization functions. You 
can use critical sections, events or semaphores, depending on what you need 
to synchronize.

Read the topics in this page for some more detail on the thread 
syncronization functions that Windows has:
http://msdn2.microsoft.com/en-us/library/ms686353.aspx

HTH

Jon 
Technical Details
Message-ID: <45f81f00$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com> <45f5973e$1@newsgroups.borland.com> <45f598bf$1@newsgroups.borland.com> <45f59c41$1@newsgroups.borland.com> <45f59e8e$1@newsgroups.borland.com> <45f5aca4@newsgroups.borland.com> <45f5b4dc$1@newsgroups.borland.com> <45f5fdec$3@newsgroups.borland.com> <45f5fec6$1@newsgroups.borland.com> <45f81a06@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,411b13b57e2ea81a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jonathan Benedicto" <invalid@nobody.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com> <45f5973e$1@newsgroups.borland.com> <45f598bf$1@newsgroups.borland.com> <45f59c41$1@newsgroups.borland.com> <45f59e8e$1@newsgroups.borland.com> <45f5aca4@newsgroups.borland.com> <45f5b4dc$1@newsgroups.borland.com> <45f5fdec$3@newsgroups.borland.com> <45f5fec6$1@newsgroups.borland.com> <45f81a06@newsgroups.borland.com>
In-Reply-To: <45f81a06@newsgroups.borland.com>
Subject: Re: Multi-Thread Processing on Dual-Core CPU
Date: Wed, 14 Mar 2007 12:12:45 -0400
Lines: 42
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16386
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16386
NNTP-Posting-Host: 74.115.18.89
Message-ID: <45f81f00$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1173888768 74.115.18.89 (14 Mar 2007 09:12:48 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail