diff options
author | Christian Franke <christian.franke@t-online.de> | 2024-12-09 12:14:07 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-12-12 10:32:00 +0100 |
commit | a31a6fe5dd36616ac4ccbb62958072413265e563 (patch) | |
tree | 8e580f1aaaebd3ef69e1fa041757b0cdb7853471 /winsup/cygwin/sched.cc | |
parent | a0527e37869e8e3e467bbd106d6c77612df617c7 (diff) | |
download | newlib-a31a6fe5dd36616ac4ccbb62958072413265e563.zip newlib-a31a6fe5dd36616ac4ccbb62958072413265e563.tar.gz newlib-a31a6fe5dd36616ac4ccbb62958072413265e563.tar.bz2 |
Cygwin: sched_setscheduler: accept SCHED_BATCH
Add SCHED_BATCH to <sys/sched.h>. SCHED_BATCH is similar to SCHED_OTHER,
except that the nice value is mapped to a one step lower Windows priority.
Rework the mapping functions to ease the addition of this functionality.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Diffstat (limited to 'winsup/cygwin/sched.cc')
-rw-r--r-- | winsup/cygwin/sched.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc index 8b4e7ef..ec62ea8 100644 --- a/winsup/cygwin/sched.cc +++ b/winsup/cygwin/sched.cc @@ -34,6 +34,7 @@ sched_get_priority_max (int policy) switch (policy) { case SCHED_OTHER: + case SCHED_BATCH: case SCHED_IDLE: return 0; case SCHED_FIFO: @@ -51,6 +52,7 @@ sched_get_priority_min (int policy) switch (policy) { case SCHED_OTHER: + case SCHED_BATCH: case SCHED_IDLE: return 0; case SCHED_FIFO: @@ -95,7 +97,8 @@ sched_getparam (pid_t pid, struct sched_param *param) return -1; } - if (p->sched_policy == SCHED_OTHER || p->sched_policy == SCHED_IDLE) + if (p->sched_policy == SCHED_OTHER || p->sched_policy == SCHED_BATCH + || p->sched_policy == SCHED_IDLE) { /* No realtime policy. */ param->sched_priority = 0; @@ -234,9 +237,10 @@ sched_setparam_pinfo (pinfo & p, const struct sched_param *param) /* calculate our desired priority class. We only reserve a small area (31/32) for realtime priority. */ DWORD pclass; - if (p->sched_policy == SCHED_OTHER && pri == 0) + bool batch = (p->sched_policy == SCHED_BATCH); + if ((p->sched_policy == SCHED_OTHER || batch) && pri == 0) /* No realtime policy, reapply the nice value. */ - pclass = nice_to_winprio (p->nice); + pclass = nice_to_winprio (p->nice, batch); else if (p->sched_policy == SCHED_IDLE && pri == 0) /* Idle policy, ignore the nice value. */ pclass = IDLE_PRIORITY_CLASS; @@ -422,8 +426,9 @@ sched_setscheduler (pid_t pid, int policy, const struct sched_param *param) { if (!(pid >= 0 && param && - (((policy == SCHED_OTHER || policy == SCHED_IDLE) && param->sched_priority == 0) || - ((policy == SCHED_FIFO || policy == SCHED_RR) && valid_sched_parameters(param))))) + (((policy == SCHED_OTHER || policy == SCHED_BATCH || policy == SCHED_IDLE) + && param->sched_priority == 0) || ((policy == SCHED_FIFO || policy == SCHED_RR) + && valid_sched_parameters(param))))) { set_errno (EINVAL); return -1; |