Changeset 26257
- Timestamp:
- 07/04/08 20:17:00 (5 months ago)
- Location:
- haiku/branches/developer/bonefish/vm
- Files:
-
- 2 modified
-
headers/private/kernel/lock.h (modified) (3 diffs)
-
src/system/kernel/lock.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/branches/developer/bonefish/vm/headers/private/kernel/lock.h
r25691 r26257 53 53 54 54 55 #if 0 && KDEBUG // XXX disable this for now, it causes problems when including thread.h here56 # include <thread.h>57 #define ASSERT_LOCKED_RECURSIVE(r) { ASSERT(thread_get_current_thread_id() == (r)->holder); }58 # define ASSERT_LOCKED_MUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); }55 #if KDEBUG 56 # define ASSERT_LOCKED_RECURSIVE(r) \ 57 { ASSERT(find_thread(NULL) == (r)->lock.holder); } 58 # define ASSERT_LOCKED_MUTEX(m) { ASSERT(find_thread(NULL) == (m)->holder); } 59 59 #else 60 # define ASSERT_LOCKED_RECURSIVE(r)61 # define ASSERT_LOCKED_MUTEX(m)60 # define ASSERT_LOCKED_RECURSIVE(r) do {} while (false) 61 # define ASSERT_LOCKED_MUTEX(m) do {} while (false) 62 62 #endif 63 63 … … 101 101 extern void mutex_init_etc(mutex* lock, const char* name, uint32 flags); 102 102 extern void mutex_destroy(mutex* lock); 103 extern status_t mutex_switch_lock(mutex* from, mutex* to); 104 // Unlocks "from" and locks "to" such that unlocking and starting to wait 105 // for the lock is atomically. I.e. if "from" guards the object "to" belongs 106 // to, the operation is safe as long as "from" is held while destroying 107 // "to". 103 108 104 109 // implementation private: 105 110 extern status_t _mutex_lock(mutex* lock, bool threadsLocked); 106 extern void _mutex_unlock(mutex* lock );111 extern void _mutex_unlock(mutex* lock, bool threadsLocked); 107 112 extern status_t _mutex_trylock(mutex* lock); 108 113 … … 150 155 mutex_unlock(mutex* lock) 151 156 { 152 #ifdef KDEBUG 153 _mutex_unlock(lock); 154 #else 157 #if !defined(KDEBUG) 155 158 if (atomic_add(&lock->count, 1) < -1) 156 _mutex_unlock(lock);157 159 #endif 160 _mutex_unlock(lock, false); 158 161 } 159 162 -
haiku/branches/developer/bonefish/vm/src/system/kernel/lock.cpp
r25812 r26257 382 382 383 383 free(name); 384 } 385 386 387 status_t 388 mutex_switch_lock(mutex* from, mutex* to) 389 { 390 InterruptsSpinLocker locker(thread_spinlock); 391 392 #if !defined(KDEBUG) 393 if (atomic_add(&from->count, 1) < -1) 394 #endif 395 _mutex_unlock(from, true); 396 397 return mutex_lock_threads_locked(to); 384 398 } 385 399 … … 442 456 443 457 void 444 _mutex_unlock(mutex* lock) 445 { 446 InterruptsSpinLocker _(thread_spinlock); 458 _mutex_unlock(mutex* lock, bool threadsLocked) 459 { 460 // lock only, if !threadsLocked 461 InterruptsSpinLocker locker(thread_spinlock, false, !threadsLocked); 447 462 448 463 #ifdef KDEBUG
