Sponsored Content
Full Discussion: RDTSC use in C:
Top Forums Programming RDTSC use in C: Post 302324893 by otheus on Friday 12th of June 2009 06:47:03 AM
Old 06-12-2009
Sivaraman,

I need to re-phrase your question --- please tell me if this is correct: How does one find out (on Linux) whether the CPU is actually running at the speed specified in cpuinfo?

Instead of the sleep statement above, set an alarm for 10 seconds, do some CPU-intensive work, get the number of ticks, compare the clocks to find how long the CPU actually slept (setting an alarm does not guarantee anything) and calculate. Use gettimeofday() to get the actual time.
 
alarm(2)							System Calls Manual							  alarm(2)

NAME
alarm - set a process's alarm clock SYNOPSIS
DESCRIPTION
instructs the alarm clock of the calling process to send the signal to the calling process after the number of real-time seconds specified by sec have elapsed; see signal(5). Specific implementations might place limitations on the maximum supported alarm time. The constant defined in specifies the implementation-specific maximum. Whenever sec is greater that this maximum, it is silently rounded down to it. On all implementations, is guaranteed to be at least 31 days (in seconds). Alarm requests are not stacked; successive calls reset the alarm clock of the calling process. If sec is 0, any previously made alarm request is canceled. Alarms are not inherited by a child process across a but are inherited across an On systems that support the and system calls, the timer mechanism used by is the same as that used by Thus successive calls to and set and return the state of a single timer. In addition, sets the timer interval to zero. RETURN VALUE
returns the amount of time previously remaining in the alarm clock of the calling process. WARNINGS
In some implementations, error bounds for alarm are -1, +0 seconds (for the posting of the alarm, not the restart of the process). Thus a delay of 1 second can return immediately. The routine can be used to create a more precise delay. SEE ALSO
sleep(1), exec(2), getitimer(2), pause(2), signal(5), sleep(3C). STANDARDS CONFORMANCE
alarm(2)
All times are GMT -4. The time now is 05:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy