mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Rename Memory::Lock() to Core_LockAgainstShutdown(), move it to Core
It stopped being about memory when CPU_Shutdown started holding it across the whole teardown - it's what keeps kernel objects, the symbol map and the memory map from being freed while another thread reads them. The old name invited the reading that it locks memory *access*, which it has never done. Memory::Reinit() now holds it across both halves rather than relying on Memory::Shutdown()'s own acquire: between Shutdown() and Init() there is no memory map at all, and a reader could slip into that gap. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
1 parent
f57a102027
commit
75ff0d406c
16 files changed
+76
-66
No files matched your search
+4
-17
@@ -87,7 +87,6 @@ u32 g_PSPModel;
|
||||
|
||||
static MemMapSetupFlags g_setupFlags;
|
||||
|
||||
std::recursive_mutex g_shutdownLock;
|
||||
|
||||
// We don't declare the IO region in here since its handled by other means.
|
||||
static MemoryView views[] = {
|
||||
@@ -343,6 +342,9 @@ bool Init(MemMapSetupFlags flags) {
|
||||
void Reinit() {
|
||||
_assert_msg_(PSP_GetBootState() == BootState::Complete, "Cannot reinit during startup/shutdown");
|
||||
Core_NotifyLifecycle(CoreLifecycle::MEMORY_REINITING);
|
||||
// Held across both halves: between Shutdown() and Init() there is no memory map at all, and a
|
||||
// reader that only saw Shutdown()'s own acquire could slip into that gap.
|
||||
CoreShutdownLock coreLock = Core_LockAgainstShutdown();
|
||||
MemMapSetupFlags flags = g_setupFlags;
|
||||
Shutdown();
|
||||
Init(flags);
|
||||
@@ -421,7 +423,7 @@ void DoState(PointerWrap &p) {
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
std::lock_guard<std::recursive_mutex> guard(g_shutdownLock);
|
||||
CoreShutdownLock coreLock = Core_LockAgainstShutdown();
|
||||
u32 flags = 0;
|
||||
MemoryMap_Shutdown();
|
||||
base = nullptr;
|
||||
@@ -432,21 +434,6 @@ bool IsActive() {
|
||||
return base != nullptr;
|
||||
}
|
||||
|
||||
// Wanting to avoid include pollution, MemMap.h is included a lot.
|
||||
MemoryInitedLock::MemoryInitedLock()
|
||||
{
|
||||
g_shutdownLock.lock();
|
||||
}
|
||||
MemoryInitedLock::~MemoryInitedLock()
|
||||
{
|
||||
g_shutdownLock.unlock();
|
||||
}
|
||||
|
||||
MemoryInitedLock Lock()
|
||||
{
|
||||
return MemoryInitedLock();
|
||||
}
|
||||
|
||||
static Opcode Read_Instruction(u32 address, bool resolveReplacements, Opcode inst) {
|
||||
if (!MIPS_IS_EMUHACK(inst.encoding)) {
|
||||
return inst;
|
||||
|
||||
Reference in new issue
Block a user