diff options
author | Bruce Cran <bruce.cran@gmail.com> | 2016-10-12 03:22:47 +0100 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-10-12 08:58:36 -0600 |
commit | 24a2bb13ec8e449fd5e30967420894f88cdad11a (patch) | |
tree | 63586a54874876fecabe73fdcfa7ae5921ad63db /os/windows/posix.c | |
parent | d23ae82785f99927331e358d2c0deac5e53f2df1 (diff) | |
download | fio-24a2bb13ec8e449fd5e30967420894f88cdad11a.tar.gz fio-24a2bb13ec8e449fd5e30967420894f88cdad11a.tar.bz2 |
Implement nice() for Windows
Map the following ranges for the "nice" option:
Less than -15: High
-1 through -15: Above normal
0: Normal
1 through 15: Below normal
More than 15: Low/Idle
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'os/windows/posix.c')
-rwxr-xr-x | os/windows/posix.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/os/windows/posix.c b/os/windows/posix.c index 33881278..bbd93e97 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -647,10 +647,19 @@ int setgid(gid_t gid) int nice(int incr) { - if (incr != 0) { - errno = EINVAL; - return -1; - } + DWORD prioclass = NORMAL_PRIORITY_CLASS; + + if (incr < -15) + prioclass = HIGH_PRIORITY_CLASS; + else if (incr < 0) + prioclass = ABOVE_NORMAL_PRIORITY_CLASS; + else if (incr > 15) + prioclass = IDLE_PRIORITY_CLASS; + else if (incr > 0) + prioclass = BELOW_NORMAL_PRIORITY_CLASS; + + if (!SetPriorityClass(GetCurrentProcess(), prioclass)) + log_err("fio: SetPriorityClass failed\n"); return 0; } |