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(3)						     Library Functions Manual							  sleep(3)

NAME
sleep - Suspends execution for an interval of time LIBRARY
Standard C Library (libc.a) Threads Library (libpthreads.a) SYNOPSIS
#include <unistd.h> unsigned int sleep ( unsigned int seconds ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: sleep(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the number of seconds to sleep. DESCRIPTION
The sleep() function suspends execution of a process for the interval specified by the seconds parameter. The suspension time may be longer than requested due to the scheduling of other activity by the system. In a multi-threaded environment, the sleep() function is redefined so that only the calling thread is suspended. RETURN VALUES
If the sleep() function returns because the requested time has elapsed, it returns 0 (zero). If the sleep() function returns because it caught a signal, the function returns the number of seconds remaining in the suspension. RELATED INFORMATION
Commands: wall(1), shutdown(8) sleep(1) Functions: sigaction(2), alarm(3), pause(3) Standards: standards(5) delim off sleep(3)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy