Replace recursive_mutex with mutex (#708)

* Replace recursive_mutex with mutex

* Move mutex lock outside of ObtainBuffer
This commit is contained in:
Paris Oplopoios 2024-09-01 22:20:22 +03:00 committed by GitHub
parent 1d8359f828
commit f514fdfd18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 5 deletions

View file

@ -101,7 +101,7 @@ void MemoryManager::Free(PAddr phys_addr, size_t size) {
}
}
for (const auto& [addr, size] : remove_list) {
UnmapMemory(addr, size);
UnmapMemoryImpl(addr, size);
}
// Mark region as free and attempt to coalesce it with neighbours.
@ -124,7 +124,7 @@ int MemoryManager::Reserve(void** out_addr, VAddr virtual_addr, size_t size, Mem
const auto& vma = FindVMA(mapped_addr)->second;
// If the VMA is mapped, unmap the region first.
if (vma.IsMapped()) {
UnmapMemory(mapped_addr, size);
UnmapMemoryImpl(mapped_addr, size);
}
const size_t remaining_size = vma.base + vma.size - mapped_addr;
ASSERT_MSG(vma.type == VMAType::Free && remaining_size >= size);
@ -233,7 +233,10 @@ int MemoryManager::MapFile(void** out_addr, VAddr virtual_addr, size_t size, Mem
void MemoryManager::UnmapMemory(VAddr virtual_addr, size_t size) {
std::scoped_lock lk{mutex};
UnmapMemoryImpl(virtual_addr, size);
}
void MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) {
const auto it = FindVMA(virtual_addr);
const auto& vma_base = it->second;
ASSERT_MSG(vma_base.Contains(virtual_addr, size),