Merge branch 'charm' of charmgit:charm into charm
[charm.git] / examples / charm++ / Maj_Min / TempCore.h
1 static int cpufreq_sysfs_read (int proc)
2 {
3         FILE *fd;
4         char path[100];
5         int i=proc;
6         sprintf(path,"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed",i);
7
8         fd = fopen (path, "r");
9
10         if (!fd) {
11                 printf("FILE OPEN ERROR file=%s\n",path);
12                 return 0;
13         }
14         char val[10];
15         fgets(val,10,fd);
16         int ff=atoi(val);
17         fclose (fd);
18
19         return ff;
20 }
21
22 //FILE *f;
23 void writeTemps(FILE *f,char *temps)
24 {
25 //        FILE *f;
26 //        f=fopen("temps.out","a+");
27         fprintf(f,"%s\n",temps);
28 //        fclose(f);
29 }
30
31 float getTemp(int cpu)
32 {
33         char val[10];
34         FILE *f;
35                 char path[100];
36                 sprintf(path,"/sys/devices/platform/coretemp.%d/temp1_input",cpu);
37                 f=fopen(path,"r");
38                 if (!f) {
39                         printf("FILE OPEN ERROR file=\n");
40                         exit(0);
41                 }
42
43         if(f==NULL) {printf("ddddddddddddddddddddddddddd\n");exit(0);}
44         fgets(val,10,f);
45         fclose(f);
46         return atof(val)/1000;
47 }
48
49