<br><br><div class="gmail_quote">On Sat, Jan 19, 2013 at 1:36 AM, horseriver <span dir="ltr"><<a href="mailto:horserivers@gmail.com" target="_blank">horserivers@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Fri, Jan 18, 2013 at 10:18:19AM +0800, Peter Teoh wrote:<br>
> essentially, when the packet arrive, it will be assigned to the correct<br>
> process based on IP address + port matching, and then the corresponding<br>
> process's blocked scheduling status will be changed to continue execution,<br>
> so that when the scheduler next selection of runnable process will pick him<br>
> out for continue execution. The process will then pick his data up from<br>
> the network queue.<br>
><br>
<br>
</div> Thanks!<br>
<br>
If there is no event occured on one socket descriptor ,<br>
will the poll operation on this socket descriptor be blocked ?<br></blockquote><div><br></div><div>I/O mechanism have two types: blocking and non-blocking. by definition: poll is non-blocking, and select() is blocking. In general that is true for kernel source as well.</div>
<div><br></div><div>For details and implementations there may be ambiguity. </div><div><br></div><div>For eg, manpage say poll may has a timeout for blocking, and inside the kernel source:</div><div><br></div><div>in fs/select.c's definition for select() syscall:</div>
<div><br></div><div><div>SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp,</div><div> fd_set __user *, exp, struct timeval __user *, tvp)</div><div>{</div><div> struct timespec end_time, *to = NULL;</div>
<div> struct timeval tv;</div><div> int ret;</div><div><br></div><div> if (tvp) {</div><div> if (copy_from_user(&tv, tvp, sizeof(tv)))</div><div> return -EFAULT;</div>
<div><br></div><div> to = &end_time;</div><div> if (poll_select_set_timeout(to,</div><div> tv.tv_sec + (tv.tv_usec / USEC_PER_SEC),</div><div> (tv.tv_usec % USEC_PER_SEC) * NSEC_PER_USEC))</div>
<div> return -EINVAL;</div><div> }</div><div><br></div><div> ret = core_sys_select(n, inp, outp, exp, to);</div><div> ret = poll_select_copy_remaining(&end_time, tvp, 1, ret);</div>
<div><br></div></div><div><br></div><div>And for syscall of poll() (same file):</div><div><br></div><div><div>SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,</div><div> long, timeout_msecs)</div>
<div>{</div><div> struct timespec end_time, *to = NULL;</div><div> int ret;</div><div><br></div><div> if (timeout_msecs >= 0) {</div><div> to = &end_time;</div><div> poll_select_set_timeout(to, timeout_msecs / MSEC_PER_SEC,</div>
<div> NSEC_PER_MSEC * (timeout_msecs % MSEC_PER_SEC));</div><div> }</div></div><div><br></div><div>So there is this common file poll_select_set_timeout() called by both....the details is even more confusing - shall stop here.</div>
<div><br></div><div>A good article on epoll etc:</div><div><br></div><div><a href="http://www.eecs.berkeley.edu/~sangjin/2012/12/21/epoll-vs-kqueue.html">http://www.eecs.berkeley.edu/~sangjin/2012/12/21/epoll-vs-kqueue.html</a></div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">> > _______________________________________________<br>
> > Kernelnewbies mailing list<br>
> > <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
> > <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
> ><br>
><br>
><br>
><br>
> --<br>
> Regards,<br>
> Peter Teoh<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh