debugging, more pthreads crap
This commit is contained in:
parent
493f3d0fbf
commit
ba15d71b0c
7 changed files with 27 additions and 9 deletions
|
|
@ -50,6 +50,7 @@ _threadexec(Channel *pidc, int fd[3], char *prog, char *args[], int freeargs)
|
|||
goto Bad;
|
||||
case 0:
|
||||
efork(fd, pfd, prog, args);
|
||||
_threaddebug(DBGSCHED, "exit after efork");
|
||||
_exit(0);
|
||||
default:
|
||||
_threadafterexec();
|
||||
|
|
@ -152,6 +153,7 @@ efork(int stdfd[3], int fd[2], char *prog, char **args)
|
|||
strcpy(buf, "exec failed");
|
||||
write(fd[1], buf, strlen(buf));
|
||||
close(fd[1]);
|
||||
_threaddebug(DBGSCHED, "_exits in exec-unix");
|
||||
_exits(buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ threadsetname(char *fmt, ...)
|
|||
t->name = vsmprint(fmt, arg);
|
||||
va_end(arg);
|
||||
|
||||
_threaddebug(DBGSCHED, "set name %s", t->name);
|
||||
/* Plan 9 only
|
||||
if(p->nthreads == 1){
|
||||
snprint(buf, sizeof buf, "#p/%d/args", getpid());
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ tprimes: tprimes.$O $PLAN9/lib/$LIB
|
|||
texec: texec.$O $PLAN9/lib/$LIB
|
||||
$LD -o texec texec.$O $LDFLAGS -lthread -l9
|
||||
|
||||
tspawn: tspawn.$O $PLAN9/lib/$LIB
|
||||
$LD -o tspawn tspawn.$O $LDFLAGS -lthread -l9
|
||||
|
||||
trend: trend.$O $PLAN9/lib/$LIB
|
||||
$LD -o trend trend.$O $LDFLAGS -lthread -l9
|
||||
|
||||
|
|
|
|||
|
|
@ -87,9 +87,7 @@ _threadnote(void *v, char *s)
|
|||
Note *n;
|
||||
|
||||
_threaddebug(DBGNOTE, "Got note %s", s);
|
||||
if(strncmp(s, "sys:", 4) == 0
|
||||
&& strcmp(s, "sys: write on closed pipe") != 0
|
||||
&& strcmp(s, "sys: child") != 0)
|
||||
if(strncmp(s, "sys:", 4) == 0)
|
||||
noted(NDFLT);
|
||||
|
||||
// if(_threadexitsallstatus){
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ _threadinitproc(Proc *p)
|
|||
void
|
||||
_threadexitproc(char *exitstr)
|
||||
{
|
||||
_threaddebug(DBGSCHED, "_pthreadexit");
|
||||
pthread_exit(nil);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +70,8 @@ _threadexitproc(char *exitstr)
|
|||
void
|
||||
_threadexitallproc(char *exitstr)
|
||||
{
|
||||
exits(0);
|
||||
_threaddebug(DBGSCHED, "_threadexitallproc");
|
||||
exits(exitstr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -111,6 +113,7 @@ _threadwaitproc(void *v)
|
|||
else
|
||||
free(w);
|
||||
}
|
||||
fprint(2, "_threadwaitproc exits\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -170,9 +170,10 @@ runthread(Proc *p)
|
|||
/*
|
||||
* Maybe we were awakened to exit?
|
||||
*/
|
||||
if(_threadexitsallstatus)
|
||||
if(_threadexitsallstatus){
|
||||
_threaddebug(DBGSCHED, "time to exit");
|
||||
_exits(_threadexitsallstatus);
|
||||
|
||||
}
|
||||
assert(q->head != nil);
|
||||
}
|
||||
|
||||
|
|
@ -291,9 +292,12 @@ schedexit(Proc *p)
|
|||
strncpy(ex, p->exitstr, sizeof ex);
|
||||
ex[sizeof ex-1] = '\0';
|
||||
free(p);
|
||||
if(n == 0)
|
||||
if(n == 0){
|
||||
_threaddebug(DBGSCHED, "procexit; no more procs");
|
||||
_threadexitallproc(ex);
|
||||
else
|
||||
}else{
|
||||
_threaddebug(DBGSCHED, "procexit");
|
||||
_threadexitproc(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
#include "threadimpl.h"
|
||||
|
||||
static void
|
||||
launcher(void (*f)(void*), void *arg)
|
||||
{
|
||||
f(arg);
|
||||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
_threadinitstack(Thread *t, void (*f)(void*), void *arg)
|
||||
{
|
||||
|
|
@ -17,7 +24,7 @@ _threadinitstack(Thread *t, void (*f)(void*), void *arg)
|
|||
/* leave a few words open on both ends */
|
||||
t->context.uc.uc_stack.ss_sp = t->stk+8;
|
||||
t->context.uc.uc_stack.ss_size = t->stksize-16;
|
||||
makecontext(&t->context.uc, (void(*)())f, 1, arg);
|
||||
makecontext(&t->context.uc, (void(*)())launcher, 2, f, arg);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue