Skip to content

Commit

Permalink
drop lock of process_map before yielding to other tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zen4647 committed Sep 27, 2024
1 parent e0cbc0f commit 2431ea7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/ruxos_posix_api/src/imp/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ pub fn sys_wait4(
} else if options & WNOHANG != 0 {
return 0; // No child process
}
// for single-cpu system, we must yield to other tasks instead of dead-looping here.
yield_now();
} else {
return -1; // No such process
}
// drop lock before yielding to other tasks
drop(process_map);
// for single-cpu system, we must yield to other tasks instead of dead-looping here.
yield_now();
}
} else if pid == -1 {
let mut to_remove: Option<u64> = None;
Expand All @@ -104,6 +106,8 @@ pub fn sys_wait4(
if options & WNOHANG != 0 {
return 0; // No child process
}
// drop lock before yielding to other tasks
drop(process_map);
// for single-cpu system, we must yield to other tasks instead of dead-looping here.
yield_now();
}
Expand Down

0 comments on commit 2431ea7

Please sign in to comment.