From 73d9b58dfc3d94cc70c2c5263122318b2a975110 Mon Sep 17 00:00:00 2001 From: luxsie Date: Wed, 18 Feb 2015 23:56:46 +0800 Subject: [PATCH 1/2] sys_ppu_thread_create: minimum stack size and stack allocation unit applied. --- rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index 3a3f32ae6f..5efed2c8f2 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -162,6 +162,15 @@ PPUThread* ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool i { PPUThread& new_thread = *(PPUThread*)&Emu.GetCPU().AddThread(CPU_THREAD_PPU); + // Note: I haven't figured out the minimum stack size of PPU Thread. + // Maybe it can be done with pthread_attr_getstacksize function. + // And i toke 4096 (PTHREAD_STACK_MIN, and the smallest allocation unit) for this. + if ((stacksize % 4096) || (stacksize == 0)) { + // If not times of smallest allocation unit, round it up to the nearest one. + // And regard zero as a same condition. + stacksize = 4096 * ((u32)(stacksize / 4096) + 1); + } + u32 id = new_thread.GetId(); new_thread.SetEntry(entry); new_thread.SetPrio(prio); From ffb0454424bd1a8179459d924cf6b93ac67f5800 Mon Sep 17 00:00:00 2001 From: luxsie Date: Thu, 19 Feb 2015 01:44:07 +0800 Subject: [PATCH 2/2] sys_ppu_thread_create: Add warning when allocated more stack size than required. --- rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index 5efed2c8f2..c524e17515 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -162,12 +162,14 @@ PPUThread* ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool i { PPUThread& new_thread = *(PPUThread*)&Emu.GetCPU().AddThread(CPU_THREAD_PPU); - // Note: I haven't figured out the minimum stack size of PPU Thread. + // Note: (Syphurith) I haven't figured out the minimum stack size of PPU Thread. // Maybe it can be done with pthread_attr_getstacksize function. // And i toke 4096 (PTHREAD_STACK_MIN, and the smallest allocation unit) for this. if ((stacksize % 4096) || (stacksize == 0)) { // If not times of smallest allocation unit, round it up to the nearest one. // And regard zero as a same condition. + sys_ppu_thread.Warning("sys_ppu_thread_create: stacksize increased from 0x%x to 0x%x.", + stacksize, 4096 * ((u32)(stacksize / 4096) + 1)); stacksize = 4096 * ((u32)(stacksize / 4096) + 1); }