[PATCH 3/5] Revert "ntdll: Implement NtYieldExecution() as usleep()."

Matteo Bruni mbruni at codeweavers.com
Fri Nov 19 13:50:28 CST 2021


Rémi found a regression caused by that patch. His analysis suggests
that it's probably correct for NtYieldExecution() to map to
sched_yield().

Let's revert the patch and fix the issue in a slightly different way.

This reverts commit b1a79c6b9c3ada0c34b1411b60879962f1815e4d.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 configure.ac           | 1 +
 dlls/ntdll/unix/sync.c | 6 +++++-
 include/config.h.in    | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6631d2f42fc..72018825610 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,6 +1948,7 @@ AC_CHECK_FUNCS(\
 	posix_fallocate \
 	prctl \
 	proc_pidinfo \
+	sched_yield \
 	setproctitle \
 	setprogname \
 	sigprocmask \
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
index 0065f265e42..137d8d2c87d 100644
--- a/dlls/ntdll/unix/sync.c
+++ b/dlls/ntdll/unix/sync.c
@@ -1447,8 +1447,12 @@ NTSTATUS WINAPI NtSignalAndWaitForSingleObject( HANDLE signal, HANDLE wait,
  */
 NTSTATUS WINAPI NtYieldExecution(void)
 {
-    usleep(0);
+#ifdef HAVE_SCHED_YIELD
+    sched_yield();
     return STATUS_SUCCESS;
+#else
+    return STATUS_NO_YIELD_PERFORMED;
+#endif
 }
 
 
diff --git a/include/config.h.in b/include/config.h.in
index 0c843a0423c..0fe50e8ce7c 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -443,6 +443,9 @@
 /* Define to 1 if you have the `sched_setaffinity' function. */
 #undef HAVE_SCHED_SETAFFINITY
 
+/* Define to 1 if you have the `sched_yield' function. */
+#undef HAVE_SCHED_YIELD
+
 /* Define to 1 if `cmd' is a member of `scsireq_t'. */
 #undef HAVE_SCSIREQ_T_CMD
 
-- 
2.26.3




More information about the wine-devel mailing list