[newlib-cygwin/cygwin-3_5-branch] Cygwin: sched_setscheduler: allow changes of the priority

Corinna Vinschen corinna@sourceware.org
Wed Nov 27 17:16:42 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=96d729bc00a13a0c870701262745209e1ad59456

commit 96d729bc00a13a0c870701262745209e1ad59456
Author:     Christian Franke <christian.franke@t-online.de>
AuthorDate: Wed Nov 27 16:39:37 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Nov 27 18:08:53 2024 +0100

    Cygwin: sched_setscheduler: allow changes of the priority
    
    Behave like sched_setparam() if the requested policy is identical
    to the fixed value (SCHED_FIFO) returned by sched_getscheduler().
    
    Fixes: 9a08b2c02eea ("* sched.cc: New file.  Implement sched*.")
    Signed-off-by: Christian Franke <christian.franke@t-online.de>
    (cherry picked from commit 522f3e921aa034c6a146021a918ce8b479a9111e)

Diff:
---
 winsup/cygwin/release/3.5.5 | 3 +++
 winsup/cygwin/sched.cc      | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.5.5 b/winsup/cygwin/release/3.5.5
index d91f2b92cd06..d41d168c6e7a 100644
--- a/winsup/cygwin/release/3.5.5
+++ b/winsup/cygwin/release/3.5.5
@@ -45,3 +45,6 @@ Fixes:
 
 - Fix segfault in sigtimedwait() when using timeout.
   Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256762.html
+
+- sched_setscheduler(2) allows to change the priority if the policy is
+  equal to the value returned by sched_getscheduler(2).
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc
index 39d0ed96bbf6..a37e4f8b2faa 100644
--- a/winsup/cygwin/sched.cc
+++ b/winsup/cygwin/sched.cc
@@ -402,8 +402,11 @@ int
 sched_setscheduler (pid_t pid, int policy,
 		    const struct sched_param *param)
 {
+  if (policy == SCHED_FIFO) /* returned by sched_getscheduler. */
+    return sched_setparam (pid, param);
+
   /* on win32, you can't change the scheduler. Doh! */
-  set_errno (ENOSYS);
+  set_errno (EINVAL);
   return -1;
 }


More information about the Cygwin-cvs mailing list