I am working on a bulk image processing program which does not require user attention and need to choose a priority level for this process.
The superuser is able to set values from PRI_MIN (-20) to PRI_MAX (+20) and normal users can set from 0 to PRI_MAX. The default level is zero.
On Mac OS X 10.11, the man nice(1)
documentation discusses priority levels and notes conformance to POSIX.2 (IEEE Std 1003.2-1992). However this documentation is not publicly available and, also, has been superseded.
Other than randomly picking a number between 0 and 20 inclusive, is there a prescribed, meaningful way to choose the priority level based on some POSIX or Mac standard?
Advertisement
Answer
The batch processing priority is often OS specific and generally is not covered by POSIX.
Check the sched.h
header, and the function sched_get_priority_min
. This is a newer more advanced interface, compared to the nice
.
Linux additionally supports SCHED_BATCH
and SCHED_IDLE
policies, while Mac OS X provides entirely different interface called Grand Central Dispatch with DISPATCH_QUEUE_PRIORITY_BACKGROUND
.