* minor cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19526 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2006-12-15 22:41:35 +00:00
parent d881c6ba5c
commit 2ba6b3a649

View File

@ -210,8 +210,9 @@ MultiLocker::WriteLock()
if (readers > 0) { if (readers > 0) {
//readers hold the lock - acquire fWriteSem //readers hold the lock - acquire fWriteSem
locked = (acquire_sem_etc(fWriteSem, readers, B_DO_NOT_RESCHEDULE, locked = (acquire_sem_etc(fWriteSem, readers,
B_INFINITE_TIMEOUT) == B_OK); B_DO_NOT_RESCHEDULE,
B_INFINITE_TIMEOUT) == B_OK);
} }
if (locked) { if (locked) {
ASSERT(fWriterThread == -1); ASSERT(fWriterThread == -1);
@ -301,7 +302,8 @@ MultiLocker::WriteUnlock()
//increment fReadCount by a large number //increment fReadCount by a large number
//this will let new readers acquire the read lock //this will let new readers acquire the read lock
//retrieve the number of current waiters //retrieve the number of current waiters
int32 readersWaiting = atomic_add(&fReadCount, LARGE_NUMBER) + LARGE_NUMBER; int32 readersWaiting = atomic_add(&fReadCount, LARGE_NUMBER)
+ LARGE_NUMBER;
if (readersWaiting > 0) { if (readersWaiting > 0) {
//readers are waiting to acquire the lock //readers are waiting to acquire the lock
@ -373,7 +375,7 @@ MultiLocker::IsWriteLocked(uint32 *the_stack_base, thread_id *the_thread)
//this is managed by taking the address of the item on the //this is managed by taking the address of the item on the
//stack and dividing it by the size of the memory pages //stack and dividing it by the size of the memory pages
//if it is the same as the cached stack_page, there is a match //if it is the same as the cached stack_page, there is a match
stack_base = (uint32) &write_lock_holder/B_PAGE_SIZE; stack_base = (uint32)&write_lock_holder / B_PAGE_SIZE;
if (fWriterStackBase == stack_base) { if (fWriterStackBase == stack_base) {
write_lock_holder = true; write_lock_holder = true;
} else { } else {
@ -413,8 +415,10 @@ MultiLocker::IsReadLocked()
#if DEBUG #if DEBUG
//determine if the lock is actually held //determine if the lock is actually held
thread_id thread = find_thread(NULL); thread_id thread = find_thread(NULL);
if (fDebugArray[thread % fMaxThreads] > 0) locked = true; if (fDebugArray[thread % fMaxThreads] > 0)
else locked = false; locked = true;
else
locked = false;
#endif #endif
return locked; return locked;