mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
how much stack do we need?
This commit is contained in:
parent
2b4b2ae191
commit
fb36ed82ec
1 changed files with 16 additions and 4 deletions
|
@ -156,6 +156,21 @@ relock:
|
|||
return t;
|
||||
}
|
||||
|
||||
void
|
||||
needstack(int howmuch)
|
||||
{
|
||||
Proc *p;
|
||||
Thread *t;
|
||||
|
||||
p = _threadgetproc();
|
||||
if(p == nil || (t=p->thread) == nil)
|
||||
return;
|
||||
if((ulong)&howmuch < (ulong)t->stk+howmuch){ /* stack overflow waiting to happen */
|
||||
fprint(2, "stack overflow: stack at 0x%lux, limit at 0x%lux, need 0x%lux\n", (ulong)&p, (ulong)t->stk, howmuch);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_sched(void)
|
||||
{
|
||||
|
@ -166,10 +181,7 @@ Resched:
|
|||
p = _threadgetproc();
|
||||
//fprint(2, "p %p\n", p);
|
||||
if((t = p->thread) != nil){
|
||||
if((ulong)&p < (ulong)t->stk+512){ /* stack overflow waiting to happen */
|
||||
fprint(2, "stack overflow: stack at %lux, limit at %lux\n", (ulong)&p, (ulong)t->stk);
|
||||
abort();
|
||||
}
|
||||
needstack(512);
|
||||
// _threaddebug(DBGSCHED, "pausing, state=%s set %p goto %p",
|
||||
// psstate(t->state), &t->sched, &p->sched);
|
||||
if(_setlabel(&t->sched)==0)
|
||||
|
|
Loading…
Reference in a new issue