Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libshmif introduce a sleep to trying to gra...
details: https://anonhg.NetBSD.org/src/rev/ecd13f84221b
branches: trunk
changeset: 757120:ecd13f84221b
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Aug 15 18:47:38 2010 +0000
description:
introduce a sleep to trying to grab the bus
diffstat:
sys/rump/net/lib/libshmif/shmif_busops.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diffs (50 lines):
diff -r 6c32c66781fe -r ecd13f84221b sys/rump/net/lib/libshmif/shmif_busops.c
--- a/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:40:41 2010 +0000
+++ b/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:47:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shmif_busops.c,v 1.2 2010/08/13 10:13:44 pooka Exp $ */
+/* $NetBSD: shmif_busops.c,v 1.3 2010/08/15 18:47:38 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.2 2010/08/13 10:13:44 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.3 2010/08/15 18:47:38 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -44,6 +44,7 @@
#define LOCK_UNLOCKED 0
#define LOCK_LOCKED 1
+#define LOCK_COOLDOWN 1001
/*
* This locking needs work and will misbehave severely if:
@@ -53,10 +54,21 @@
void
shmif_lockbus(struct shmif_mem *busmem)
{
+ int i = 0;
- while (atomic_cas_32(&busmem->shm_lock,
- LOCK_UNLOCKED, LOCK_LOCKED) == LOCK_LOCKED)
+ while (__predict_false(atomic_cas_32(&busmem->shm_lock,
+ LOCK_UNLOCKED, LOCK_LOCKED) == LOCK_LOCKED)) {
+ if (__predict_false(++i > LOCK_COOLDOWN)) {
+ uint64_t sec, nsec;
+ int error;
+
+ sec = 0;
+ nsec = 1000*1000; /* 1ms */
+ rumpuser_nanosleep(&sec, &nsec, &error);
+ i = 0;
+ }
continue;
+ }
membar_enter();
}
Home |
Main Index |
Thread Index |
Old Index