ClockId(), ClockId_r()

Get the CPU-time clock ID for a given process and thread

Synopsis:

#include <sys/neutrino.h>
#include <inttypes.h>

int ClockId( pid_t pid, 
             int tid ); 

int ClockId_r( pid_t pid, 
               int tid ); 

Arguments:

pid
The ID of the process that you want to get the clock ID for. If this argument is zero, the ID of the process making the call is assumed.
tid
The ID of the thread that you want to get the clock ID for, or 0 to get the clock ID for the process as a whole.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The ClockId() and ClockId_r() kernel calls retrieve the clock ID of a process or thread CPU-time clock. These clocks represent the approximate amount of time that the process or thread has spent running. See Monitoring execution times in the Tick, Tock: Understanding the Microkernel's Concept of Time chapter of the QNX Neutrino Programmer's Guide.

The ClockId() and ClockId_r() functions are identical except in the way they indicate errors. See the Returns section for details.


Note: Instead of using these kernel calls directly, consider calling clock_getcpuclockid() or pthread_getcpuclockid().

Blocking states:

These calls don't block.

Returns:

A clock ID for a process or thread CPU-time clock. If an error occurs:

Errors:

ESRCH
The pid and/or tid don't exist.

Examples:

Here's how you can determine how busy a system is:

id = ClockId(1, 1);
for( ;; ) {
    ClockTime(id, NULL, &start);
    sleep(1);
    ClockTime(id, NULL, &stop);
    printf("load = %f%%\n", (1000000000.0 - (stop-start)) / 10000000.0);
}

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

clock_getcpuclockid(), clock_gettime(), ClockTime(), clock_getcpuclockid(), pthread_getcpuclockid()

Clocks, Timers, and Getting a Kick Every So Often chapter of Getting Started with QNX Neutrino

Monitoring execution times in the Tick, Tock: Understanding the Microkernel's Concept of Time chapter of the QNX Neutrino Programmer's Guide.