Skip to content

Commit

Permalink
fix various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 8, 2007
1 parent bda5186 commit 00d0f79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 0 additions & 12 deletions BUGS
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,13 @@ main.c:
cpus[0] -> cpus[bcpu]

proc.c:
comment at top of scheduler() should say
via longjmp back to the scheduler
not
via longjmp back to the top of scheduler

sched should panic if state == RUNNING.

forkret comment should say "Return" not "return"

as a consequence of the implementation of proc_kill,
any loop calling sleep should check for p->killed
and be able to break out with an error return.

can swap procdump up after proc_kill
and then have proc_exit and proc_wait on same sheet

proc_exit should wake up proc[1] if any
reparenting was done.

sched -> switch2scheduler? or just switch?

factor out switching and scheduling code from process code
Expand Down
11 changes: 9 additions & 2 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ sched(void)
{
struct proc *p = curproc[cpu()];

if(p->state == RUNNING)
panic("sched running");
if(!holding(&proc_table_lock))
panic("sched");
panic("sched proc_table_lock");
if(cpus[cpu()].nlock != 1)
panic("sched locks");

Expand Down Expand Up @@ -334,6 +336,9 @@ proc_exit(void)
struct proc *cp = curproc[cpu()];
int fd;

if(cp->pid == 1)
panic("init exiting");

// Close all open files.
for(fd = 0; fd < NOFILE; fd++){
if(cp->ofile[fd]){
Expand All @@ -354,8 +359,10 @@ proc_exit(void)

// Reparent our children to process 1.
for(p = proc; p < &proc[NPROC]; p++)
if(p->ppid == cp->pid)
if(p->ppid == cp->pid){
p->ppid = 1;
wakeup1(&proc[1]); // init
}

// Jump into the scheduler, never to return.
cp->killed = 0;
Expand Down

0 comments on commit 00d0f79

Please sign in to comment.