From fa1308e9f1b104ad0fd3536dc90205f2a630ec63 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 29 Mar 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-03-29 --- pc/trap.c | 16 +--------------- port/devrealtime.c | 14 +++++++++++++- port/edf.c | 11 ++--------- port/portdat.h | 1 + port/proc.c | 2 +- port/segment.c | 1 + 6 files changed, 19 insertions(+), 26 deletions(-) diff --git a/pc/trap.c b/pc/trap.c index ebd059d302c2a4420c928758d88ab2a16c0b811b..3a8946bd9869413a54336db7e80b18f2d7968238 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -303,21 +303,7 @@ trap(Ureg* ureg) postnote(up, 1, buf, NDebug); } else if(vno >= VectorPIC && vno != VectorSYSCALL){ - /* call all interrupt routines, just in case */ - for(i = VectorPIC; i <= MaxIrqLAPIC; i++){ - ctl = vctl[i]; - if(ctl == nil) - continue; - if(!ctl->isintr) - continue; - for(v = ctl; v != nil; v = v->next){ - if(v->f) - v->f(ureg, v->a); - } - /* should we do this? */ - if(ctl->eoi) - ctl->eoi(i); - } + i8259isr(vno); /* * An unknown interrupt. diff --git a/port/devrealtime.c b/port/devrealtime.c index 64eaa0f168978d5aaff522b267e1e19253194abe..e971de81170c8ace89c4be60cdb6b296bf0c5d3a 100644 --- a/port/devrealtime.c +++ b/port/devrealtime.c @@ -57,6 +57,18 @@ Dirtab scheddir[]={ "time", {Qtime}, 0, 0444, }; +static char *schedstatename[] = { + [SRelease] = "Release", + [SRun] = "Run", + [SPreempt] = "Preempt", + [SBlock] = "Block", + [SResume] = "Resume", + [SDeadline] = "Deadline", + [SYield] = "Yield", + [SSlice] = "Slice", + [SExpel] = "Expel", +}; + static char* dumptask(char *p, char *e, Task *t, Ticks now) { @@ -169,7 +181,7 @@ _devrt(Task *t, Ticks t1, SEvent etype) if (logopens.ref == 0 || nevents == Nevents) return; - if(edfprint)iprint("state %s\n", edf_statename[etype]); + if(edfprint)iprint("state %s\n", schedstatename[etype]); events[wevent].tid = t - tasks; events[wevent].ts = 0; if (t1) diff --git a/port/edf.c b/port/edf.c index fb0d1fade088a17204108956e3f651b43334bddc..f0e6702aac715a24af189d65f73226d496839679 100644 --- a/port/edf.c +++ b/port/edf.c @@ -29,7 +29,6 @@ char *edf_statename[] = { static Cycintr cycdeadline; /* Time of next deadline */ static Cycintr cycrelease; /* Time of next release */ -static Ticks utilization; /* Current utilization */ static int initialized; static uvlong fasthz; static Ticks now; @@ -154,12 +153,10 @@ edfenqueue(Taskq *q, Task *t) { Task *tt, **ttp; - ilock(q); DPRINT("%d edfenqueue, %s, %d\n", m->machno, edf_statename[t->state], t->runq.n); t->rnext = nil; if (q->head == nil) { q->head = t; - iunlock(q); return t; } SET(tt); @@ -175,7 +172,6 @@ edfenqueue(Taskq *q, Task *t) tt->rnext = t; if (t != q->head) t = nil; - iunlock(q); return t; } @@ -185,12 +181,10 @@ edfdequeue(Taskq *q) Task *t; DPRINT("%d edfdequeue\n", m->machno); - ilock(q); if (t = q->head){ q->head = t->rnext; t->rnext = nil; } - iunlock(q); return t; } @@ -199,17 +193,14 @@ edfqremove(Taskq *q, Task *t) { Task **tp; - ilock(q); DPRINT("%d edfqremove, %s, %d\n", m->machno, edf_statename[t->state], t->runq.n); for (tp = &q->head; *tp; tp = &(*tp)->rnext){ if (*tp == t){ *tp = t->rnext; t = (tp == &q->head) ? q->head : nil; - iunlock(q); return t; } } - iunlock(q); return nil; } @@ -482,6 +473,8 @@ edfdeadlineintr(Ureg*, Cycintr*) } } } + if (up->nlocks) + iprint("have %lud locks at deadline\n", up->nlocks); } iunlock(&edflock); sched(); diff --git a/port/portdat.h b/port/portdat.h index ccb09f06fecb6f0495e2955189afe260bbcc1d36..cc05d7f41b45ece7e380e8e77d56c94577096564 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -640,6 +640,7 @@ struct Proc Mach *wired; Mach *mp; /* machine this process last ran on */ ulong nlocks; /* number of locks held by proc */ + ulong delaysched; ulong priority; /* priority level */ ulong basepri; /* base priority level */ uchar fixedpri; /* priority level deson't change */ diff --git a/port/proc.c b/port/proc.c index 2371fd50d9dda4dfc1a091e34134d4d9c847fa53..74262ef69ff86f583d4aa25a9090900c70e93161 100644 --- a/port/proc.c +++ b/port/proc.c @@ -514,7 +514,7 @@ ms2tk(ulong ms) /* avoid overflows at the cost of precision */ if(ms >= 1000000000/HZ) return (ms/1000)*HZ; - return (ms+500)*HZ/1000; + return (ms*HZ+500)/1000; } void diff --git a/port/segment.c b/port/segment.c index 69c4c72c8021b5213b5986c0df73897402aa3d1c..762332538ff328135c798ab78603889dec0a40be 100644 --- a/port/segment.c +++ b/port/segment.c @@ -125,6 +125,7 @@ putseg(Segment *s) free(s->map); if(s->profile != 0) free(s->profile); + unlock(s); /* keep lock/unlocks balanced */ free(s); }