ref: 543763a08d4652736766543fa1369dec622ac886
parent: cc44473e8c095bb48bfcf68b982239bddfb97e07
author: halfwit <michaelmisch1985@gmail.com>
date: Thu Jan 29 20:35:23 EST 2026
Add in a bit more proc
--- a/kern/arm.c
+++ b/kern/arm.c
@@ -513,8 +513,8 @@
switch(up->procctl) {case Proc_traceme:
- //if(up->nnote == 0)
- // return;
+ if(up->nnote == 0)
+ return;
/* No break */
case Proc_stopme:
up->procctl = 0;
--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -578,7 +578,6 @@
}
i += n;
}
-/*print("got %d\n", i);*/uif->offset += i;
return i;
}
--- a/kern/devproc.c
+++ b/kern/devproc.c
@@ -128,14 +128,25 @@
error(Eperm);
}
+static int
+prochaswaitq(void *x)
+{+ Chan *c;
+ Proc *p;
+
+ c = (Chan *)x;
+ p = proctab(SLOT(c->qid));
+ return p->pid != PID(c->qid) || p->waitq != nil;
+}
+
static void
procstopwait(Proc *p, int ctl)
{- //char *state;
- //int pid;
-/*
- if(p->pdbg != nil)
- error(Einuse);
+ char *state;
+ int pid;
+
+ //if(p->pdbg != nil)
+ // error(Einuse);
if(procstopped(p) || p->state == Broken)
return;
pid = p->pid;
@@ -145,24 +156,23 @@
p->procctl = ctl;
if(p == up)
return;
- p->pdbg = up;
+ //p->pdbg = up;
qunlock(&p->debug);
- state = up->psstate;
- up->psstate = "Stopwait";
+ //state = up->psstate;
+ //up->psstate = "Stopwait";
if(waserror()) {- up->psstate = state;
+ //up->psstate = state;
qlock(&p->debug);
- if(p->pdbg == up)
- p->pdbg = nil;
+ //if(p->pdbg == up)
+ // p->pdbg = nil;
nexterror();
}
- sleep(&up->sleep, procstopped, p);
+ sleep(&up->rsleep, procstopped, p);
poperror();
- up->psstate = state;
+ //up->psstate = state;
qlock(&p->debug);
if(p->pid != pid)
error(Eprocdied);
-*/
}
static void
@@ -272,7 +282,7 @@
len = tab->length;
switch(QID(c->qid)) {case Qwait:
- // len = p->nwait; /* incorrect size, but >0 means there's something to read */
+ len = p->nwait; /* incorrect size, but >0 means there's something to read */
break;
case Qprofile:
// q = p->seg[TSEG];
@@ -657,42 +667,42 @@
goto statbufread;
case Qwait:
- // if(!canqlock(&p->qwaitr))
- // error(Einuse);
+ if(!canqlock(&p->qwaitr))
+ error(Einuse);
- // if(waserror()) {- // qunlock(&p->qwaitr);
- // nexterror();
- // }
+ if(waserror()) {+ qunlock(&p->qwaitr);
+ nexterror();
+ }
- // lock(&p->exl);
- // while(p->waitq == nil && p->pid == PID(c->qid)) {- // if(up == p && p->nchild == 0) {- // unlock(&p->exl);
- // error(Enochild);
- // }
- // unlock(&p->exl);
- // sleep(&p->waitr, prochaswaitq, c);
- // lock(&p->exl);
- // }
- // if(p->pid != PID(c->qid)){- // unlock(&p->exl);
- // error(Eprocdied);
- // }
- // wq = p->waitq;
- // p->waitq = wq->next;
- // p->nwait--;
- // unlock(&p->exl);
+ lock(&p->exl);
+ while(p->waitq == nil && p->pid == PID(c->qid)) {+ if(up == p && p->nchild == 0) {+ unlock(&p->exl);
+ error(Enochild);
+ }
+ unlock(&p->exl);
+ sleep(&p->waitr, prochaswaitq, c);
+ lock(&p->exl);
+ }
+ if(p->pid != PID(c->qid)){+ unlock(&p->exl);
+ error(Eprocdied);
+ }
+ wq = p->waitq;
+ p->waitq = wq->next;
+ p->nwait--;
+ unlock(&p->exl);
- // qunlock(&p->qwaitr);
- // poperror();
+ qunlock(&p->qwaitr);
+ poperror();
- // j = snprint(statbuf, sizeof(statbuf), "%d %lud %lud %lud %q",
- // wq->w.pid,
- // wq->w.time[TUser], wq->w.time[TSys], wq->w.time[TReal],
- // wq->w.msg);
- // free(wq);
- // offset = 0;
+ j = snprint(statbuf, sizeof(statbuf), "%d %lud %lud %lud %q",
+ wq->w.pid,
+ wq->w.ticks[TUser], wq->w.ticks[TSys], wq->w.ticks[TReal],
+ wq->w.msg);
+ free(wq);
+ offset = 0;
goto statbufread;
}
@@ -786,6 +796,7 @@
/* use the remembered noteid in the channel qid */
if(QID(c->qid) == Qnotepg) {+ print("Posting note\n");if(n >= sizeof(buf))
error(Etoobig);
memmove(buf, va, n);
@@ -860,6 +871,7 @@
// unbreak(p);
// return;
//}
+ print("PROCKILLLLL\n");if(ctl != 0)
p->procctl = ctl;
incref(&killnote.ref);
--- a/kern/procinit.c
+++ b/kern/procinit.c
@@ -77,8 +77,8 @@
if(p->egrp != nil)
incref(&p->egrp->ref);
strecpy(p->text, p->text+sizeof p->text, name);
- memset(p->time, 0, sizeof(p->time));
- p->time[TReal] = ticks();
+ memset(p->ticks, 0, sizeof(p->ticks));
+ p->ticks[TReal] = ticks();
osproc(p);
return (void*)p;
@@ -189,11 +189,11 @@
wq = smalloc(sizeof(Waitq));
wq->w.pid = up->pid;
- utime = up->time[TUser];
- stime = up->time[TSys];
+ utime = up->ticks[TUser];
+ stime = up->ticks[TSys];
wq->w.ticks[TUser] = utime;
wq->w.ticks[TSys] = stime;
- wq->w.ticks[TReal] = ticks() - up->time[TReal];
+ wq->w.ticks[TReal] = ticks() - up->ticks[TReal];
if(exitstr != nil && exitstr[0])
snprint(wq->w.msg, sizeof(wq->w.msg), "%s %lud: %s", up->text, up->pid, exitstr);
else
--
⑨