rt/msr_jitter.c
changeset 43 35120a61d55e
parent 42 a22a202d0f42
equal deleted inserted replaced
42:a22a202d0f42 43:35120a61d55e
     1 /**************************************************************************************************
     1 /******************************************************************************
     2 *
     2  *
     3 *                          msr_jitter.c
     3  * msr_jitter.c
     4 *
     4  *
     5 *           
     5  * Autor: Wilhelm Hagemeister
     6 *           Autor: Wilhelm Hagemeister
     6  *
     7 *
     7  * (C) Copyright IgH 2002
     8 *           (C) Copyright IgH 2002
     8  * Ingenieurgemeinschaft IgH
     9 *           Ingenieurgemeinschaft IgH
     9  * Heinz-Bäcker Str. 34
    10 *           Heinz-Bäcker Str. 34
    10  * D-45356 Essen
    11 *           D-45356 Essen
    11  * Tel.: +49 201/61 99 31
    12 *           Tel.: +49 201/61 99 31
    12  * Fax.: +49 201/61 98 36
    13 *           Fax.: +49 201/61 98 36
    13  * E-mail: hm@igh-essen.com
    14 *           E-mail: hm@igh-essen.com
    14  *
    15 *
    15  * $Id$
    16 *
    16  *
    17 *           $RCSfile: msr_adeos_latency.c,v $
    17  *****************************************************************************/
    18 *           $Revision: 1.3 $
       
    19 *           $Author: hm $
       
    20 *           $Date: 2005/12/07 20:13:53 $
       
    21 *           $State: Exp $
       
    22 *
       
    23 *
       
    24 *           $Log: msr_adeos_latency.c,v $
       
    25 *           Revision 1.3  2005/12/07 20:13:53  hm
       
    26 *           *** empty log message ***
       
    27 *
       
    28 *           Revision 1.2  2005/12/07 15:56:13  hm
       
    29 *           *** empty log message ***
       
    30 *
       
    31 *           Revision 1.1  2005/12/07 08:43:40  hm
       
    32 *           Initial revision
       
    33 *
       
    34 *           Revision 1.5  2005/11/14 20:28:09  hm
       
    35 *           *** empty log message ***
       
    36 *
       
    37 *           Revision 1.4  2005/11/13 10:34:07  hm
       
    38 *           *** empty log message ***
       
    39 *
       
    40 *           Revision 1.3  2005/11/12 20:52:46  hm
       
    41 *           *** empty log message ***
       
    42 *
       
    43 *           Revision 1.2  2005/11/12 20:51:27  hm
       
    44 *           *** empty log message ***
       
    45 *
       
    46 *           Revision 1.1  2005/11/12 19:16:02  hm
       
    47 *           Initial revision
       
    48 *
       
    49 *           Revision 1.13  2005/06/17 11:35:13  hm
       
    50 *           *** empty log message ***
       
    51 *
       
    52 *
       
    53 *
       
    54 *
       
    55 **************************************************************************************************/
       
    56 
    18 
    57 #ifndef __KERNEL__
    19 #ifndef __KERNEL__
    58 #  define __KERNEL__
    20 #  define __KERNEL__
    59 #endif
    21 #endif
    60 #ifndef MODULE
    22 #ifndef MODULE
    69 #include <linux/param.h> /* fuer HZ */
    31 #include <linux/param.h> /* fuer HZ */
    70 
    32 
    71 #include <msr_reg.h>
    33 #include <msr_reg.h>
    72 #include "msr_jitter.h"
    34 #include "msr_jitter.h"
    73 
    35 
    74 /*--includes-------------------------------------------------------------------------------------*/
    36 /*--includes-----------------------------------------------------------------*/
    75  
       
    76 
    37 
    77 /*--external functions---------------------------------------------------------------------------*/
    38 /*--external functions-------------------------------------------------------*/
    78 
    39 
    79 /*--external data--------------------------------------------------------------------------------*/
    40 /*--external data------------------------------------------------------------*/
    80 
    41 
    81 /*--public data----------------------------------------------------------------------------------*/
    42 /*--public data--------------------------------------------------------------*/
    82 
    43 
    83 /*--local data-----------------------------------------------------------------------------------*/
    44 /*--local data---------------------------------------------------------------*/
    84 
    45 
    85 #define NUMCLASSES 16
    46 #define NUMCLASSES 16
    86 
    47 
    87 static int jittime[NUMCLASSES]={0,1,2,5,10,20,50,100,200,500,1000,2000,5000,10000,20000,50000}; //in usec
    48 static int jittime[NUMCLASSES]={0,1,2,5,10,20,50,100,200,500,
       
    49                                 1000,2000,5000,10000,20000,50000}; //in usec
    88 static int jitcount[NUMCLASSES];
    50 static int jitcount[NUMCLASSES];
    89 static double jitpercent[NUMCLASSES];
    51 static double jitpercent[NUMCLASSES];
    90 
       
    91 static unsigned int tcount = 1;
    52 static unsigned int tcount = 1;
    92 
       
    93 
       
    94 
    53 
    95 static void msr_jit_read(void)
    54 static void msr_jit_read(void)
    96 {
    55 {
    97     int i;
    56     int i;
    98     for(i=0;i<NUMCLASSES;i++) {
    57     for(i=0;i<NUMCLASSES;i++) {
   102     }
    61     }
   103 }
    62 }
   104 
    63 
   105 void msr_jitter_init(void)
    64 void msr_jitter_init(void)
   106 {
    65 {
   107     msr_reg_int_list("/Taskinfo/Jitter/Classes","usec",&jittime[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
    66     msr_reg_int_list("/Taskinfo/Jitter/Classes","usec",
   108     msr_reg_int_list("/Taskinfo/Jitter/Count","",&jitcount[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
    67                      &jittime[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
   109     msr_reg_dbl_list("/Taskinfo/Jitter/percent","%",&jitpercent[0],MSR_R,NUMCLASSES,NULL,NULL,&msr_jit_read);
    68     msr_reg_int_list("/Taskinfo/Jitter/Count","",
       
    69                      &jitcount[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
       
    70     msr_reg_dbl_list("/Taskinfo/Jitter/percent","%",
       
    71                      &jitpercent[0],MSR_R,NUMCLASSES,NULL,NULL,&msr_jit_read);
   110 }
    72 }
   111 
    73 
   112 /*
    74 /******************************************************************************
   113 ***************************************************************************************************
    75  *
   114 *
    76  * Function: msr_jitter_run
   115 * Function: msr_jitter_run
    77  *
   116 *
    78  * Beschreibung:
   117 * Beschreibung: 
    79  *
   118 *               
    80  *
   119 *
    81  * Parameter: Zeiger auf msr_data
   120 * Parameter: Zeiger auf msr_data
    82  *
   121 *
    83  * Rückgabe:
   122 * Rückgabe: 
    84  *
   123 *               
    85  * Status: exp
   124 * Status: exp
    86  *
   125 *
    87  *****************************************************************************/
   126 ***************************************************************************************************
       
   127 */
       
   128 
    88 
   129 void msr_jitter_run(unsigned int hz) {
    89 void msr_jitter_run(unsigned int hz) {
   130 
    90 
   131     int i,hit;
    91     int i,hit;
   132     static int firstrun = 1;
    92     static int firstrun = 1;
   138 
    98 
   139     tcount++;
    99     tcount++;
   140 
   100 
   141     //Zeitabstand zwischen zwei Interrupts in usec
   101     //Zeitabstand zwischen zwei Interrupts in usec
   142 
   102 
   143     dt = ((unsigned long)(100000/HZ)*((unsigned long)(k-j)))/(current_cpu_data.loops_per_jiffy/10);
   103     dt = ((unsigned long)(100000/HZ)*((unsigned long)(k-j)))
       
   104         /(current_cpu_data.loops_per_jiffy/10);
   144 
   105 
   145     jitter = (unsigned int)abs((int)dt-(int)1000000/hz); //jitter errechnet zum Sollabtastrate
   106     jitter = (unsigned int)abs((int)dt-(int)1000000/hz);
       
   107     //jitter errechnet zum Sollabtastrate
   146 
   108 
   147     //in die Klassen einsortieren
   109     //in die Klassen einsortieren
   148     if(!firstrun) { //das erste mal nicht einsortieren
   110     if(!firstrun) { //das erste mal nicht einsortieren
   149 	hit = 0;
   111 	hit = 0;
   150 	for(i=0;i<NUMCLASSES-1;i++) {
   112 	for(i=0;i<NUMCLASSES-1;i++) {
   163 
   125 
   164     j = k;
   126     j = k;
   165 
   127 
   166 
   128 
   167 }
   129 }
   168 
       
   169 
       
   170 
       
   171 
       
   172 
       
   173 
       
   174 
       
   175 
       
   176 
       
   177 
       
   178 
       
   179 
       
   180 
       
   181 
       
   182 
       
   183 
       
   184