[Previous] [Contents] [Next]

ClockId(), ClockId_r()

Return an integer to be used as a clockid_t

Synopsis:

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

extern int ClockId( pid_t pid, 
                    int tid ); 

extern int ClockId_r( pid_t pid, 
                      int tid ); 

Library:

libc

Description:

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

The ClockId() and ClockId_r() functions return an integer that's passed to ClockTime() as a clockid_t. When this clock ID is used, ClockTime() returns (in the location pointed to by old) the number of nanoseconds that the specified thread of the specified process has executed.

If the tid is zero, the number of nanoseconds that the process as a whole has executed is returned. On an SMP box, this number may exceed the realtime number of nanoseconds that have elapsed because multiple threads in the process can run on several CPUs at the same time.

If the pid is zero, the pid of the process making the call is assumed.

Blocking states:

This call doesn't block.

Returns:

ClockId()
An integer that can be passed to ClockTime(). If an error occurs, -1 is returned and errno is set.
ClockId_r()
An integer that can be passed to ClockTime(). This function does NOT set errno. If an error occurs, the negative of a value from the Errors section is returned.

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 6

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

See also:

ClockTime(), clock_getcpuclockid(), pthread_getcpuclockid()


[Previous] [Contents] [Next]