From af019b5030106663bb4afcefdca9a304ea063f31 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 18 Mar 2004 02:53:15 +0000 Subject: 2004-03-17 Marcus Brinkmann * sysdeps/l4/pt-spin.c (_pthread_spin_lock): Implement using new time period interface. --- sysdeps/l4/pt-spin.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sysdeps/l4/pt-spin.c') diff --git a/sysdeps/l4/pt-spin.c b/sysdeps/l4/pt-spin.c index 355253e..d2917d6 100644 --- a/sysdeps/l4/pt-spin.c +++ b/sysdeps/l4/pt-spin.c @@ -40,9 +40,10 @@ _pthread_spin_lock (__pthread_spinlock_t *lock) { l4_time_t timeout; int i; - - timeout.period.m = 1; - timeout.period.e = 1; + + /* Start with a small timeout of 2 microseconds, then back off + exponentially. */ + timeout = l4_time_period (2); while (1) { @@ -51,9 +52,11 @@ _pthread_spin_lock (__pthread_spinlock_t *lock) if (__pthread_spin_trylock (lock) == 0) return 0; } - /* FIXME verify this */ - l4_receive_timeout (l4_nilthread, timeout); - timeout.period.e++; + l4_sleep (timeout); + + timeout = l4_time_mul2 (timeout); + if (timeout == L4_NEVER) + timeout = L4_TIME_PERIOD_MAX; } } -- cgit v1.2.3