Memory: Make TLS only 0x200 bytes for each thread

Also move TLS to Base region
This commit is contained in:
PSI-Rockin 2024-05-09 20:35:28 -04:00
parent ba25ae7eba
commit 6c4c20fe3e
2 changed files with 6 additions and 6 deletions

View file

@ -47,9 +47,9 @@ namespace VirtualAddrs {
LinearHeapStartNew = 0x30000000, LinearHeapStartNew = 0x30000000,
LinearHeapEndNew = 0x40000000, LinearHeapEndNew = 0x40000000,
// Start of TLS for first thread. Next thread's storage will be at TLSBase + 0x1000, and so on // Start of TLS for first thread. Next thread's storage will be at TLSBase + 0x200, and so on
TLSBase = 0x1FF82000, TLSBase = 0x1FF82000,
TLSSize = 0x1000, TLSSize = 0x200,
VramStart = 0x1F000000, VramStart = 0x1F000000,
VramSize = 0x00600000, VramSize = 0x00600000,

View file

@ -37,10 +37,10 @@ void Memory::reset() {
paddrTable[i] = 0; paddrTable[i] = 0;
} }
// Map 4 KB of FCRAM for each thread // Allocate 512 bytes of TLS for each thread. Since the smallest allocatable unit is 4 KB, that means allocating one page for every 8 threads
// TODO: the region should be taken from the exheader // Note that TLS is always allocated in the Base region
// TODO: each thread should only have 512 bytes - an FCRAM page should account for 8 threads s32 tlsPages = (appResourceLimits.maxThreads + 7) >> 3;
assert(allocMemory(VirtualAddrs::TLSBase, appResourceLimits.maxThreads, FcramRegion::App, true, true, false, MemoryState::Locked)); allocMemory(VirtualAddrs::TLSBase, tlsPages, FcramRegion::Base, true, true, false, MemoryState::Locked);
// Initialize shared memory blocks and reserve memory for them // Initialize shared memory blocks and reserve memory for them
for (auto& e : sharedMemBlocks) { for (auto& e : sharedMemBlocks) {