ref: cc44473e8c095bb48bfcf68b982239bddfb97e07
parent: 23109a6631eb21b2d849807b470c239d71d09159
author: halfwit <michaelmisch1985@gmail.com>
date: Wed Jan 28 20:05:21 EST 2026
ticks
--- a/include/lib.h
+++ b/include/lib.h
@@ -206,7 +206,7 @@
struct OWaitmsg
{char pid[12]; /* of loved one */
- char time[3*12]; /* of loved one and descendants */
+ char ticks[3*12]; /* of loved one and descendants */
char msg[64]; /* compatibility BUG */
} OWaitmsg;
@@ -214,7 +214,7 @@
struct Waitmsg
{int pid; /* of loved one */
- ulong dur[3]; /* of loved one & descendants */
+ ulong ticks[3]; /* of loved one & descendants */
char msg[64];
} Waitmsg;
--- a/kern/chan.c
+++ b/kern/chan.c
@@ -236,7 +236,7 @@
* allowed, but other names with / in them draw warnings.
*/
if(strchr(s, '/') != nil && strcmp(s, "#/") != 0 && strcmp(s, "/") != 0)
- print("newpath: %s from %#p\n", s, getcallerpc(&s));+ panic("newpath: %s from %#p\n", s, getcallerpc(&s));p->mlen = 1;
p->malen = PATHMSLOP;
--- a/kern/dat.h
+++ b/kern/dat.h
@@ -431,6 +431,10 @@
Proc_traceme,
Proc_exitbig,
Proc_tracesyscall,
+
+ TUser = 0, /* Proc.time */
+ TSys,
+ TReal,
};
struct Proc
@@ -498,6 +502,7 @@
QLock qwaitr;
Rendez waitr; /* Place to hang out in wait */
+ ulong ticks[3];
Proc *child;
ulong noteid; /* Equivalent of note group */
int procctl;
--- a/kern/devcap.c
+++ b/kern/devcap.c
@@ -154,7 +154,7 @@
p = secalloc(sizeof *p);
memmove(p->hash, hash, Hashlen);
p->next = nil;
- p->ticks = (ulong)time(0);
+ p->ticks = ticks();
qlock(&capalloc.lk);
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -251,7 +251,6 @@
void osmsleep(int);
ulong ticks(void);
void osproc(Proc*);
-int osawait(Proc *, char *, int);
void osnewproc(Proc*);
void procsleep(void);
void procwakeup(Proc*);
--- a/kern/posix.c
+++ b/kern/posix.c
@@ -62,24 +62,6 @@
signal(SIGPIPE, SIG_IGN);
}
-int
-osawait(Proc *proc, char *str, int n)
-{- void *msg;
- int pid;
- ulong time[3] = {1000, 1000, 1000};-
- if(!proc->child)
- return -1;
- pid = proc->child->pid;
- if(pthread_join(thids[pid], &msg) != 0)
- return -1;
-
- // TODO: Actual TUser, TSys, TReal
- snprint(str, n, "%d %ux %lud %lud %lud %q", pid, time[0], time[1], time[2], msg);
- return sizeof(str);
-}
-
void
osnewproc(Proc *p)
{--- a/kern/procinit.c
+++ b/kern/procinit.c
@@ -77,6 +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();
osproc(p);
return (void*)p;
@@ -141,6 +143,7 @@
pexit(char *exitstr, int freemem)
{Proc *p;
+ ulong utime, stime;
Waitq *wq;
Fgrp *fgrp;
Egrp *egrp;
@@ -186,14 +189,15 @@
wq = smalloc(sizeof(Waitq));
wq->w.pid = up->pid;
- // TODO: Timers
- wq->w.dur[0] = 1000;
- wq->w.dur[1] = 1000;
- wq->w.dur[2] = 1000;
+ utime = up->time[TUser];
+ stime = up->time[TSys];
+ wq->w.ticks[TUser] = utime;
+ wq->w.ticks[TSys] = stime;
+ wq->w.ticks[TReal] = ticks() - up->time[TReal];
if(exitstr != nil && exitstr[0])
snprint(wq->w.msg, sizeof(wq->w.msg), "%s %lud: %s", up->text, up->pid, exitstr);
else
- snprint(wq->w.msg, 1, "%c", '0');
+ snprint(wq->w.msg, 1, "%c", '\0');
lock(&p->exl);
/*
* Check that parent is still alive.
@@ -200,8 +204,6 @@
*/
if(p->pid == up->parentpid && p->state != Broken) {p->nchild--;
- //p->dur[TCUser] += 100;
- //p->dur[TCSys] += 100;
/*
* If there would be more than 128 wait records
* processes for my parent, then don't leave a wait
--- a/kern/seg.c
+++ b/kern/seg.c
@@ -42,8 +42,9 @@
s = malloc(sizeof(Segment));
if(s == nil)
panic("%r");-
+ memset(s, 0, sizeof(Segment));
incref(&s->ref);
+
s->start = start;
s->size = size;
s->dref = malloc(size + sizeof(Ref));
--- a/kern/syscall.c
+++ b/kern/syscall.c
@@ -847,9 +847,9 @@
}
if(owt != nil){readnum(0, owt->pid, NUMSIZE, w.pid, NUMSIZE);
- //readnum(0, owt->time+TUser*NUMSIZE, NUMSIZE, w.time[TUser], NUMSIZE);
- //readnum(0, owt->time+TSys*NUMSIZE, NUMSIZE, w.time[TSys], NUMSIZE);
- //readnum(0, owt->time+TReal*NUMSIZE, NUMSIZE, w.time[TReal], NUMSIZE);
+ readnum(0, owt->ticks+TUser*NUMSIZE, NUMSIZE, w.ticks[TUser], NUMSIZE);
+ readnum(0, owt->ticks+TSys*NUMSIZE, NUMSIZE, w.ticks[TSys], NUMSIZE);
+ readnum(0, owt->ticks+TReal*NUMSIZE, NUMSIZE, w.ticks[TReal], NUMSIZE);
strncpy(owt->msg, w.msg, sizeof(owt->msg)-1);
owt->msg[sizeof(owt->msg)-1] = '\0';
}
--- a/kern/sysproc.c
+++ b/kern/sysproc.c
@@ -369,6 +369,8 @@
p->notepending = 0;
p->lastnote = nil;
p->parentpid = up->pid;
+ memset(p->ticks, 0, sizeof(p->ticks));
+ p->ticks[TReal] = ticks();
if((flag & RFNOTEG) == 0)
p->noteid = up->noteid;
--
⑨