Did you know ... Search Documentation:
sched.pl -- Access process scheduling
PublicShow source

This library provides an interface to the process scheduling facilities of the operating system. It is based on the sched(7) manual page from Linux.

Source setpriority(+Which, +Who, +Priority) is det
Source getpriority(+Which, +Who, +Priority) is det
Get/set the priority of a single process or set of processed. Note that on Linux threads are similar to processes and this interface also applies to threads. The PID of a Prolog thread is accessible through thread_property/2. Which is one of
Specify a single process/thread. Who is the PID of the process.
Specify a process group. Who is the process group indentifier. Currently SWI-Prolog has no interface to process groups.
Specify all processes owned by a user. Who is the numeric user id of the target user.

Priority is the nice value of the process and is an integer in the range -20..20, where lower numbers denote a higher priority. Who can be 0 (zero) to specify the calling process, process group or user.

Please consult the scheduler documentation of your operating system before using setpriority/3. Unix systems generally schedule a process at a given priority only if there is no process with a higher priority (lower nice value) in runnable state.

For example, to lower the priority of the gc thread we can use the call below. Note that this may cause GC to never run.

?- thread_property(gc, system_thread_id(PID)),
   setpriority(process, PID, 5).
- existence_error(Which, Who)
- permission_error(setpriority, Which, Who)