hm@28: /************************************************************************************************** hm@28: * hm@28: * msr_jitter.c hm@28: * hm@28: * hm@28: * Autor: Wilhelm Hagemeister hm@28: * hm@28: * (C) Copyright IgH 2002 hm@28: * Ingenieurgemeinschaft IgH hm@28: * Heinz-Bäcker Str. 34 hm@28: * D-45356 Essen hm@28: * Tel.: +49 201/61 99 31 hm@28: * Fax.: +49 201/61 98 36 hm@28: * E-mail: hm@igh-essen.com hm@28: * hm@28: * hm@28: * $RCSfile: msr_adeos_latency.c,v $ hm@28: * $Revision: 1.3 $ hm@28: * $Author: hm $ hm@28: * $Date: 2005/12/07 20:13:53 $ hm@28: * $State: Exp $ hm@28: * hm@28: * hm@28: * $Log: msr_adeos_latency.c,v $ hm@28: * Revision 1.3 2005/12/07 20:13:53 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.2 2005/12/07 15:56:13 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.1 2005/12/07 08:43:40 hm hm@28: * Initial revision hm@28: * hm@28: * Revision 1.5 2005/11/14 20:28:09 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.4 2005/11/13 10:34:07 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.3 2005/11/12 20:52:46 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.2 2005/11/12 20:51:27 hm hm@28: * *** empty log message *** hm@28: * hm@28: * Revision 1.1 2005/11/12 19:16:02 hm hm@28: * Initial revision hm@28: * hm@28: * Revision 1.13 2005/06/17 11:35:13 hm hm@28: * *** empty log message *** hm@28: * hm@28: * hm@28: * hm@28: * hm@28: **************************************************************************************************/ hm@28: hm@28: #ifndef __KERNEL__ hm@28: # define __KERNEL__ hm@28: #endif hm@28: #ifndef MODULE hm@28: # define MODULE hm@28: #endif hm@28: hm@28: #include hm@28: #include hm@28: #include hm@28: #include hm@28: #include /* maschine-specific registers */ hm@28: #include /* fuer HZ */ hm@28: hm@28: #include hm@28: #include "msr_jitter.h" hm@28: hm@28: /*--includes-------------------------------------------------------------------------------------*/ hm@28: hm@28: hm@28: /*--external functions---------------------------------------------------------------------------*/ hm@28: hm@28: /*--external data--------------------------------------------------------------------------------*/ hm@28: hm@28: /*--public data----------------------------------------------------------------------------------*/ hm@28: hm@28: /*--local data-----------------------------------------------------------------------------------*/ hm@28: hm@28: #define NUMCLASSES 16 hm@28: hm@28: static int jittime[NUMCLASSES]={0,1,2,5,10,20,50,100,200,500,1000,2000,5000,10000,20000,50000}; //in usec hm@28: static int jitcount[NUMCLASSES]; hm@28: static double jitpercent[NUMCLASSES]; hm@28: hm@28: static unsigned int tcount = 1; hm@28: hm@28: hm@28: hm@28: static void msr_jit_read(void) hm@28: { hm@28: int i; hm@28: for(i=0;i100) { hm@28: jitpercent[i] = jitcount[i]*100.0/tcount; hm@28: } hm@28: } hm@28: } hm@28: hm@28: void msr_jitter_init(void) hm@28: { hm@28: msr_reg_int_list("/Taskinfo/Jitter/Classes","usec",&jittime[0],MSR_R,NUMCLASSES,NULL,NULL,NULL); hm@28: msr_reg_int_list("/Taskinfo/Jitter/Count","",&jitcount[0],MSR_R,NUMCLASSES,NULL,NULL,NULL); hm@28: msr_reg_dbl_list("/Taskinfo/Jitter/percent","%",&jitpercent[0],MSR_R,NUMCLASSES,NULL,NULL,&msr_jit_read); hm@28: } hm@28: hm@28: /* hm@28: *************************************************************************************************** hm@28: * hm@28: * Function: msr_jitter_run hm@28: * hm@28: * Beschreibung: hm@28: * hm@28: * hm@28: * Parameter: Zeiger auf msr_data hm@28: * hm@28: * Rückgabe: hm@28: * hm@28: * Status: exp hm@28: * hm@28: *************************************************************************************************** hm@28: */ hm@28: hm@28: void msr_jitter_run(unsigned int hz) { hm@28: hm@28: int i,hit; hm@28: static int firstrun = 1; hm@28: static int counter = 0; hm@28: static unsigned long k,j = 0; hm@28: unsigned int dt,jitter; hm@28: hm@28: hm@28: rdtscl(k); hm@28: hm@28: tcount++; hm@28: hm@28: //Zeitabstand zwischen zwei Interrupts in usec hm@28: hm@28: dt = ((unsigned long)(100000/HZ)*((unsigned long)(k-j)))/(current_cpu_data.loops_per_jiffy/10); hm@28: hm@28: jitter = (unsigned int)abs((int)dt-(int)1000000/hz); //jitter errechnet zum Sollabtastrate hm@28: hm@28: //in die Klassen einsortieren hm@28: if(!firstrun) { //das erste mal nicht einsortieren hm@28: hit = 0; hm@28: for(i=0;i=jittime[i] && jitter