1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

Kernel: Move block condition evaluation out of the Scheduler

This makes the Scheduler a lot leaner by not having to evaluate
block conditions every time it is invoked. Instead evaluate them as
the states change, and unblock threads at that point.

This also implements some more waitid/waitpid/wait features and
behavior. For example, WUNTRACED and WNOWAIT are now supported. And
wait will now not return EINTR when SIGCHLD is delivered at the
same time.
This commit is contained in:
Tom 2020-11-29 16:05:27 -07:00 committed by Andreas Kling
parent 6a620562cc
commit 046d6855f5
53 changed files with 2027 additions and 930 deletions

View file

@ -56,12 +56,22 @@ pid_t waitpid(pid_t waitee, int* wstatus, int options)
id = waitee;
}
// To be able to detect if a child was found when WNOHANG is set,
// we need to clear si_pid, which will only be set if it was found.
siginfo.si_pid = 0;
int rc = waitid(idtype, id, &siginfo, options | WEXITED);
if (rc < 0)
return rc;
if (wstatus) {
if ((options & WNOHANG) && siginfo.si_pid == 0) {
// No child in a waitable state was found. All other fields
// in siginfo are undefined
*wstatus = 0;
return 0;
}
switch (siginfo.si_code) {
case CLD_EXITED:
*wstatus = siginfo.si_status << 8;