[lkml]   [2002]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subjectfutex and timeouts

    Ulrich, it seems to me that absolute timeouts are the easiest to do.

    (a) expand by additional parameter (0) means no timeout desired
    (b) differentiate the schedule call in futex_down..

    Question is whether the granularity of jiffies (10ms) is sufficiently small
    for timeouts.....

    Rusty, take a look, wether there's something wrong with this and see whether
    you can integrate it or improve and integrate it.

    /* Simplified from arch/ppc/kernel/semaphore.c: Paul M. is a genius. */
    static int futex_down(struct list_head *head, struct page *page, int offset,
    signed long timeout)
    int retval = 0;
    struct futex_q q;

    current->state = TASK_INTERRUPTIBLE;
    queue_me(head, &q, page, offset);

    while (!decrement_to_zero(page, offset)) {
    if (signal_pending(current)) {
    retval = -EINTR;
    if (!timeout) {
    current->state = TASK_INTERRUPTIBLE;
    delay = schedule_timeout(timeout);
    if (delay == 0) {
    retval = -EAGAIN;
    current->state = TASK_INTERRUPTIBLE;
    timeout -= delay;
    current->state = TASK_RUNNING;
    /* If we were signalled, we might have just been woken: we
    must wake another one. Otherwise we need to wake someone
    else (if they are waiting) so they drop the count below 0,
    and when we "up" in userspace, we know there is a
    waiter. */
    wake_one_waiter(head, page, offset);
    return retval;

    -- Hubertus Franke (
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:24    [W:0.022 / U:38.124 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site