Clean up using killed()

This commit is contained in:
Frans Kaashoek 2022-08-11 07:23:17 -04:00
parent 4087a6e7fc
commit 975f3b31d3
6 changed files with 14 additions and 7 deletions

View file

@ -422,7 +422,7 @@ wait(uint64 addr)
}
// No point waiting if we don't have any children.
if(!havekids || __sync_add_and_fetch(&p->killed, 0)){
if(!havekids || killed(p)){
release(&wait_lock);
return -1;
}
@ -601,6 +601,12 @@ kill(int pid)
return -1;
}
int
killed(struct proc *p)
{
return __sync_add_and_fetch(&p->killed, 0);
}
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.