Skip to content
Snippets Groups Projects
Commit cf3dbc6c authored by Fache Charles's avatar Fache Charles
Browse files

WIP Q1.1, added a few lines, kernel crashes on boot

parent 3586c456
No related branches found
No related tags found
No related merge requests found
......@@ -21,3 +21,4 @@ myapi.key
xv6.out*
.vagrant/
submissions/
.~lock.*
File added
......@@ -254,7 +254,11 @@ userinit(void)
{
struct proc *p;
acquire(&prio_lock);
p = allocproc();
if (p != 0) {
insert_into_prio_queue(p);
}
initproc = p;
// allocate one user page and copy init's instructions
......@@ -272,6 +276,7 @@ userinit(void)
p->state = RUNNABLE;
release(&p->lock);
release(&prio_lock);
}
// Grow or shrink user memory by n bytes.
......@@ -456,6 +461,7 @@ wait(uint64 addr)
if(np->parent == p){
// np->parent can't change between the check and the acquire()
// because only the parent changes it, and we're the parent.
acquire(&prio_lock);
acquire(&np->lock);
havekids = 1;
if(np->state == ZOMBIE){
......@@ -465,11 +471,14 @@ wait(uint64 addr)
sizeof(np->xstate)) < 0) {
release(&np->lock);
release(&p->lock);
release(&prio_lock);
return -1;
}
freeproc(np);
remove_from_prio_queue(np);
release(&np->lock);
release(&p->lock);
release(&prio_lock);
return pid;
}
release(&np->lock);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment