summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/src/9/port/portclock.c2
-rw-r--r--sys/src/9/port/proc.c29
2 files changed, 22 insertions, 9 deletions
diff --git a/sys/src/9/port/portclock.c b/sys/src/9/port/portclock.c
index db2420948..6711815ff 100644
--- a/sys/src/9/port/portclock.c
+++ b/sys/src/9/port/portclock.c
@@ -148,7 +148,7 @@ hzclock(Ureg *ur)
m->proc->pc = ur->pc;
if(m->flushmmu){
- if(up)
+ if(up && up->newtlb)
flushmmu();
m->flushmmu = 0;
}
diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c
index f67dc9f3a..8ea620a51 100644
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1331,36 +1331,49 @@ procdump(void)
static void
procflushmmu(int (*match)(Proc*, void*), void *a)
{
+ Proc *await[MAXMACH];
int i, nm, nwait;
Proc *p;
/*
* tell all matching processes to flush their mmu's
*/
+ memset(await, 0, conf.nmach*sizeof(await[0]));
nwait = 0;
- for(i=0; i<conf.nproc; i++) {
+ for(i = 0; i < conf.nproc; i++){
p = &procalloc.arena[i];
if(p->state != Dead && (*match)(p, a)){
p->newtlb = 1;
for(nm = 0; nm < conf.nmach; nm++){
if(MACHP(nm)->proc == p){
+ coherence();
MACHP(nm)->flushmmu = 1;
- nwait++;
+ if(await[nm] == nil)
+ nwait++;
+ await[nm] = p;
}
}
}
}
- if(nwait == 0)
- return;
-
/*
* wait for all other processors to take a clock interrupt
* and flush their mmu's
*/
- for(nm = 0; nm < conf.nmach; nm++)
- while(m->machno != nm && MACHP(nm)->flushmmu)
- sched();
+ for(;;){
+ if(nwait == 0 || nwait == 1 && await[m->machno] != nil)
+ break;
+
+ sched();
+
+ for(nm = 0; nm < conf.nmach; nm++){
+ p = await[nm];
+ if(p != nil && (MACHP(nm)->proc != p || MACHP(nm)->flushmmu == 0)){
+ await[nm] = nil;
+ nwait--;
+ }
+ }
+ }
}
static int