//============================================================================ // Name : clock_period.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include #include #include using namespace std; int main(int argc, char *argv[]) { struct _clockperiod clkper; if (argc != 1 && argc != 2) { cout << "Usage: clock_period " << endl; exit (0); } if (argc == 1) { /* display the current clock period */ ClockPeriod(CLOCK_REALTIME, NULL, &clkper, 0); cout << "ClockPeriod: " << clkper.nsec << " nsecs" << endl; } else { /* set new clock period */ clkper.nsec = atoi(argv[1]); clkper.fract = 0; ClockPeriod ( CLOCK_REALTIME, &clkper, NULL, 0 ); } return 0; }