Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > Kernel 2.6.27.7-9 for Suse 11.1 help required with CPU Clock freq/speed/ticks

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 11-17-2009   #1 (permalink)
Just Joined!
 
Join Date: Nov 2009
Posts: 1
Kernel 2.6.27.7-9 for Suse 11.1 help required with CPU Clock freq/speed/ticks

Problem Statement: High CPU clock speed/freq
Requirement: Obtain a stable CPU clock ticks/speed/freq on Suse 11.1 with kernel 2.6.27.7-9
Questions: Please refer to the bottom of this page


Artifacts in Use:
-----------------------------------
OS: Suse 11.1
GCC Version: 4.3.2 (Suse Linux) [gcc_4_3-brach revision 141291]
Kernel: 2.6.27.7-9
Kernel Mods:
* Un-check the Tickless option
* Timer Frequency - 1000Hz
* Preempt kernel

Others 1
-----------
OS: Suse 10.2
GCC Version: 4.1.2 20061115 (prerelease)(SUSE Linux)
Kernel: 2.6.18.2-34-default
Kernel Mods:
* Preemptible Kernel (Low-Latency Desktop) (NEW)
* Preempt The Big Kernel Lock (NEW)
* Timer frequency (NEW) - 1000 Hz (NEW)

Others 2
-----------
OS: Suse 9.3
GCC Version: 3.3.5 20050117 (prerelease)(SUSE Linux)
Kernel 2.6.11.4-20a-default
Kernel Mods: None

I executed the following c++ code on the above stated builds

code is in attached file as well

Code:
#include <signal.h>
#include <sys/time.h>
#include <iostream>
#include <cstdlib>


using namespace std;

long long int counter = 0;
struct timeval last_time;
struct timeval curr_time;
double dif = 0.0;
double freq_sum = 0.0;
double reps = 0.0;
double freq_min = 99999.0;
double freq_max = 0.0;
long long int num_too_low = 0;

void time_check(int data)
{
    // work out the frequecy of the SIGALRMs
    ++counter;
    if (counter >= 1000)
    {

        // need to work out time since last 1000 ticks
	gettimeofday(&curr_time, NULL);
	dif = ((curr_time.tv_usec + curr_time.tv_sec * 1000000)
		- (last_time.tv_usec + last_time.tv_sec * 1000000));
        double freq = (counter / dif)  * 1000000;

        freq_sum = ((freq_sum * reps) + freq) / (reps + 1) ;

        ++reps;
        cout << "Frequency = " << freq << " reps= " << dif / 1000000 << endl;
        if (freq_min > freq) freq_min = freq;
        if (freq_max < freq) freq_max = freq;
        if (freq < 950) 
            ++num_too_low;
        last_time = curr_time;
        counter = 0;
    }
}

int main (int argc, char * argv[])
{
    cout << "go" /* << "\a \a \a" */ << endl;
	
    int res;
    gettimeofday(&last_time, NULL);
    struct sigaction action;

    struct itimerval timer_value;

    timer_value.it_value.tv_sec = 0;
    timer_value.it_value.tv_usec = 1;
    timer_value.it_interval.tv_sec = 0;
    timer_value.it_interval.tv_usec = 1;

    action.sa_handler = time_check;
    action.sa_flags = SA_NOMASK;
    sigemptyset(&action.sa_mask);

    sigaction( SIGALRM, &action, NULL);
    res = setitimer( ITIMER_REAL, &timer_value, NULL );
    if (res == -1)
        cout << "error in setitimer" << endl;

    cout << "Starting CPU Test program" << endl;
    // loop for a long time

    while (reps < 3000.0)
    {
        sleep(1);
    }
    cout << "average CPU frequency = " << freq_sum << endl;
    cout << "reps = " << reps << endl;
    cout << "Min = " << freq_min << "  Max = " << freq_max << endl;
    cout << "number of low = " << num_too_low << endl;
    return 0;
}
Compiled the above code with "g++ test.cpp -o test"
Run the above code with "./test"

Code:
Observations:
SUSE Version    AVG. Frequency        		AVG. REPS
Suse 9.3  		999.xxx to 990.xxx  			reps > 1 (on average)
Suse 10.2 		999.xxx to 998.xxx  			reps (1 - 1.001)
Suse 10.3     	1000.xxx to 912.xxx  			reps (1 - 1.090)
Suse 11.1       0 to  324263.xxx  				reps (-2e-0.6 upto 0.005112)

Suse 11.1 - Options:

- Turn off ACPI in options when booting with clock=tsc | clock=pit

Observations for suse 11.1 with options acpi=off and clock=tsc | clock=pit

SUSE Version    AVG. Frequency        		AVG. REPS
Suse 11.1 		710.xxx to 999.xxx      		reps (1.37xx to 1.0002)
Hardware used for Suse 11.1 - HP Pavilion Slimline s3821uk Desktop PC (NQ808AA) specifications - HP Home & Home Office products

While testing no other application/s were running.

Code:
Question:

* Is my c++ code correct?
* Am I using the correct way to get the clock ticks or is there more reliable tchnique avaliable to do this?
* Is that a problem with new Kernel if so is it a known issue ?
* Do I need to modify the Kernel to obtain regular and stable clock tick at 1000 Hz ?
* Do I have to upgrade the Kernel ?
* Would be great, if pointed to the right direction for solution (e.g. another forum) if no solution at hand.

Thanks
Attached Files
File Type: txt test.txt (2.1 KB, 1 views)
subhan222 is offline  



Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 11:45 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1