Author: axeld Date: 2009-10-19 02:16:54 +0200 (Mon, 19 Oct 2009) New Revision: 33647 Changeset: http://dev.haiku-os.org/changeset/33647/haiku Modified: haiku/trunk/headers/private/kernel/lock.h haiku/trunk/src/system/kernel/lock.cpp Log: * Reverted r33643 - while it doubled the performance for my test case (with high contention of the read lock (I experimented with the VM page mapping lock)), it actually hurt the compile performance pretty obviously. Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2009-10-19 00:07:59 UTC (rev 33646) +++ haiku/trunk/headers/private/kernel/lock.h 2009-10-19 00:16:54 UTC (rev 33647) @@ -42,7 +42,6 @@ typedef struct rw_lock { const char* name; - mutex lock; struct rw_lock_waiter* waiters; thread_id holder; int32 reader_count; @@ -86,8 +85,7 @@ # define RECURSIVE_LOCK_INITIALIZER(name) { MUTEX_INITIALIZER(name), -1, 0 } #endif -#define RW_LOCK_INITIALIZER(name) { name, MUTEX_INITIALIZER(name), \ - NULL, -1, 0, 0, 0 } +#define RW_LOCK_INITIALIZER(name) { name, NULL, -1, 0, 0, 0 } #if KDEBUG Modified: haiku/trunk/src/system/kernel/lock.cpp =================================================================== --- haiku/trunk/src/system/kernel/lock.cpp 2009-10-19 00:07:59 UTC (rev 33646) +++ haiku/trunk/src/system/kernel/lock.cpp 2009-10-19 00:16:54 UTC (rev 33647) @@ -164,10 +164,6 @@ lock->waiters->last = &waiter; - InterruptsSpinLocker locker(gThreadSpinlock); - - _mutex_unlock(&lock->lock, true); - // block thread_prepare_to_block(waiter.thread, 0, THREAD_BLOCK_TYPE_RW_LOCK, lock); return thread_block_locked(waiter.thread); @@ -194,7 +190,6 @@ lock->holder = waiter->thread->id; // unblock thread - InterruptsSpinLocker locker(gThreadSpinlock); thread_unblock_locked(waiter->thread, B_OK); } return; @@ -210,7 +205,6 @@ lock->reader_count++; // unblock thread - InterruptsSpinLocker locker(gThreadSpinlock); thread_unblock_locked(waiter->thread, B_OK); } } @@ -227,8 +221,6 @@ lock->owner_count = 0; lock->flags = 0; - mutex_init(&lock->lock, name); - T_SCHEDULING_ANALYSIS(InitRWLock(lock, name)); NotifyWaitObjectListeners(&WaitObjectListener::RWLockInitialized, lock); } @@ -245,8 +237,6 @@ lock->owner_count = 0; lock->flags = flags & RW_LOCK_FLAG_CLONE_NAME; - mutex_init(&lock->lock, lock->name); - T_SCHEDULING_ANALYSIS(InitRWLock(lock, name)); NotifyWaitObjectListeners(&WaitObjectListener::RWLockInitialized, lock); } @@ -262,8 +252,8 @@ InterruptsSpinLocker locker(gThreadSpinlock); #if KDEBUG - if (lock->waiters != NULL - && thread_get_current_thread_id() != lock->holder) { + if (lock->waiters != NULL && thread_get_current_thread_id() + != lock->holder) { panic("rw_lock_destroy(): there are blocking threads, but the caller " "doesn't hold the write lock (%p)", lock); @@ -285,7 +275,6 @@ lock->name = NULL; locker.Unlock(); - mutex_destroy(&lock->lock); free(name); } @@ -297,7 +286,7 @@ #if KDEBUG_RW_LOCK_DEBUG return rw_lock_write_lock(lock); #else - MutexLocker locker(lock->lock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->writer_count == 0) { lock->reader_count++; @@ -308,8 +297,6 @@ return B_OK; } - locker.Detach(); - return rw_lock_wait(lock, false); #endif } @@ -321,7 +308,7 @@ #if KDEBUG_RW_LOCK_DEBUG return rw_lock_write_unlock(lock); #else - MutexLocker locker(lock->lock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->holder == thread_get_current_thread_id()) { if (--lock->owner_count > 0) @@ -351,7 +338,7 @@ status_t rw_lock_write_lock(rw_lock* lock) { - MutexLocker locker(lock->lock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->reader_count == 0 && lock->writer_count == 0) { lock->writer_count++; @@ -365,7 +352,6 @@ } lock->writer_count++; - locker.Detach(); status_t status = rw_lock_wait(lock, true); if (status == B_OK) { @@ -379,7 +365,7 @@ status_t rw_lock_write_unlock(rw_lock* lock) { - MutexLocker locker(lock->lock); + InterruptsSpinLocker locker(gThreadSpinlock); if (thread_get_current_thread_id() != lock->holder) { panic("rw_lock_write_unlock(): lock %p not write-locked by this thread",