From 343898b7312f5ebbb9860d4818a349428313d6b6 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 4 Dec 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-12-04 --- carrera/dat.h | 1 + pc/dat.h | 1 + port/devproc.c | 8 ++++++++ port/portdat.h | 11 +++++++++++ port/proc.c | 19 ++++++++++--------- port/sysproc.c | 1 + port/taslock.c | 2 ++ power/dat.h | 1 + 8 files changed, 35 insertions(+), 9 deletions(-) diff --git a/carrera/dat.h b/carrera/dat.h index bcf9070ecf7a427b94ca3add397818acff53c051..da00c7a5a553fe87b5462a03a2debc257c6f5766 100644 --- a/carrera/dat.h +++ b/carrera/dat.h @@ -117,6 +117,7 @@ struct Mach uchar ktlbnext; int speed; /* cpu speed */ ulong delayloop; /* for the delay() routine */ + Schedq runq; int pfault; int cs; diff --git a/pc/dat.h b/pc/dat.h index e5d2bc9ec5ea50dd0db841b69b8a353c0d2b0500..03e9f7fc73a6fae2516f082c6a16defd4a0a3a5a 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -123,6 +123,7 @@ struct Mach Label sched; /* scheduler wakeup */ Lock alarmlock; /* access to alarm list */ void *alarm; /* alarms bound to this clock */ + Schedq runq; int tlbfault; int otlbfault; diff --git a/port/devproc.c b/port/devproc.c index 6cdb72631462bf2e2b438296091124b8d9761808..18a0989ff9c7381a403952f00b652f3b6a2d3d93 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -697,6 +697,7 @@ procstopwait(Proc *p, int ctl) void procctlreq(Proc *p, char *va, int n) { + int i; char buf[NAMELEN]; if(n > NAMELEN) @@ -744,6 +745,13 @@ procctlreq(Proc *p, char *va, int n) error(Ebadctl); ready(p); } + else + if(strncmp(buf, "cpu ", 4) == 0) { + i = strtoul(buf+4, 0, 0); + if(i < 0 || i >= conf.nmach) + error(Ebadctl); + p->mp = MACHP(i); + } else error(Ebadctl); } diff --git a/port/portdat.h b/port/portdat.h index fa17ef1965c4f6a1839a71d1f01b5dff0397fa94..17a7e3fadc76cf8668e99660da456d0e53a81b24 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -31,6 +31,7 @@ typedef struct Ref Ref; typedef struct Rendez Rendez; typedef struct RWlock RWlock; typedef struct Sargs Sargs; +typedef struct Schedq Schedq; typedef struct Segment Segment; typedef struct Session Session; typedef struct Talarm Talarm; @@ -553,6 +554,8 @@ struct Proc Note lastnote; int (*notify)(void*, char*); + Mach *mp; /* machine this process is tied to */ + void *ureg; /* User registers for notes */ void *dbgreg; /* User registers for devproc */ Notsave; @@ -567,6 +570,14 @@ struct Proc PMMU; }; +struct Schedq +{ + Lock; + Proc *head; + Proc *tail; +}; + + enum { PRINTSIZE = 256, diff --git a/port/proc.c b/port/proc.c index 443010ed67ed1ea493cc464bdbfd323a9f76a887..01d6c674d284692e1f11b3426d9de5d3d3cb4d56 100644 --- a/port/proc.c +++ b/port/proc.c @@ -21,13 +21,6 @@ struct Waitq *free; }waitqalloc; -typedef struct -{ - Lock; - Proc *head; - Proc *tail; -}Schedq; - Schedq runhiq, runloq; int nrdy; @@ -109,7 +102,7 @@ m->otlbfault = m->tlbfault; int anyready(void) { - return runloq.head != 0 || runhiq.head != 0; + return runloq.head != 0 || runhiq.head != 0 || m->runq.head != 0; } void @@ -121,6 +114,9 @@ ready(Proc *p) s = splhi(); rq = &runhiq; + if(p->mp) + rq = &p->mp->runq; + else if(p->state == Running) rq = &runloq; @@ -146,12 +142,16 @@ runproc(void) loop: spllo(); - while(runhiq.head == 0 && runloq.head == 0) + while(runhiq.head == 0 && runloq.head == 0 && m->runq.head == 0) ; splhi(); lock(&runhiq); + + if(m->runq.head) + rq = &m->runq; + else if(runhiq.head) rq = &runhiq; else @@ -225,6 +225,7 @@ newproc(void) p->kp = 0; p->procctl = 0; p->notepending = 0; + p->mp = 0; memset(p->seg, 0, sizeof p->seg); p->pid = incref(&pidalloc); p->noteid = incref(¬eidalloc); diff --git a/port/sysproc.c b/port/sysproc.c index 07ff2582fd36e9fc723865422ee13c2cd1d0945e..e4975b0cd36381ff1b513fc0c2dd655a5c66a183 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -160,6 +160,7 @@ sysrfork(ulong *arg) p->time[TReal] = MACHP(0)->ticks; memmove(p->text, up->text, NAMELEN); memmove(p->user, up->user, NAMELEN); + p->mp = up->mp; /* * since the bss/data segments are now shareable, * any mmu info about this process is now stale diff --git a/port/taslock.c b/port/taslock.c index a410aa65b45f66877487790c7a2c3c78dd252728..818302a91f2f5851621b58bf6da3a63327d5693d 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -8,6 +8,8 @@ void lock(Lock *l) { + if(tas(&l->key) == 0) + return; for(;;){ while(l->key) ; diff --git a/power/dat.h b/power/dat.h index 18bee9f2581266a5d980133c7d1d4b41f4011089..d553ab478af60c13ccde5e6164b061a0cc8e8f44 100644 --- a/power/dat.h +++ b/power/dat.h @@ -131,6 +131,7 @@ struct Mach int intr; int ledval; /* value last written to LED */ int otlbfault; + Schedq runq; int stack[1]; };