Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 8

ClockId(), ClockId_r()

Get a clock ID for a given process and thread

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 ); 

Arguments:

pid
The ID of the process that you want to calculate the execution time 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 calculate the execution time for, or 0 to get the execution time 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 return an integer that you can pass as a clockid_t to ClockTime(). When you pass this clock ID to ClockTime(), the function returns (in the location pointed to by old) the number of nanoseconds that the specified thread of the specified process has executed.

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().

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.

Blocking states:

This call doesn't block.

Returns:

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

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:

ClockTime(), clock_getcpuclockid(), pthread_getcpuclockid()

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


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 201

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/clockid.html on line 201