lkml.org 
[lkml]   [2009]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v4] introduce macro spin_event_timeout()
    From
    On Thu, Mar 12, 2009 at 9:54 AM, Timur Tabi <timur@freescale.com> wrote:
    > On Wed, Mar 11, 2009 at 9:45 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
    >
    >>> The other big advantage of that approach is that drivers that aren't in
    >>> an atomic section can use msleep() and allow the kernel to schedule on
    >>> that processor.
    >>
    >> Ack!  I totally agree.
    >
    > I'm glad everyone agrees.  I still don't know how to solve the
    > problem, though.  I came up with this:
    >
    > #define spin_until_timeout(condition, timeout)          \
    >       for (unsigned long __timeout = jiffies + (timeout);     \
    >               (!(condition) && time_after(jiffies, __timeout)); )
    >
    > Now how do I modify this so that the caller knows whether the loop
    > terminated because of a timeout or the condition became true?

    How about this:

    #define spin_until_timeout(condition, timeout, rc) \
    for (unsigned long __timeout = jiffies + (timeout); \
    (!(rc = (condition)) && time_after(jiffies, __timeout)); )

    g.

    --
    Grant Likely, B.Sc., P.Eng.
    Secret Lab Technologies Ltd.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2009-03-12 17:05    [W:0.021 / U:1.096 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site