[PATCH] Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RR
Christian Franke
Christian.Franke@t-online.de
Mon Dec 2 17:33:10 GMT 2024
Corinna Vinschen wrote:
> On Nov 29 18:48, Christian Franke wrote:
>> A very first attempt to let sched_setscheduler() do something possibly
>> useful.
>>
>> This patch is on top of
>> Cygwin: setpriority, sched_setparam: add missing process access right
>
> Looks quite nice. If you're confident this is ready for the main
> branch, just give the word!
Yes, initial tests look good. Related documentation update attached.
-------------- next part --------------
From 7b422c55a120c523550efc3423f230630d082fac Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Mon, 2 Dec 2024 18:27:22 +0100
Subject: [PATCH] Cygwin: doc: document sched_setpolicy(2) and priority mapping
Document the long standing mapping from nice or sched_priority
values to Windows priority classes and the new behavior of
sched_setpolicy(8).
Signed-off-by: Christian Franke <christian.franke@t-online.de>
---
winsup/doc/posix.xml | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml
index 89056915b..436ab00a7 100644
--- a/winsup/doc/posix.xml
+++ b/winsup/doc/posix.xml
@@ -601,7 +601,7 @@ also IEEE Std 1003.1-2017 (POSIX.1-2017).</para>
nexttowardf
nexttowardl
nftw
- nice
+ nice (see <xref linkend="std-notes">chapter "Implementation Notes"</xref>)
nl_langinfo
nl_langinfo_l
nrand48
@@ -818,8 +818,8 @@ also IEEE Std 1003.1-2017 (POSIX.1-2017).</para>
sched_getparam
sched_getscheduler
sched_rr_get_interval
- sched_setparam
- sched_setscheduler
+ sched_setparam (see <xref linkend="std-notes">chapter "Implementation Notes"</xref>)
+ sched_setscheduler (see <xref linkend="std-notes">chapter "Implementation Notes"</xref>)
sched_yield
seed48
seekdir
@@ -854,7 +854,7 @@ also IEEE Std 1003.1-2017 (POSIX.1-2017).</para>
setlogmask
setpgid
setpgrp
- setpriority
+ setpriority (see <xref linkend="std-notes">chapter "Implementation Notes"</xref>)
setprotoent
setpwent
setregid
@@ -1769,6 +1769,32 @@ atomic either. Over-allocation with FALLOC_FL_KEEP_SIZE is only
temporary on Windows until the last handle to the file is closed.
Over-allocation on sparse files is entirely ignored on Windows.</para>
+<para><function>sched_setpolicy</function> only emulates API behavior
+because Windows does not offer alternative scheduling policies.
+If <literal>SCHED_OTHER</literal> is selected, the Windows priority is
+set according to the nice value. If <literal>SCHED_FIFO</literal>
+or <literal>SCHED_RR</literal> is selected, the nice value is preserved
+and the Windows priority is set according to the
+<literal>sched_priority</literal> value.</para>
+
+<para><function>nice</function>, <function>setpriority</function>,
+<function>sched_setparam</function> and <function>sched_setpolicy</function>
+map the nice value (<literal>SCHED_OTHER</literal>) or the
+<literal>sched_priority</literal> (<literal>SCHED_FIFO</literal>,
+<literal>SCHED_RR</literal>) to Windows priority classes as follows:</para>
+<screen>
+ nice value sched_priority Windows priority class
+ 12...19 1....6 IDLE_PRIORITY_CLASS
+ 4...11 7...12 BELOW_NORMAL_PRIORITY_CLASS
+ -4....3 13...18 NORMAL_PRIORITY_CLASS
+ -12...-5 19...24 ABOVE_NORMAL_PRIORITY_CLASS
+ -13..-19 25...30 HIGH_PRIORITY_CLASS
+ -20 31...32 REALTIME_PRIORITY_CLASS
+</screen>
+The use of values which are mapped to the
+<literal>REALTIME_PRIORITY_CLASS</literal> require administrative
+privileges.
+
</sect1>
</chapter>
--
2.45.1
More information about the Cygwin-patches
mailing list