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