Thread.Sleep(0) action?
-
Does Thread.Sleep(0) allow the time slicer to start the next thread straight away or does it just idle the cpu in the existing thread until the next thread is scheduled to start? Thanks, Bruce :confused:
-
Does Thread.Sleep(0) allow the time slicer to start the next thread straight away or does it just idle the cpu in the existing thread until the next thread is scheduled to start? Thanks, Bruce :confused:
-
That is how I had interpreted the MSDN info but my hardware vendor is telling me that the balance of the thread time idles the cpu before relinquishing the thread. Does anybody know if the time slicer can detect this sleep(0) to switch the time slice early?
-
That is how I had interpreted the MSDN info but my hardware vendor is telling me that the balance of the thread time idles the cpu before relinquishing the thread. Does anybody know if the time slicer can detect this sleep(0) to switch the time slice early?
Bruce Coward wrote:
my hardware vendor is telling me that the balance of the thread time idles the cpu
that is nonsense. Every Thread.Sleep tells the scheduler to go and reschedule threads, i.e. continue working on the highest-priority ready thread; if the caller happens to be the only ready thread, it will continue working immediately. A scheduler is not supposed to idle until a tick occurs, when there is work to do (i.e. there are ready threads), then at least some of it should be taken on immediately. What would be the point to halt the CPU till the end of the current tick??? I have developed my share of embedded operating systems, and used some commercial ones, I've never seen one that deliberately did nothing for a while, not even Windows. :-D :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:14 AM
-
Bruce Coward wrote:
my hardware vendor is telling me that the balance of the thread time idles the cpu
that is nonsense. Every Thread.Sleep tells the scheduler to go and reschedule threads, i.e. continue working on the highest-priority ready thread; if the caller happens to be the only ready thread, it will continue working immediately. A scheduler is not supposed to idle until a tick occurs, when there is work to do (i.e. there are ready threads), then at least some of it should be taken on immediately. What would be the point to halt the CPU till the end of the current tick??? I have developed my share of embedded operating systems, and used some commercial ones, I've never seen one that deliberately did nothing for a while, not even Windows. :-D :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:14 AM
Luc Pattyn wrote:
I've never seen one that deliberately did nothing for a while
What about virtually nothing? :-D
-
Bruce Coward wrote:
my hardware vendor is telling me that the balance of the thread time idles the cpu
that is nonsense. Every Thread.Sleep tells the scheduler to go and reschedule threads, i.e. continue working on the highest-priority ready thread; if the caller happens to be the only ready thread, it will continue working immediately. A scheduler is not supposed to idle until a tick occurs, when there is work to do (i.e. there are ready threads), then at least some of it should be taken on immediately. What would be the point to halt the CPU till the end of the current tick??? I have developed my share of embedded operating systems, and used some commercial ones, I've never seen one that deliberately did nothing for a while, not even Windows. :-D :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:14 AM
Hi Luc, your reply makes more sense to me. Cheers, Bruce :thumbsup:
-
Luc Pattyn wrote:
I've never seen one that deliberately did nothing for a while
What about virtually nothing? :-D
PIEBALDconsult wrote:
virtually nothing?
The future method Thread.Doze() is scheduled for introduction in .NET 4.5 :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:14 AM
-
PIEBALDconsult wrote:
virtually nothing?
The future method Thread.Doze() is scheduled for introduction in .NET 4.5 :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:14 AM
I was hoping for
Thread.Winks ( 40 ) ;
Oh, wait, I could use an Extension Method for that... obfuscation here I come!