[PATCH] Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RR

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Tue Dec 3 15:23:30 GMT 2024


On 2024-12-03 06:13, Corinna Vinschen wrote:
> On Dec  3 10:20, Christian Franke wrote:
>> Brian Inglis wrote:
>>> On 2024-12-02 11:28, ASSI wrote:
>>>> Christian Franke writes:
>>>>> +    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
>>>>
>>>> That mapping looks odd… care to explain why the number of nice values
>>>> and sched_priorities doesn't match up for each priority class? 39
>>>> possible values for one can't match to 32 for the other of course, but
>>>> which ones are skipped and why?
>>>
>>> See also miscfuncs.cc which maps nice<->winprio with a 40 entry table,
>>> and cygwin-doc proc(5) or cygwin-ug-net/proc.html which explains the
>>> mapping to scheduler priorities and policies.
>>
>> No *_PRIORITY_CLASS is mentioned in current newlib-cygwin/winsup/doc/*.

>>> Also relevant may be man-pages-posix sched.h(0p), man-pages-linux
>>> sched(7) and proc_pid_stat(5).
>>>
>>> You may also wish to consider whether SCHED_SPORADIC should be somewhat
>>> supported for POSIX compatibility, and SCHED_IDLE, SCHED_BATCH,
>>> SCHED_DEADLINE for Linux compatibility?
>>
>> SCHED_IDLE: Ignore nice value and set IDLE_PRIORITY_CLASS ?
> 
> Would make sense, I guess.
> 
>> SCHED_BATCH: Reduced mapping, e.g. nice=0 -> BELOW_NORMAL_PRIORITY_CLASS ?
> 
> Sounds good.
> 
>> SCHED_SPORADIC, SCHED_DEADLINE: ?
> 
> We can't model SCHED_DEADLINE in Windows.
> 
>> The current newlib/libc/include/sys/sched.h only defines SCHED_OTHER,
>> SCHED_FIFO, SCHED_RR and SCHED_SPORADIC. The latter is guarded by
>> _POSIX_SPORADIC_SERVER which is only set for RTEMS (#ifdef __rtems__) in
>> features.h.
> 
> SCHED_SPORADIC is a bit of a problem.  It requires extension of the
> sched_param struct with values we're not able to handle.

=> SCHED_IDLE?
Could be something like a background process on a real time system?

> Also, SCHED_SPORADIC doesn't exist in Linux either, so why bother.

	https://pubs.opengroup.org/onlinepubs/9799919799/

sched.h Change History:

"Sporadic server members are added to the sched_param structure, and the 
SCHED_SPORADIC scheduling policy is added for alignment with IEEE Std 1003.1d-1999."

It's been in POSIX since at least Issue 6 thru 8, with no changes in last go 
round, so presumably it exists and is used on some major platform(s)?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin-patches mailing list