Use a rw_lock instead of a mutex.

This however doesn't seem to improve performance here.
Need to investigate lock contention I think.
This commit is contained in:
Fredrik Holmqvist 2012-07-30 17:21:18 +02:00
parent 45dc5c4664
commit f099314535
2 changed files with 11 additions and 11 deletions

View File

@ -610,14 +610,14 @@ __unused static void ifa_free(struct ifaddr *ifa) {}
__unused static void ifa_init(struct ifaddr *ifa) {}
__unused static void ifa_ref(struct ifaddr *ifa) {}
extern struct mtx ifnet_lock;
#define IFNET_LOCK_INIT()
#define IFNET_WLOCK() mtx_lock(&ifnet_lock)
#define IFNET_WUNLOCK() mtx_unlock(&ifnet_lock)
#define IFNET_RLOCK() IFNET_WLOCK()
#define IFNET_RLOCK_NOSLEEP() IFNET_WLOCK()
#define IFNET_RUNLOCK() IFNET_WUNLOCK()
#define IFNET_RUNLOCK_NOSLEEP() IFNET_WUNLOCK()
extern struct rw_lock ifnet_rwlock;
#define IFNET_LOCK_INIT() rw_lock_init(&ifnet_rwlock, "ifnet rwlock")
#define IFNET_WLOCK() rw_lock_write_lock(&ifnet_rwlock)
#define IFNET_WUNLOCK() rw_lock_write_unlock(&ifnet_rwlock)
#define IFNET_RLOCK() rw_lock_read_lock(&ifnet_rwlock)
#define IFNET_RLOCK_NOSLEEP() rw_lock_read_lock(&ifnet_rwlock)
#define IFNET_RUNLOCK() rw_lock_read_unlock(&ifnet_rwlock)
#define IFNET_RUNLOCK_NOSLEEP() rw_lock_read_unlock(&ifnet_rwlock)
struct ifnet *ifnet_byindex(u_short idx);
struct ifnet *ifnet_byindex_locked(u_short idx);

View File

@ -13,7 +13,7 @@
// these methods are bit unfriendly, a bit too much panic() around
struct mtx Giant;
struct mtx ifnet_lock;
struct rw_lock ifnet_rwlock;
struct mtx gIdStoreLock;
@ -48,7 +48,7 @@ status_t
init_mutexes()
{
mtx_init(&Giant, "Banana Giant", NULL, MTX_DEF);
mtx_init(&ifnet_lock, "gDevices", NULL, MTX_DEF);
rw_lock_init(&ifnet_rwlock, "gDevices");
mtx_init(&gIdStoreLock, "Identity Store", NULL, MTX_DEF);
return B_OK;
@ -59,6 +59,6 @@ void
uninit_mutexes()
{
mtx_destroy(&Giant);
mtx_destroy(&ifnet_lock);
rw_lock_destroy(&ifnet_rwlock);
mtx_destroy(&gIdStoreLock);
}