Skip to content
Snippets Groups Projects
Commit 1b2a4032 authored by Georges Da Costa's avatar Georges Da Costa
Browse files

Adds cli arguments for init of sensors

parent 6882f86a
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ void _get_load(uint64_t* results) { ...@@ -43,7 +43,7 @@ void _get_load(uint64_t* results) {
// Public interface // Public interface
unsigned int init_load(void **state) { unsigned int init_load(char* argument, void **state) {
load_fid = open("/proc/stat", O_RDONLY); load_fid = open("/proc/stat", O_RDONLY);
_get_load(load_values); _get_load(load_values);
return 10; return 10;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*******************************************************/ *******************************************************/
unsigned int init_load(void **); unsigned int init_load(char*, void **);
unsigned int get_load(uint64_t* results, void*); unsigned int get_load(uint64_t* results, void*);
void clean_load(void *); void clean_load(void *);
void label_load(char **labels); void label_load(char **labels);
...@@ -111,7 +111,7 @@ void flushexit() { ...@@ -111,7 +111,7 @@ void flushexit() {
fclose(output); fclose(output);
} }
typedef unsigned int (initializer_t)(void **); typedef unsigned int (initializer_t)(char*, void **);
typedef void (labeler_t)(char **); typedef void (labeler_t)(char **);
typedef unsigned int (*getter_t)(uint64_t*, void*); typedef unsigned int (*getter_t)(uint64_t*, void*);
typedef void (*cleaner_t)(void*); typedef void (*cleaner_t)(void*);
...@@ -125,7 +125,7 @@ unsigned int nb_sensors=0; ...@@ -125,7 +125,7 @@ unsigned int nb_sensors=0;
char **labels=NULL; char **labels=NULL;
uint64_t *values=NULL; uint64_t *values=NULL;
void add_source(initializer_t init, labeler_t labeler, void add_source(initializer_t init, char* arg, labeler_t labeler,
getter_t get, cleaner_t clean) { getter_t get, cleaner_t clean) {
nb_sources++; nb_sources++;
states = realloc(states, nb_sources*sizeof(void*)); states = realloc(states, nb_sources*sizeof(void*));
...@@ -133,7 +133,7 @@ void add_source(initializer_t init, labeler_t labeler, ...@@ -133,7 +133,7 @@ void add_source(initializer_t init, labeler_t labeler,
getter[nb_sources-1] = get; getter[nb_sources-1] = get;
cleaner = realloc(cleaner, nb_sources*sizeof(void*)); cleaner = realloc(cleaner, nb_sources*sizeof(void*));
cleaner[nb_sources-1] = clean; cleaner[nb_sources-1] = clean;
int nb = init(&states[nb_sources-1]); int nb = init(arg, &states[nb_sources-1]);
labels = realloc(labels, (nb_sensors+nb)*sizeof(char*)); labels = realloc(labels, (nb_sensors+nb)*sizeof(char*));
labeler(labels+nb_sensors); labeler(labels+nb_sensors);
...@@ -152,7 +152,6 @@ int main(int argc, char **argv) { ...@@ -152,7 +152,6 @@ int main(int argc, char **argv) {
int rapl_mode = -1; int rapl_mode = -1;
int perf_mode = -1; int perf_mode = -1;
int load_mode = -1;
int stat_mode = -1; int stat_mode = -1;
if(argc==1) if(argc==1)
...@@ -198,7 +197,7 @@ int main(int argc, char **argv) { ...@@ -198,7 +197,7 @@ int main(int argc, char **argv) {
rapl_mode=0; rapl_mode=0;
break; break;
case 'u': case 'u':
load_mode=0; add_source(init_load, NULL, label_load, get_load, clean_load);
break; break;
case 's': case 's':
stat_mode=0; stat_mode=0;
...@@ -210,9 +209,6 @@ int main(int argc, char **argv) { ...@@ -210,9 +209,6 @@ int main(int argc, char **argv) {
usage(argv); usage(argv);
} }
// Load initialization
if(load_mode == 0)
add_source(init_load, label_load, get_load, clean_load);
// Network initialization // Network initialization
int *network_sources = NULL; int *network_sources = NULL;
...@@ -388,8 +384,7 @@ int main(int argc, char **argv) { ...@@ -388,8 +384,7 @@ int main(int argc, char **argv) {
} }
for(int i=0; i<nb_sources;i++) for(int i=0; i<nb_sources;i++)
cleaner[i](states[i]); cleaner[i](states[i]);
// if(load_mode == 0)
// clean_load(load_state);
if(dev!=NULL) if(dev!=NULL)
clean_network(network_sources); clean_network(network_sources);
if(infi_path!=NULL) if(infi_path!=NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment