Clean up the feedback code.
This commit is contained in:
@@ -126,9 +126,6 @@ static inline task_struct *__scheduler_priority(runqueue_t *runqueue, bool_t ski
|
||||
}
|
||||
}
|
||||
|
||||
//function to track the scheduler algorithm
|
||||
//writeFeedback(next->pid, next->name, next->parent->pid, 2, (next->se).prio);
|
||||
|
||||
return next;
|
||||
#else
|
||||
return __scheduler_rr(runqueue, skip_periodic);
|
||||
@@ -175,8 +172,6 @@ static inline task_struct *__scheduler_cfs(runqueue_t *runqueue, bool_t skip_per
|
||||
next = entry; // scambio il prossimo processo con quello a priorità piu bassa trovato
|
||||
}
|
||||
}
|
||||
//function to track the scheduler algorithm
|
||||
//writeFeedback(next->pid, next->name, next->parent->pid, 3, (next->se).prio);
|
||||
|
||||
return next;
|
||||
#else
|
||||
@@ -243,8 +238,8 @@ task_struct *scheduler_pick_next_task(runqueue_t *runqueue)
|
||||
|
||||
// Update the last context switch time of the next task.
|
||||
next->se.exec_start = timer_get_ticks();
|
||||
feedback(next->pid, next->name, next->parent->pid, 1, (next->se).prio);
|
||||
writeFeedback(next->pid, next->name, next->parent->pid, 1, (next->se).prio);
|
||||
|
||||
scheduler_feedback_update(next);
|
||||
|
||||
return next;
|
||||
}
|
||||
@@ -286,82 +281,3 @@ static void __update_task_statistics(task_struct *task)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Nuova funzione per statistiche RunTime
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#define MAX_STORAGE 500000
|
||||
|
||||
typedef struct statistic {
|
||||
pid_t pid;
|
||||
char name[20];
|
||||
int occur;
|
||||
} stat;
|
||||
|
||||
int countPid = 1;
|
||||
int countPid_1 = 1;
|
||||
|
||||
stat arr_stats[MAX_STORAGE] = { 0, "", 0 };
|
||||
|
||||
pid_t PID_BUFFER1[MAX_STORAGE] = { 0 };
|
||||
char PID_NAME1[MAX_STORAGE][40];
|
||||
|
||||
void feedback(pid_t pid, char name[], pid_t padre, int mode, int prio)
|
||||
{
|
||||
//se lasciamo a 600k sono 31 secondi circa, nb -> ovviamente dipende dalla cpu del pc che ospita la macchina
|
||||
if (!(countPid_1 % 500000)) {
|
||||
//printf("PID %i name :%s\n", pid, name);
|
||||
//qui dentro dobbiamo: ordinare senza ripetizioni sia pid_buffer1 sia pid_name1
|
||||
//e in piu ci serve un altro array per contare le occorreze
|
||||
//se facciamo cosi poi possimao permetterci di ciclare un for e semplicemente stampare i tre cosi
|
||||
int end = 0;
|
||||
printf("\nSTATS:\n");
|
||||
|
||||
for (int i = 0; i < MAX_STORAGE && !end; i++) {
|
||||
if (arr_stats[i].pid == 0) {
|
||||
end = 1;
|
||||
} else {
|
||||
printf("Name: %s, Pid: %i, TCPU: %.4f%% \n", arr_stats[i].name, arr_stats[i].pid, arr_stats[i].occur * 100 / (double)MAX_STORAGE);
|
||||
}
|
||||
}
|
||||
end = 0;
|
||||
//resettiamo
|
||||
for (int i = 0; i < MAX_STORAGE && !end; i++) {
|
||||
if (arr_stats[i].pid == 0) { //se trovo che ho finito di ciclare i valori registrati
|
||||
end = 1; //esco dal for
|
||||
}
|
||||
arr_stats[i].pid = 0;
|
||||
arr_stats[i].occur = 0;
|
||||
}
|
||||
|
||||
countPid = 0;
|
||||
countPid_1 = 0;
|
||||
} else {
|
||||
//Opportuno controllo per non sforare il MAX_STORAGE della struttura dati che utilizziamo
|
||||
if (countPid != MAX_STORAGE) {
|
||||
//REGISTRAZIONE PID IN BUFFER
|
||||
int stored = 0;
|
||||
int endArr = 0;
|
||||
int i;
|
||||
for (i = 0; i < MAX_STORAGE && !stored && !endArr; i++) {
|
||||
if (arr_stats[i].pid == pid) {
|
||||
arr_stats[i].occur++;
|
||||
stored = 1;
|
||||
}
|
||||
if (arr_stats[i].pid == 0) { //se trovo che ho finito di ciclpidare i valori registrati
|
||||
endArr = 1; //esco dal for
|
||||
}
|
||||
}
|
||||
if (!stored) { //se non avevo registrato il valore
|
||||
|
||||
i--;
|
||||
arr_stats[i].pid = pid;
|
||||
strcpy(arr_stats[i].name, name);
|
||||
arr_stats[i].occur = 1;
|
||||
}
|
||||
countPid++;
|
||||
}
|
||||
}
|
||||
countPid_1++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user