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.
 
sleep(3UCB)					     SunOS/BSD Compatibility Library Functions					       sleep(3UCB)

NAME
sleep - suspend execution for interval SYNOPSIS
/usr/ucb/cc [ flag ... ] file ... int sleep( seconds); unsigned seconds; DESCRIPTION
sleep() suspends the current process from execution for the number of seconds specified by the argument. The actual suspension time may be up to 1 second less than that requested, because scheduled wakeups occur at fixed 1-second intervals, and may be an arbitrary amount longer because of other activity in the system. sleep() is implemented by setting an interval timer and pausing until it expires. The previous state of this timer is saved and restored. If the sleep time exceeds the time to the expiration of the previous value of the timer, the process sleeps only until the timer would have expired, and the signal which occurs with the expiration of the timer is sent one second later. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
alarm(2), getitimer(2), longjmp(3C), siglongjmp(3C), sleep(3C), usleep(3C), attributes(5) NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. SIGALRM should not be blocked or ignored during a call to sleep(). Only a prior call to alarm(2) should generate SIGALRM for the calling process during a call to sleep(). A signal-catching function should not interrupt a call to sleep() to call siglongjmp(3C) or longjmp(3C) to restore an environment saved prior to the sleep() call. WARNINGS
sleep() is slightly incompatible with alarm(2). Programs that do not execute for at least one second of clock time between successive calls to sleep() indefinitely delay the alarm signal. Use sleep(3C). Each sleep(3C) call postpones the alarm signal that would have been sent during the requested sleep period to occur one second later. SunOS 5.10 12 Feb 1993 sleep(3UCB)
All times are GMT -4. The time now is 08:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy