linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* futex and timeouts
@ 2002-03-13 18:26 Hubertus Franke
  2002-03-13 18:54 ` Ulrich Drepper
  2002-03-14  4:15 ` Rusty Russell
  0 siblings, 2 replies; 14+ messages in thread
From: Hubertus Franke @ 2002-03-13 18:26 UTC (permalink / raw)
  To: drepper; +Cc: rusty, matthew, linux-kernel, lse-tech


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)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-03-18 21:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-13 18:26 futex and timeouts Hubertus Franke
2002-03-13 18:54 ` Ulrich Drepper
2002-03-14  4:15 ` Rusty Russell
2002-03-14 15:19   ` Hubertus Franke
2002-03-15  5:39     ` [PATCH] " Rusty Russell
2002-03-15  6:08       ` Joel Becker
2002-03-15  6:56         ` H. Peter Anvin
2002-03-15  8:49         ` Rusty Russell
2002-03-15 15:16         ` Hubertus Franke
2002-03-15 16:04           ` Joel Becker
2002-03-15 18:59             ` Hubertus Franke
2002-03-15 19:28               ` Joel Becker
2002-03-16  1:12                 ` [Lse-tech] " george anzinger
2002-03-18 21:35                   ` Hubertus Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).