Up: Specifying a Run-Time Library   [Contents][Index]


7.2.1 Choosing the Scheduling Policy

When using a POSIX threads implementation, you have a choice of several scheduling policies: SCHED_FIFO, SCHED_RR and SCHED_OTHER.

Typically, the default is SCHED_OTHER, while using SCHED_FIFO or SCHED_RR requires special (e.g., root) privileges.

By default, GNAT uses the SCHED_OTHER policy. To specify SCHED_FIFO, you can use one of the following:

To specify SCHED_RR, you should use pragma Time_Slice with a value greater than 0.0, or else use the corresponding -T binder option.

To make sure a program is running as root, you can put something like this in a library package body in your application:

function geteuid return Integer;
pragma Import (C, geteuid, "geteuid");
Ignore : constant Boolean :=
  (if geteuid = 0 then True else raise Program_Error with "must be root");

It gets the effective user id, and if it’s not 0 (i.e. root), it raises Program_Error.