M carrera/dat.h => carrera/dat.h +1 -0
@@ 117,6 117,7 @@ struct Mach
uchar ktlbnext;
int speed; /* cpu speed */
ulong delayloop; /* for the delay() routine */
+ Schedq runq;
int pfault;
int cs;
M pc/dat.h => pc/dat.h +1 -0
@@ 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;
M port/devproc.c => port/devproc.c +8 -0
@@ 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)
@@ 745,6 746,13 @@ procctlreq(Proc *p, char *va, int n)
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);
}
M port/portdat.h => port/portdat.h +11 -0
@@ 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,
M port/proc.c => port/proc.c +10 -9
@@ 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);
M port/sysproc.c => port/sysproc.c +1 -0
@@ 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
M port/taslock.c => port/taslock.c +2 -0
@@ 8,6 8,8 @@
void
lock(Lock *l)
{
+ if(tas(&l->key) == 0)
+ return;
for(;;){
while(l->key)
;
M power/dat.h => power/dat.h +1 -0
@@ 131,6 131,7 @@ struct Mach
int intr;
int ledval; /* value last written to LED */
int otlbfault;
+ Schedq runq;
int stack[1];
};