<br><br><div class="gmail_quote">On Sat, Jan 19, 2013 at 1:36 AM, horseriver <span dir="ltr">&lt;<a href="mailto:horserivers@gmail.com" target="_blank">horserivers@gmail.com</a>&gt;</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>
&gt; essentially, when the packet arrive, it will be assigned to the correct<br>
&gt; process based on IP address + port matching, and then the corresponding<br>
&gt; process&#39;s blocked scheduling status will be changed to continue execution,<br>
&gt; so that when the scheduler next selection of runnable process will pick him<br>
&gt; out for continue execution.   The process will then pick his data up from<br>
&gt; the network queue.<br>
&gt;<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&#39;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(&amp;tv, tvp, sizeof(tv)))</div><div>                        return -EFAULT;</div>
<div><br></div><div>                to = &amp;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(&amp;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 &gt;= 0) {</div><div>                to = &amp;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">&gt; &gt; _______________________________________________<br>
&gt; &gt; Kernelnewbies mailing list<br>
&gt; &gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt; &gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt; &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Regards,<br>
&gt; Peter Teoh<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh