Skip to content
Snippets Groups Projects
Commit 65012bf1 authored by Videau Luc's avatar Videau Luc
Browse files

:sparkles:feat: Question 1.2

parent 3586c456
No related branches found
No related tags found
No related merge requests found
......@@ -253,10 +253,14 @@ void
userinit(void)
{
struct proc *p;
acquire(&prio_lock);
p = allocproc();
initproc = p;
insert_into_prio_queue(p);
release(&prio_lock);
// allocate one user page and copy init's instructions
// and data into it.
uvminit(p->pagetable, initcode, sizeof(initcode));
......@@ -303,6 +307,8 @@ fork(void)
struct proc *np;
struct proc *p = myproc();
acquire(&prio_lock);
// Allocate process.
if((np = allocproc()) == 0){
return -1;
......@@ -333,9 +339,12 @@ fork(void)
safestrcpy(np->name, p->name, sizeof(p->name));
np->cmd = strdup(p->cmd);
pid = np->pid;
np->priority=p->priority;
np->state = RUNNABLE;
insert_into_prio_queue(np);
release(&prio_lock);
release(&np->lock);
return pid;
......@@ -413,6 +422,7 @@ exit(int status)
// we need the parent's lock in order to wake it up from wait().
// the parent-then-child rule says we have to lock it first.
acquire(&prio_lock);
acquire(&original_parent->lock);
acquire(&p->lock);
......@@ -428,6 +438,10 @@ exit(int status)
release(&original_parent->lock);
remove_from_prio_queue(p);
release(&prio_lock);
// Jump into the scheduler, never to return.
sched();
panic("zombie exit");
......
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