提交 33d26bc4 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

fix

上级 3beaa242
...@@ -23,8 +23,7 @@ pinit(void) ...@@ -23,8 +23,7 @@ pinit(void)
int i; int i;
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
ptables[c].nextpid = 1; ptables[c].nextpid = (c << 16) | (1);
ptables[c].name[0] = (char) (c + '0'); ptables[c].name[0] = (char) (c + '0');
safestrcpy(ptables[c].name+1, "ptable", MAXNAME-1); safestrcpy(ptables[c].name+1, "ptable", MAXNAME-1);
initlock(&ptables[c].lock, ptables[c].name); initlock(&ptables[c].lock, ptables[c].name);
...@@ -50,7 +49,6 @@ allocproc(void) ...@@ -50,7 +49,6 @@ allocproc(void)
{ {
struct proc *p; struct proc *p;
char *sp; char *sp;
int pid;
acquire(&ptable->lock); acquire(&ptable->lock);
for(p = ptable->proc; p < &ptable->proc[NPROC]; p++) for(p = ptable->proc; p < &ptable->proc[NPROC]; p++)
...@@ -60,9 +58,8 @@ allocproc(void) ...@@ -60,9 +58,8 @@ allocproc(void)
return 0; return 0;
found: found:
pid = ptable->nextpid++;
p->state = EMBRYO; p->state = EMBRYO;
p->pid = (cpu->id & 0xFFFF) << 16 | (pid & 0xFFFF); p->pid = ptable->nextpid++;
release(&ptable->lock); release(&ptable->lock);
// Allocate kernel stack if possible. // Allocate kernel stack if possible.
...@@ -382,9 +379,9 @@ scheduler(void) ...@@ -382,9 +379,9 @@ scheduler(void)
struct proc *p; struct proc *p;
int pid; int pid;
acquire(&ptable.lock); acquire(&ptable->lock);
pid = nextpid++; pid = ptable->nextpid++;
release(&ptable.lock); release(&ptable->lock);
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys. // Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpunum()); // mtrace_call_set(1, cpunum());
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论