Allocate thread stack on create, not on start.
Also, don't free and reallocate on thread reset.
This commit is contained in:
parent
c089fcec27
commit
e30dedd46f
1 changed files with 11 additions and 5 deletions
|
@ -336,12 +336,16 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the stack.
|
|
||||||
Memory::Memset(stackBlock, 0xFF, stackSize);
|
|
||||||
context.r[MIPS_REG_SP] = stackBlock + stackSize;
|
|
||||||
stackEnd = context.r[MIPS_REG_SP];
|
|
||||||
nt.initialStack = stackBlock;
|
nt.initialStack = stackBlock;
|
||||||
nt.stackSize = stackSize;
|
nt.stackSize = stackSize;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FillStack() {
|
||||||
|
// Fill the stack.
|
||||||
|
Memory::Memset(stackBlock, 0xFF, nt.stackSize);
|
||||||
|
context.r[MIPS_REG_SP] = stackBlock + nt.stackSize;
|
||||||
|
stackEnd = context.r[MIPS_REG_SP];
|
||||||
// What's this 512?
|
// What's this 512?
|
||||||
context.r[MIPS_REG_K0] = context.r[MIPS_REG_SP] - 256;
|
context.r[MIPS_REG_K0] = context.r[MIPS_REG_SP] - 256;
|
||||||
context.r[MIPS_REG_SP] -= 512;
|
context.r[MIPS_REG_SP] -= 512;
|
||||||
|
@ -1682,7 +1686,7 @@ void __KernelResetThread(Thread *t)
|
||||||
t->pendingMipsCalls.clear();
|
t->pendingMipsCalls.clear();
|
||||||
|
|
||||||
t->context.r[MIPS_REG_RA] = threadReturnHackAddr; //hack! TODO fix
|
t->context.r[MIPS_REG_RA] = threadReturnHackAddr; //hack! TODO fix
|
||||||
t->AllocateStack(t->nt.stackSize); // can change the stacksize!
|
t->FillStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread *__KernelCreateThread(SceUID &id, SceUID moduleId, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr)
|
Thread *__KernelCreateThread(SceUID &id, SceUID moduleId, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr)
|
||||||
|
@ -1721,6 +1725,8 @@ Thread *__KernelCreateThread(SceUID &id, SceUID moduleId, const char *name, u32
|
||||||
|
|
||||||
strncpy(t->nt.name, name, KERNELOBJECT_MAX_NAME_LENGTH);
|
strncpy(t->nt.name, name, KERNELOBJECT_MAX_NAME_LENGTH);
|
||||||
t->nt.name[KERNELOBJECT_MAX_NAME_LENGTH] = '\0';
|
t->nt.name[KERNELOBJECT_MAX_NAME_LENGTH] = '\0';
|
||||||
|
|
||||||
|
t->AllocateStack(t->nt.stackSize); // can change the stacksize!
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue