Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0128/12

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Add needstack to libthread.
 [rsc] --rw-rw-r-- M 1428987 glenda sys 3616 Jan 28 10:48 sys/include/thread.h
	/n/sourcesdump/2006/0128/plan9/sys/include/thread.h:69,74 - 
	/n/sourcesdump/2006/0129/plan9/sys/include/thread.h:69,75
	  int		nbsend(Channel *c, void *v);
	  int		nbsendp(Channel *c, void *v);
	  int		nbsendul(Channel *c, ulong v);
	+ void		needstack(int);
	  int		proccreate(void (*f)(void *arg), void *arg, uint stacksize);
	  int		procrfork(void (*f)(void *arg), void *arg, uint stacksize, int flag);
	  void**		procdata(void);
 [rsc] --rw-rw-r-- M 1428987 glenda sys 3342 Jan 28 10:47 sys/src/libthread/sched.c
	/n/sourcesdump/2006/0128/plan9/sys/src/libthread/sched.c:78,83 - 
	/n/sourcesdump/2006/0129/plan9/sys/src/libthread/sched.c:78,101
	  }
	  
	  void
	+ needstack(int n)
	+ {
	+ 	int x;
	+ 	Proc *p;
	+ 	Thread *t;
	+ 	
	+ 	p = _threadgetproc();
	+ 	t = p->thread;
	+ 	
	+ 	if((uchar*)&x - n < (uchar*)t->stk){
	+ 		fprint(2, "%s %d: &x=%p n=%d t->stk=%p\n",
	+ 			argv0, getpid(), &x, n, t->stk);
	+ 		fprint(2, "%s %d: stack overflow\n", argv0, getpid());
	+ 		abort();
	+ 	}
	+ }
	+ 
	+ void
	  _sched(void)
	  {
	  	Proc *p;
	/n/sourcesdump/2006/0128/plan9/sys/src/libthread/sched.c:86,93 - 
	/n/sourcesdump/2006/0129/plan9/sys/src/libthread/sched.c:104,110
	  Resched:
	  	p = _threadgetproc();
	  	if((t = p->thread) != nil){
	- 		if((uchar*)&p < t->stk)		/* stack overflow */
	- 			abort();
	+ 		needstack(128);
	  		_threaddebug(DBGSCHED, "pausing, state=%s", psstate(t->state));
	  		if(setjmp(t->sched)==0)
	  			longjmp(p->sched, 1);


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.