Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

System Information & Misc.

POSIX Clocks

clock_gettime

Supported functionality in SCML:

predefined_clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_MONOTONIC_RAW |
                     CLOCK_REALTIME_COARSE | CLOCK_MONOTONIC_COARSE | CLOCK_BOOTTIME |
                     CLOCK_PROCESS_CPUTIME_ID | CLOCK_THREAD_CPUTIME_ID;

// Get the time of a clock specified by a static ID
clock_gettime(clockid = <predefined_clockid>, tp);

// Get the time of a clock specified by a dynamic ID
clock_gettime(clockid = <INTEGER>, tp);

Unsupported predefined clock IDs:

  • CLOCK_REALTIME_ALARM
  • CLOCK_BOOTTIME_ALARM
  • CLOCK_TAI

For more information, see the man page.

clock_nanosleep

Supported functionality in SCML:

// Sleep with a specified clock
clock_nanosleep(
    clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_BOOTTIME | CLOCK_PROCESS_CPUTIME_ID,
    flags =
        // Optional flags:
        //
        // Sleep until an absolute time point
        TIMER_ABSTIME,
    t, remain
);

Unsupported clock IDs:

  • CLOCK_TAI

For more information, see the man page.

arch_prctl

Supported functionality in SCML:

// Get or set the FS register
arch_prctl(
    code = ARCH_GET_FS | ARCH_SET_FS,
    addr
);

Unsupported codes:

  • ARCH_GET_CPUID and ARCH_SET_CPUID
  • ARCH_GET_GS and ARCH_SET_GS

For more information, see the man page.

getrusage

Supported functionality in SCML:

// Return resource usage statistics for the calling process
getrusage(
    who = RUSAGE_SELF,
    usage
);

// Return resource usage statistics for the calling thread
getrusage(
    who = RUSAGE_THREAD,
    usage
);

Unsupported who flags:

  • RUSAGE_CHILDREN

For more information, see the man page.

getrandom

Supported functionality in SCML:

// Obtain random bytes
getrandom(
    buf, buflen,
    flags =
        // Optional flags:
        //
        // High-entropy pool
        GRND_RANDOM
);

Silently-ignored flags:

  • GRND_NONBLOCK because the underlying operation never blocks

For more information, see the man page.