1833788 Members
2651 Online
110063 Solutions
New Discussion

Re: Timer Setting

 
Pramod Sharma
Occasional Contributor

Timer Setting

Clock resolution as mentioned in the man page of system call 'setitimer' is 1/HZ sec and value of this constant 'HZ' is defined in include file ,which is 100 . That means the smallest interval timer can only be 10 ms .Is there anyway by which we can reduce it to say 1/10 ms or 1 ms as desired by our application.What is the smalles clock resolution we can get on the system .we are using system HP-UX workstation b2600.
do good, have good
2 REPLIES 2
Graham Cameron_1
Honored Contributor

Re: Timer Setting

Hi

In the context of setitmer it looks like you are right.

However, the kernel can handle much smaller time increments, via the selct() or nanosleep() calls.

see "man nanosleep".

NB also
# getconf CLOCKS_PER_SEC
1000000
# getconf CLK_TCK
100

Hope this helps.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
A. Clay Stephenson
Acclaimed Contributor

Re: Timer Setting

You want to make use of the gettimeofday() system call. Although it has microsecond precision the actual resolution is typically a few milliseconds.
If it ain't broke, I can fix that.