提交 0d948cbd 创建 作者: Frans Kaashoek's avatar Frans Kaashoek

p->next -> p->runq

上级 1403faf4
...@@ -93,7 +93,7 @@ addrun1(struct runq *rq, struct proc *p) ...@@ -93,7 +93,7 @@ addrun1(struct runq *rq, struct proc *p)
{ {
struct proc *q; struct proc *q;
cprintf("%d: add to run %d\n", cpu->id, p->pid); cprintf("%d: add to run %d\n", cpu->id, p->pid);
for (q = rq->runq; q != 0; q = q->next) { for (q = rq->runq; q != 0; q = q->runq) {
if (q == p) { if (q == p) {
cprintf("allready on q\n"); cprintf("allready on q\n");
p->state = RUNNABLE; p->state = RUNNABLE;
...@@ -101,7 +101,7 @@ addrun1(struct runq *rq, struct proc *p) ...@@ -101,7 +101,7 @@ addrun1(struct runq *rq, struct proc *p)
} }
} }
p->state = RUNNABLE; // race? p->state = RUNNABLE; // race?
p->next = rq->runq; p->runq = rq->runq;
rq->runq = p; rq->runq = p;
} }
...@@ -122,15 +122,15 @@ delrun1(struct runq *rq, struct proc *proc) ...@@ -122,15 +122,15 @@ delrun1(struct runq *rq, struct proc *proc)
while (n != 0) { while (n != 0) {
if (n == proc) { if (n == proc) {
if (p == 0) { if (p == 0) {
rq->runq = n->next; rq->runq = n->runq;
} else { } else {
p->next = n->next; p->runq = n->runq;
} }
n->next = 0; n->runq = 0;
return; return;
} else { } else {
p = n; p = n;
n = n->next; n = n->runq;
} }
} }
} }
...@@ -261,7 +261,7 @@ exit(void) ...@@ -261,7 +261,7 @@ exit(void)
// Pass abandoned children to init. // Pass abandoned children to init.
wakeupinit = 0; wakeupinit = 0;
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
acquire(&ptables[c].lock); acquire(&ptables[c].lock); // XXX Unscalable
for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){ for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){
if(p->parent == proc){ if(p->parent == proc){
p->parent = initproc; p->parent = initproc;
...@@ -301,7 +301,7 @@ wait(void) ...@@ -301,7 +301,7 @@ wait(void)
// Scan through table looking for zombie children. // Scan through table looking for zombie children.
havekids = 0; havekids = 0;
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
acquire(&ptables[c].lock); acquire(&ptables[c].lock); // XXX Unscalable
for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){ for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){
if(p->parent != proc) if(p->parent != proc)
continue; continue;
...@@ -350,7 +350,7 @@ steal(void) ...@@ -350,7 +350,7 @@ steal(void)
if (c == cpunum()) if (c == cpunum())
continue; continue;
acquire(&runqs[c].lock); acquire(&runqs[c].lock);
for(p = runqs[c].runq; p != 0; p = p->next) { for(p = runqs[c].runq; p != 0; p = p->runq) {
if (p->state == RUNNABLE) { if (p->state == RUNNABLE) {
cprintf("%d: steal %d from %d\n", cpunum(), p->pid, c); cprintf("%d: steal %d from %d\n", cpunum(), p->pid, c);
delrun1(&runqs[c], p); delrun1(&runqs[c], p);
...@@ -386,7 +386,7 @@ scheduler(void) ...@@ -386,7 +386,7 @@ scheduler(void)
// Loop over process table looking for process to run. // Loop over process table looking for process to run.
acquire(&runq->lock); acquire(&runq->lock);
for(p = runq->runq; p != 0; p = p->next) { for(p = runq->runq; p != 0; p = p->runq) {
if(p->state != RUNNABLE) if(p->state != RUNNABLE)
continue; continue;
...@@ -617,7 +617,7 @@ procdump(int c) ...@@ -617,7 +617,7 @@ procdump(int c)
cprintf("\n"); cprintf("\n");
} }
cprintf("runq: "); cprintf("runq: ");
for (q = runqs[c].runq; q != 0; q = q->next) { for (q = runqs[c].runq; q != 0; q = q->runq) {
if(q->state >= 0 && q->state < NELEM(states) && states[q->state]) if(q->state >= 0 && q->state < NELEM(states) && states[q->state])
state = states[q->state]; state = states[q->state];
else else
......
...@@ -46,7 +46,9 @@ struct proc { ...@@ -46,7 +46,9 @@ struct proc {
struct inode *cwd; // Current directory struct inode *cwd; // Current directory
char name[16]; // Process name (debugging) char name[16]; // Process name (debugging)
struct spinlock lock; struct spinlock lock;
struct proc *next; struct proc *runq;
struct proc *waiterq;
struct proc *childq;
}; };
// Process memory is laid out contiguously, low addresses first: // Process memory is laid out contiguously, low addresses first:
...@@ -74,8 +76,9 @@ struct cpu { ...@@ -74,8 +76,9 @@ struct cpu {
}; };
struct condvar { struct condvar {
void *chan; // If non-zero, sleeping on chan struct spinlock lock;
struct proc *waiters; struct proc *waiters;
void *chan; // If non-zero, sleeping on chan
}; };
struct runq { struct runq {
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论