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

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;
break;
}
if (!timeout) {
schedule();
current->state = TASK_INTERRUPTIBLE;
continue;
}
delay = schedule_timeout(timeout);
if (delay == 0) {
retval = -EAGAIN;
break;
}
current->state = TASK_INTERRUPTIBLE;
timeout -= delay;
}
current->state = TASK_RUNNING;
unqueue_me(&q);
/* 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 (frankeh@watson.ibm.com)
-
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: 2005-03-22 13:24    [W:0.061 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site