usertests and optional finished

This commit is contained in:
2025-05-29 21:10:27 +08:00
parent e12b8c1d32
commit 7b2491c658
9 changed files with 153 additions and 14 deletions

View File

@ -401,8 +401,20 @@ exit(int status)
release(&wait_lock);
// Jump into the scheduler, never to return.
// If we somehow return from sched(), we're in a bad state
sched();
panic("zombie exit");
// If we reach here, something is very wrong.
// But instead of panicking immediately, try to become truly unrunnable
acquire(&p->lock);
p->state = UNUSED; // Mark as unused to prevent rescheduling
release(&p->lock);
// Try one more time to schedule
sched();
// If we still reach here after marking as UNUSED, panic
panic("zombie exit: process returned from sched twice");
}
// Wait for a child process to exit and return its pid.