Professional Web Applications Themes

how long will select function be timeout when the last argument is set to NULL?? - UNIX Programming

The last argument is timeval which set timeout for it. If it is not set ,that is it is NULL, how long will select return ??? Thanks....

  1. #1

    Default how long will select function be timeout when the last argument is set to NULL??

    The last argument is timeval which set timeout for it. If it is not
    set ,that is it is NULL, how long will select return ???
    Thanks.
    hushui Guest

  2. #2

    Default Re: how long will select function be timeout when the last argumentis set to NULL??

    com (hushui) writes:
     

    It will wait forever, if nothing happens.

    --
    Måns Rullgård
    sf.net
    Måns Guest

  3. #3

    Default Re: how long will select function be timeout when the last argumentis set to NULL??



    hushui wrote: 

    If the timeval argument is NULL then select will block until there
    is an EINTR or until there is activity on one of the montored sockets.
    It does tell you this on the man page.

    --

    Fletcher Glenn

    Fletcher Guest

  4. #4

    Default Re: how long will select function be timeout when the last argument isset to NULL??

    hushui wrote: 

    From the (Solaris) man page:

    "[...] If the timeout argument is a null pointer,
    select() blocks until an event causes one of the masks
    to be returned with a valid (non-zero) value. [...]"

    "[...] If the readfs, writefs, and errorfds arguments
    are all null pointers and the timeout argument is a
    null pointer, select() blocks until interrupted by a
    signal. [...]"

    In short: If no timeout is specified, select() waits indefinitely
    until "something happens."

    --
    com
    Eric Guest

  5. #5

    Default Re: how long will select function be timeout when the last argument is set to NULL??

    In article <google.com>, hushui wrote: 

    From POSIX:

    If the timeout parameter is a null pointer, then the call
    to pselect() or select() shall block indefinitely until at
    least one descriptor meets the specified criteria.
    [...]
    If the readfds, writefds, and errorfds arguments are all
    null pointers and the timeout argument is a null pointer,
    the pselect() or select() function shall block until
    interrupted by a signal.

    --
    Andreas Kähäri
    Andreas Guest

  6. #6

    Default Re: how long will select function be timeout when the last argument is set to NULL??

    >>> Andreas Kahari wrote:
     
    >From POSIX:[/ref]
    AK> If the timeout parameter is a null pointer, then the call
    AK> to pselect() or select() shall block indefinitely until at
    AK> least one descriptor meets the specified criteria.

    Except this, POSIX says another clarification to its blocking "indefinitely":

    ==={{{
    Implementations may place limitations on the maximum timeout
    interval supported. All implementations shall support a maximum
    timeout interval of at least 31 days. If the timeout argument
    specifies a timeout interval greater than the
    implementation-defined maximum value, the maximum value shall be
    used as the actual timeout value.
    ===}}}

    In practice, even this isn't enough. BSD implementation of select()
    allows awakening of _all_ select()s over the whole system if awakening
    event is happening on an object where two different tasks called select()
    or poll() simultaneously (this is named "select collision").
    FreeBSD reflects number of such collisions in sysctl OID "kern.nselcoll";
    on high-loaded system its value is nonzero quite often.

    So, one should assume select() allows spurious wakeups.


    -netch-
    Valentin Guest

  7. #7

    Default Re: how long will select function be timeout when the last argument is set to NULL??

    Valentin Nechayev <kiev.ua> writes:
     [/ref]

    > >From POSIX:[/ref]
    > AK> If the timeout parameter is a null pointer, then the call
    > AK> to pselect() or select() shall block indefinitely until at
    > AK> least one descriptor meets the specified criteria.
    >
    > Except this, POSIX says another clarification to its blocking
    > "indefinitely":
    >
    > ==={{{
    > Implementations may place limitations on the maximum timeout
    > interval supported. All implementations shall support a maximum
    > timeout interval of at least 31 days. If the timeout argument
    > specifies a timeout interval greater than the
    > implementation-defined maximum value, the maximum value shall be
    > used as the actual timeout value.
    > ===}}}[/ref]

    This describes the behavior of a non-null timeout pointer, that is,
    the maximum timeout that can be set. This is different than passing a
    null timeout pointer.

    Although I'm pretty sure that the description inadvertently left out
    mentioning signals as something that would interrupt select. It
    specifies that earlier on in the standard, so I'm assuming the quoted
    section is in error in that regard.
     

    That goodness of that design isn't intuitively obvious. Any idea why
    they'd wakeup all selects in the whole system because two differen
    processes were waiting on the same thing?

    Joe
    joe@invalid.address Guest

  8. #8

    Default Re: how long will select function be timeout when the last argument is set to NULL??

    >>> address wrote:
     [/ref]
     

    This is true for second clause in cited paragraph, but not mandatory reading
    for first one (at least for me, not native speaker).
    OTOH, it is really easier to make indefinite timeout than to make timeout
    which, e.g., requires 2 full cycles of `jiffies' (Linux style).
     

    Signals are mentioned in this page.
     
    > That goodness of that design isn't intuitively obvious. Any idea why
    > they'd wakeup all selects in the whole system because two differen
    > processes were waiting on the same thing?[/ref]

    Object hasn't list of pointers to waiting tasks, but only one entry.
    When two tasks select()s on one object for the same event, collision is
    recorded with special flag.
    Canonical book ("Design and implementation of 4.4BSD operating system")
    says that such decision was made conciously because simultaneous waiting
    for the same event on the same object is too rare case.


    -netch-
    Valentin Guest

  9. #9

    Default Re: how long will select function be timeout when the last argument is set to NULL??

    Valentin Nechayev <kiev.ua> writes:
     [/ref]
    > [/ref]

    >
    > This is true for second clause in cited paragraph, but not mandatory
    > reading for first one (at least for me, not native speaker). OTOH,
    > it is really easier to make indefinite timeout than to make timeout
    > which, e.g., requires 2 full cycles of `jiffies' (Linux style).[/ref]

    Well, your English is a lot better than my Russian :-) [1]

    The way I read it:

    "If the timeout parameter is not a null pointer, it specifies a
    maximum interval to wait for the selection to complete. If the
    specified time interval expires without any requested operation
    becoming ready, the function shall return. If the timeout parameter
    is a null pointer, then the call to pselect() or select() shall
    block indefinitely until at least one descriptor meets the
    specified criteria."

    Means if a timeout is set (non-null timeout pointer), then some
    maximum timeout applies, which brings in the paragraph you quoted. If
    a timeout is not set (null timeout pointer) then there is no timeout,
    so there can't be any maximum timeout.
     
    >
    > Signals are mentioned in this page.[/ref]

    Yes, but not in the sentence that says "If the timeout parameter is a
    null pointer, then the call to pselect() or select() shall block
    indefinitely until at least one descriptor meets the specified
    criteria.". I would have expected it to be specified there as well. I
    don't speak standardese very well though.
     
    > > That goodness of that design isn't intuitively obvious. Any idea why
    > > they'd wakeup all selects in the whole system because two differen
    > > processes were waiting on the same thing?[/ref]
    >
    > Object hasn't list of pointers to waiting tasks, but only one entry.
    > When two tasks select()s on one object for the same event, collision
    > is recorded with special flag. Canonical book ("Design and
    > implementation of 4.4BSD operating system") says that such decision
    > was made conciously because simultaneous waiting for the same event
    > on the same object is too rare case.[/ref]

    Interesting, it doesn't sound standard though. Of course, the standard
    isn't something that can be blindly depended on (yet) though.

    Joe

    [1] Ya uchil mnogo let nazad, i c tex por ochen' mnogo zabyl
    joe@invalid.address Guest

Similar Threads

  1. Question about a long session timeout (somewhat long)
    By Stupid48 in forum ASP.NET Security
    Replies: 7
    Last Post: March 1st, 10:04 PM
  2. grep argument list too long...how to get around it?
    By Steve Grazzini in forum PERL Beginners
    Replies: 9
    Last Post: November 1st, 10:05 PM
  3. passing argument to function
    By subedimadhav@yahoo.c in forum Macromedia Flex General Discussion
    Replies: 4
    Last Post: May 30th, 11:11 AM
  4. Using a datafield value as a function argument
    By Dave in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: December 2nd, 04:01 PM
  5. struct as an argument of a function
    By Öznur in forum PERL Beginners
    Replies: 7
    Last Post: February 23rd, 06:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139