RE: Threading Question
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Thu, 24 Nov 2005 08:51:34 GMT
Thanks for your response Cristian,
If so, I'm afraid interval less than 10 milliseconds are too critical for
NET framework runtime since it has run beyond the runtime's core profiling
ability. Currently, if your program really demand critical requirement on
runtime profiling, maybe C/C++ is the more reasonable choice.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Threading Question
| thread-index: AcXwH0xKLtDYOWuQRfKJQ82a8kBKZA==
| X-WBNR-Posting-Host: 85.36.120.93
| From: =?Utf-8?B?TW9yaUNyaXN0aWFu?= <CristianMori@xxxxxxxxxxxxx>
| References: <8F6C013C-D17F-49B3-BB0A-3AEC1835C8FE@xxxxxxxxxxxxx>
<vCh4KtA8FHA.4000@xxxxxxxxxxxxxxxxxxxxx>
| Subject: RE: Threading Question
| Date: Wed, 23 Nov 2005 03:16:06 -0800
| Lines: 93
| Message-ID: <22E55660-B6CB-4065-9FC0-7128CBB7C20D@xxxxxxxxxxxxx>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.performance
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.performance:11023
| X-Tomcat-NG: microsoft.public.dotnet.framework.performance
|
| Hi, Thanks Steven.
| I'm into a real-time simulation. I need to perform calculation very fast,
| without 100% cpu consuption.
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Cristian,
| >
| > Welcome.
| > As for the threading problem you mentioned, I think a simple while loop
| > (without sleep...) will surely eat all the CPU time, so it should
always be
| > avoided. For the Thread.Sleep(ms), this function has certain accuracy
| > limitation ,when we specify a too small value, the Timespan between
each
| > wakeup of the thread can not be smaller than the limitation. And this
| > limitation may differ according to machine's hardware condition and
overall
| > performance. So based on my local test, the limitation is 10
milliseconds,
| > while you got the 15 milliseconds on your side. And we can even use the
| > System.Threading.Timer to reproduce such behavior. Also, such a small
| > sleep span (like 1 millisecond) is not quite reasonable for common
| > applications, what's your application's detailed code logic?
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | Thread-Topic: Threading Question
| > | thread-index: AcXvutnC86vNNgVuSR62EidVO3NGmQ==
| > | X-WBNR-Posting-Host: 81.208.74.179
| > | From: =?Utf-8?B?TW9yaUNyaXN0aWFu?= <CristianMori@xxxxxxxxxxxxx>
| > | Subject: Threading Question
| > | Date: Tue, 22 Nov 2005 15:17:04 -0800
| > | Lines: 33
| > | Message-ID: <8F6C013C-D17F-49B3-BB0A-3AEC1835C8FE@xxxxxxxxxxxxx>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.performance
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.performance:11016
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.performance
| > |
| > | Hi!
| > |
| > | I have a simple thread
| > |
| > | Thread myThread=new Thread(new ThreadStart(foo));
| > | .....
| > | void foo()
| > | {
| > | while (!bQuit)
| > | {
| > | //Do something
| > | }
| > | }
| > |
| > | However this thread run the 100% CPU
| > |
| > | if I do like that
| > | void foo()
| > | {
| > | while (!bQuit)
| > | {
| > | Thread.Sleep(1);
| > | //Do something
| > | }
| > | }
| > |
| > | The the CPU is low, however the thread sleep at least 15 msec and
then it
| > is
| > | not fast enought for my application.
| > |
| > | How can I solve this?
| > |
| > | regards
| > | Cristian Mori
| > |
| >
| >
|
.
- References:
- RE: Threading Question
- From: Steven Cheng[MSFT]
- RE: Threading Question
- From: MoriCristian
- RE: Threading Question
- Prev by Date: Shared Method and Thread Safe
- Next by Date: Re: Shared Method and Thread Safe
- Previous by thread: RE: Threading Question
- Next by thread: Re: Threading Question
- Index(es):