does block means thread sleep

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
R

Ryan Liu

Hi,

Some network methods will block until data available, does this mean this
thread will yield to other thread while it is waiting for hardware signal?

If so, difference between BeginRead() and Read() maybe isn't so important?

Thanks a lot!
Ryan
 
Ryan Liu said:
Some network methods will block until data available, does this mean this
thread will yield to other thread while it is waiting for hardware signal?

Yes. If a thread is blocked on i/o, it's not runnable and consumes no CPU
time. Note that this applies only to true blocking on i/o. In some cases,
a thread might be polling to continually check to see if some i/o state has
changed...in this case, the thread isn't really blocked (at very low levels,
this may happen naturally for certain hardware drivers...it's very bad form
in any application-level code :) ).

Network APIs in particular do block on i/o and don't run until the i/o has
completed.
If so, difference between BeginRead() and Read() maybe isn't so important?

The difference is very important. But not for the reason you apparently
thought. :)

Pete
 
Ryan said:
Hi,

Some network methods will block until data available, does this mean this
thread will yield to other thread while it is waiting for hardware signal?

If so, difference between BeginRead() and Read() maybe isn't so important?

Thanks a lot!
Ryan

what should it do if not sleep ?
there isn' t much different between beginread and read, if what you
want to do is to read. There are atleast 2 more processing procedures
(:-D) implemented after the beginread: acessing file, moving pointers
around to process, etc. But you see the return value by both more
infor.
I hope that if processing file is sure to take place, the earlier the
process, the more space savings the computer can make because it has to
pay the running costs for the current file system that is within
latency (2 periods in my system). My system doesn't evaluate the round
trip time on the scale of each units obtained but similar to many other
systems in current use around, it is based on the whole period of
running which is devided into 2 for each trip. The due for time
calculation is around the last point of the second round when the
packet arrive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top