Get the CPU-time clock ID for a given process and thread
#include <sys/neutrino.h> #include <inttypes.h> int ClockId( pid_t pid, int tid ); int ClockId_r( pid_t pid, int tid );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The ClockId() and ClockId_r() kernel calls retrieve the clock ID of a process or thread CPU-time clock. These clocks represent the amount of time the process or thread has spent running. See Monitoring execution times in the 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.
Blocking states:
These calls don't block.
A clock ID for a process or thread CPU-time clock. If an error occurs:
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); }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |