summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-08 08:57:37 +0000
committerrsc <rsc>2007-08-08 08:57:37 +0000
commit00d0f794cfd7a1df3b73f28028c8768bae3fef09 (patch)
tree2b955fe2559c1a26b1ce7afec43fb6695dd852f6
parentbda5186c0d6baee0f45b543513ffb0f629c9f348 (diff)
downloadxv6-labs-00d0f794cfd7a1df3b73f28028c8768bae3fef09.tar.gz
xv6-labs-00d0f794cfd7a1df3b73f28028c8768bae3fef09.tar.bz2
xv6-labs-00d0f794cfd7a1df3b73f28028c8768bae3fef09.zip
fix various bugs
-rw-r--r--BUGS12
-rw-r--r--proc.c11
2 files changed, 9 insertions, 14 deletions
diff --git a/BUGS b/BUGS
index daa26ca..0c6f14b 100644
--- a/BUGS
+++ b/BUGS
@@ -12,15 +12,6 @@ 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.
@@ -28,9 +19,6 @@ proc.c:
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
diff --git a/proc.c b/proc.c
index c7b6c85..9eaca99 100644
--- a/proc.c
+++ b/proc.c
@@ -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");
@@ -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]){
@@ -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;