Skip to contentSkip to conversation

How to wake_up the wait_queue of a socket?

DISCUSSION horseriver 3 participants 6 messages Jan 14, 2013 – Jan 19, 2013

lore
Share & tools
lore

horseriver

author
#0 lore raw

hi:

When one datagram has reached , How to wake_up the wait_queue of that socket ?

Thanks!

author
#2 lore raw
In reply to Valdis.Kletnieks at vt.edu
Quoted 6 lines · Valdis.Kletnieks at vt.edu
Quoted 1 line · horseriver

When one datagram has reached , How to wake_up the wait_queue of that socket ?

Please clarify your question - I'm not sure which of the following you mean:

1) How does the kernel wake up the waiting process when a datagram arrives?

This is my mean !

Thanks

#1 lore raw
In reply to horseriver
Quoted 1 line · horseriver

When one datagram has reached , How to wake_up the wait_queue of that socket ?

Please clarify your question - I'm not sure which of the following you mean:

1) How does the kernel wake up the waiting process when a datagram arrives?

2) My kernel is failing to wake up the process, how do I fix it?

3) The kernel is waking the process up, but with high latency and I want to speed it up.

4) I'm trying to wake up a process for some reason when a datagram arrives (in which case, you're probably doing something wrong and we need to discuss what you're trying to achieve)

Let us know in more detail what you wanted to know....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130115/227db625/attachment.bin

#3 lore raw
In reply to horseriver

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.

hope I have not made any mistake in my logic?

Quoted 22 lines · horseriver
Quoted 3 lines · Valdis.Kletnieks at vt.edu
Quoted 1 line · horseriver

When one datagram has reached , How to wake_up the wait_queue of

that socket ?

Quoted 2 lines

Please clarify your question - I'm not sure which of the following you

mean:

Quoted 1 line

1) How does the kernel wake up the waiting process when a datagram arrives?

This is my mean !

Thanks

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 5 lines
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130118/f7d51275/attachment.html 
author
#4 lore raw
Quoted 7 lines · Peter Teoh

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 ?

Quoted 11 lines
Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
Regards,
Peter Teoh
#5 lore raw
Quoted 7 lines · horseriver
Quoted 3 lines · Peter Teoh

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,

Quoted 1 line

so that when the scheduler next selection of runnable process will pick

him

Quoted 9 lines
Quoted 3 lines

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

Quoted 12 lines
Quoted 11 lines
Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

--
Regards,
Peter Teoh

Signature · 5 lines
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130119/04a27719/attachment.html