## gs-ioprio gs-ioprio |

## Functions

void | gs_ioprio_set ()
void | gs_set_thread_cpu_niceness ()

## Description

## Functions

### gs_ioprio_set ()

    void
    gs_ioprio_set (gint priority);

Set the I/O priority of the current thread using the ``ioprio_set()`` syscall.

The `priority` is quantised before being passed to the kernel.

This function may fail if the process doesn’t have permission to change its I/O priority to the given value. If so, a warning will be printed, as the quantised priority values are chosen so they shouldn’t typically require permissions to set.

#### Parameters

priority | I/O priority, with higher numeric values indicating lower priority; use `G_PRIORITY_DEFAULT` as the default |

### gs_set_thread_cpu_niceness ()

    void
    gs_set_thread_cpu_niceness (GDBusConnection *system_bus_connection,
                                pid_t tid,
                                int niceness);

Set the CPU niceness of the given thread using RealtimeKit.

This is essentially equivalent to calling `setpriority (PRIO_PROCESS, tid, niceness)`, or calling `nice (niceness)` from within the given thread. However, either of those syscalls require the `CAP_SYS_NICE` capability, which would also allow the process to _raise_ its priority. That is a capability we don’t want to have. Requesting the niceness change to happen via RealtimeKit means that it’s done using RealtimeKit’s `CAP_SYS_NICE` capability, and appropriate polkit permissions checks can be done, as well as checks on the requested `niceness` value.

This function may fail if the process doesn’t have permission to change its thread niceness priority to the given value. If so, *no* warning will be printed, as that would require waiting for a D-Bus round trip from RealtimeKit, which seems unnecessary given that the niceness values are chosen so they shouldn’t typically require permissions to set.

#### Parameters

system_bus_connection | a connection to the D-Bus system bus. | [transfer none]
tid | ID of the thread to change the niceness of |
niceness | new niceness (0 is default, >0 means lower scheduling priority, <0 means higher scheduling priority and is disallowed) |

Since: 50