From 2431ea727f740def1aca95c7d6855fbb56e95055 Mon Sep 17 00:00:00 2001 From: WuZheng Date: Fri, 27 Sep 2024 16:43:02 +0800 Subject: [PATCH] drop lock of `process_map` before yielding to other tasks --- api/ruxos_posix_api/src/imp/task.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/ruxos_posix_api/src/imp/task.rs b/api/ruxos_posix_api/src/imp/task.rs index 19db94bc..eb93268f 100644 --- a/api/ruxos_posix_api/src/imp/task.rs +++ b/api/ruxos_posix_api/src/imp/task.rs @@ -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 = None; @@ -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(); }