Module Name: src
Committed By: pooka
Date: Sun Aug 15 18:47:39 UTC 2010
Modified Files:
src/sys/rump/net/lib/libshmif: shmif_busops.c
Log Message:
introduce a sleep to trying to grab the bus
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libshmif/shmif_busops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/net/lib/libshmif/shmif_busops.c
diff -u src/sys/rump/net/lib/libshmif/shmif_busops.c:1.2 src/sys/rump/net/lib/libshmif/shmif_busops.c:1.3
--- src/sys/rump/net/lib/libshmif/shmif_busops.c:1.2 Fri Aug 13 10:13:44 2010
+++ src/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:47:38 2010
@@ -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();
}