commit - 315e309098f8b9f6ee8f869ceef8ea0aacce6c60
commit + 02a1a5c18bec9ca13fad2b7b12ae65c580f6fdf4
blob - 87924caa47211b1bf3d0b435d1b90dfe661ce4aa
blob + 4e047c1dde0743275c5c6f13d58173c56ab2c613
--- src/cmd/acme/acme.c
+++ src/cmd/acme/acme.c
int ncol;
Display *d;
+extern int _threaddebuglevel;
+_threaddebuglevel = ~0;
rfork(RFENVG|RFNAMEG);
ncol = -1;
blob - 4f642c84b4e4f8a52d9ad6407ddd9a9e59a2515a
blob + 957a352ba57879c7f9b696becb13a9e405261bc3
--- src/libthread/channel.c
+++ src/libthread/channel.c
int _threadhighnentry;
int _threadnalt;
+static void
+setuserpc(ulong pc)
+{
+ Thread *t;
+
+ t = _threadgetproc()->thread;
+ if(t)
+ t->userpc = pc;
+}
+
static int
canexec(Alt *a)
{
return c;
}
-int
-alt(Alt *alts)
+static int
+_alt(Alt *alts)
{
Alt *a, *xa;
Channel *volatile c;
return a - alts;
}
+int
+alt(Alt *alts)
+{
+ setuserpc(getcallerpc(&alts));
+ return _alt(alts);
+}
+
static int
runop(int op, Channel *c, void *v, int nb)
{
a[1].op = CHANEND;
if(nb)
a[1].op = CHANNOBLK;
- switch(r=alt(a)){
+ switch(r=_alt(a)){
case -1: /* interrupted */
return -1;
case 1: /* nonblocking, didn't accomplish anything */
int
recv(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
return runop(CHANRCV, c, v, 0);
}
int
nbrecv(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
return runop(CHANRCV, c, v, 1);
}
int
send(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
return runop(CHANSND, c, v, 0);
}
int
nbsend(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
return runop(CHANSND, c, v, 1);
}
int
sendul(Channel *c, ulong v)
{
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(ulong));
return send(c, &v);
}
{
ulong v;
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(ulong));
- if(recv(c, &v) < 0)
+ if(runop(CHANRCV, c, &v, 0) < 0)
return ~0;
return v;
}
int
sendp(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(void*));
- return send(c, &v);
+ return runop(CHANSND, c, &v, 0);
}
void*
{
void *v;
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(void*));
- if(recv(c, &v) < 0)
+ if(runop(CHANRCV, c, &v, 0) < 0)
return nil;
return v;
}
int
nbsendul(Channel *c, ulong v)
{
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(ulong));
- return nbsend(c, &v);
+ return runop(CHANSND, c, &v, 1);
}
ulong
{
ulong v;
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(ulong));
- if(nbrecv(c, &v) == 0)
+ if(runop(CHANRCV, c, &v, 1) == 0)
return 0;
return v;
}
int
nbsendp(Channel *c, void *v)
{
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(void*));
- return nbsend(c, &v);
+ return runop(CHANSND, c, &v, 1);
}
void*
{
void *v;
+ setuserpc(getcallerpc(&c));
channelsize(c, sizeof(void*));
- if(nbrecv(c, &v) == 0)
+ if(runop(CHANRCV, c, &v, 1) == 0)
return nil;
return v;
}
blob - 5306147134f8b39f4978b845825a8c5cc9ca5551
blob + 96d993359c1c26947227b79c88ab031fd63d3daf
--- src/libthread/main.c
+++ src/libthread/main.c
extern void (*_sysfatal)(char*, va_list);
void
+_threadstatus(int x)
+{
+ USED(x);
+ threadstatus();
+}
+
+void
_threaddie(int x)
{
extern char *_threadexitsallstatus;
signal(SIGTERM, _threaddie);
signal(SIGCHLD, _nop);
+ signal(SIGINFO, _threadstatus);
// rfork(RFREND);
//_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
blob - 755fc28006ac8513d88f218838410ce3c64ae8e3
blob + 250a19a2a86a64b88daead0947776cfa80504035
--- src/libthread/sched.c
+++ src/libthread/sched.c
//static Thread *runthread(Proc*);
-#if 0
static char *_psstate[] = {
"Dead",
"Running",
return "unknown";
return _psstate[s];
}
-#endif
void
_schedinit(void *arg)
{
_sched();
}
+
+void
+threadstatus(void)
+{
+ Proc *p;
+ Thread *t;
+ p = _threadgetproc();
+ for(t=p->threads.head; t; t=t->nextt)
+ fprint(2, "[%3d] %s userpc=%lux\n",
+ t->id, psstate(t->state), t->userpc);
+}
+
blob - 590342abbadb3aed1e01313f0f474d0e646b5fce
blob + e2e92a1b12b91846bd28f2029f181e0d78206ae2
--- src/libthread/threadimpl.h
+++ src/libthread/threadimpl.h
Chanstate chan; /* which channel operation is current */
Alt *alt; /* pointer to current alt structure (debugging) */
+ ulong userpc;
void* udata[NPRIV]; /* User per-thread data pointer */
};