aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-21 22:47:15 +0000
committerrsc <devnull@localhost>2004-04-21 22:47:15 +0000
commitfb36ed82ec7470efe4e334ddc054bcb4fa06ae9e (patch)
treeb01e82e380a5501ea80bcf4d5316252a2e300603
parent2b4b2ae19107f2c7e45ca6ab6f73c9c8a5fb84dd (diff)
downloadplan9port-fb36ed82ec7470efe4e334ddc054bcb4fa06ae9e.tar.gz
plan9port-fb36ed82ec7470efe4e334ddc054bcb4fa06ae9e.tar.bz2
plan9port-fb36ed82ec7470efe4e334ddc054bcb4fa06ae9e.zip
how much stack do we need?
-rw-r--r--src/libthread/sched.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libthread/sched.c b/src/libthread/sched.c
index 57d597ba..9ad7298b 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -157,6 +157,21 @@ relock:
}
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)
{
Proc *p;
@@ -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)