Article View: borland.public.cppbuilder.nativeapi
Article #17510Re: Tweaking threads
From: Dennis Jones
Date: Wed, 12 Mar 2003 19:39
Date: Wed, 12 Mar 2003 19:39
35 lines
2460 bytes
2460 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message news:3e6e2fb9@newsgroups.borland.com... > > "Ted Tripp" <ttripp@skypoint.com> wrote in message > news:3e6deb3f@newsgroups.borland.com... > > The BCB5 manual recommends no more than 16 threads > > per processor. > > Ignore it. It's rubbish. I've seen programs running hundreds of threads at > a time without any problems. > > > my app usually runs the CPU at about 100%, is there a > > way to control that? > > That is typically caused by your code running tight loops that don't yield > control to other threads/processes. Try introducing Sleep() calls in your > loops. Of course, only one thread at a time is actually executing at any given moment (one thread per processor). It is also possible that having too many (active) threads can have potentially devestating effects on performance due to the overhead required to perform a context switch. I seem to recall reading something once which talked about the optimum number of simultaneous threads per processor being somewhere around 3 or 4. Less than that, and you are wasting processor time (assuming the threads go to sleep once in a while); more than that, and your process actually begins to slow down (if all of the threads are active at the same time) because of context switching. I'll have to try to find where I read that...or perhaps someone else remembers the same article(?) and knows where it is. WDJ? CUJ? - Dennis
Technical Details
Message-ID:
<3e6f8ce5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e6deb3f@newsgroups.borland.com> <3e6e2fb9@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,47731b28ebfc1a3 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-12 20:39:59 PST From: "Dennis Jones" <djones@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e6deb3f@newsgroups.borland.com> <3e6e2fb9@newsgroups.borland.com> Subject: Re: Tweaking threads Date: Wed, 12 Mar 2003 11:39:18 -0800 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 204.200.27.7 Message-ID: <3e6f8ce5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1047497957 204.200.27.7 (12 Mar 2003 11:39:17 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail