* VMCache: Added a UserData attribute which can be used by the lock holder.

* Added "bool consumerLocked" parameter to VMCache::Unlock() and
  ReleaseRefAndUnlock(). Since Unlock() may cause the cache to be merged with
  a consumer cache, the flag is needed to prevent a deadlock in case the
  caller still holds a lock to the consumer. Hasn't been a problem yet, since
  that situation never occurred.
* VMCacheChainLocker: Reversed unlocking order to bottom-up. The other
  direction could cause a deadlock in case caches would be merged, since the
  locking order would be reversed. The way VMCacheChainLocker was used this
  didn't happen, though.
* fault_get_page(): While copying a page from a lower cache to the top cache,
  we do now unlock all caches but the top one, so we don't unnecessarily
  kill concurrency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-01-19 03:02:11 +00:00
parent 5ec7bd49cb
commit 3632eeedb9
3 changed files with 82 additions and 15 deletions
+12 -5
View File
@@ -74,14 +74,15 @@ public:
inline bool TryLock();
inline bool SwitchLock(mutex* from);
inline bool SwitchFromReadLock(rw_lock* from);
void Unlock();
void Unlock(bool consumerLocked = false);
inline void AssertLocked();
inline void AcquireRefLocked();
inline void AcquireRef();
inline void ReleaseRefLocked();
inline void ReleaseRef();
inline void ReleaseRefAndUnlock();
inline void ReleaseRefAndUnlock(
bool consumerLocked = false);
void WaitForPageEvents(vm_page* page, uint32 events,
bool relock);
@@ -108,6 +109,11 @@ public:
status_t FlushAndRemoveAllPages();
void* UserData() { return fUserData; }
void SetUserData(void* data) { fUserData = data; }
// Settable by the lock owner and valid as
// long as the lock is owned.
// for debugging only
mutex* GetLock()
{ return &fLock; }
@@ -171,13 +177,14 @@ private:
inline bool _IsMergeable() const;
void _MergeWithOnlyConsumer();
void _MergeWithOnlyConsumer(bool consumerLocked);
void _RemoveConsumer(VMCache* consumer);
private:
int32 fRefCount;
mutex fLock;
PageEventWaiter* fPageEventWaiters;
void* fUserData;
};
@@ -272,10 +279,10 @@ VMCache::ReleaseRef()
void
VMCache::ReleaseRefAndUnlock()
VMCache::ReleaseRefAndUnlock(bool consumerLocked)
{
ReleaseRefLocked();
Unlock();
Unlock(consumerLocked);
}