- event_data->hooks_trace_before = lttv_hooks_new();
- lttv_hooks_add(event_data->hooks_trace_before, trace_header, event_data, LTTV_PRIO_DEFAULT);
-
- EventsRequest *events_request = g_new(EventsRequest, 1);
- events_request->owner = event_data;
- events_request->viewer_data = event_data;
- events_request->servicing = FALSE;
- events_request->start_time = event_data->time_window.start_time;
- events_request->start_position = NULL;
- events_request->stop_flag = FALSE;
- events_request->end_time = event_data->time_window.end_time;
- events_request->num_events = G_MAXUINT;
- events_request->end_position = NULL;
- events_request->trace = 0;
- events_request->hooks = NULL;
- events_request->before_chunk_traceset = NULL;
- events_request->before_chunk_trace = event_data->hooks_trace_before;
- events_request->before_chunk_tracefile= NULL;
- events_request->event = event_data->event_hooks;
- events_request->event_by_id = NULL;
- events_request->after_chunk_tracefile = NULL;
- events_request->after_chunk_trace = NULL;
- events_request->after_chunk_traceset = NULL;
- events_request->before_request = NULL;
- events_request->after_request = event_data->hooks_trace_after;
-
- lttvwindow_events_request(event_data->tab, events_request);
+ FrequencyHZ = FrequencyInHZ(element.TotalNumberOfInterrupts,event_data->time_window);
+
+ if(FrequencyHZ != 0)
+ {
+ periodInSec = (double)1/FrequencyHZ;
+ periodInSec *= NANOSECONDS_PER_SECOND;
+ periodInNsec = (int)periodInSec;
+
+ }
+
+ gtk_list_store_append (event_data->ListStore, &iter);
+ gtk_list_store_set (event_data->ListStore, &iter,
+ CPUID_COLUMN, element.cpu_id,
+ IRQ_ID_COLUMN, element.id,
+ FREQUENCY_COLUMN, FrequencyHZ,
+ DURATION_COLUMN, real_data,
+ DURATION_STANDARD_DEV_COLUMN, CalculateDurationStandardDeviation(element.id, event_data),
+ MAX_IRQ_HANDLER_COLUMN, maxIrqHandler,
+ MIN_IRQ_HANDLER_COLUMN, minIrqHandler,
+ AVERAGE_PERIOD , periodInNsec,
+ PERIOD_STANDARD_DEV_COLUMN, CalculatePeriodStandardDeviation(element.id, event_data),
+ FREQUENCY_STANDARD_DEV_COLUMN, CalculateFrequencyStandardDeviation(element.id, event_data),
+ -1);
+ printf("%d %d %lld %d %s %d %d %d\n\n",element.id, FrequencyHZ,real_data,CalculateDurationStandardDeviation(element.id, event_data), maxIrqHandler, periodInNsec, CalculatePeriodStandardDeviation(element.id, event_data), CalculateFrequencyStandardDeviation(element.id, event_data));
+
+
+ }
+
+
+ if(event_data->FirstRequestIrqExit->len)
+ {
+ g_array_remove_range (event_data->FirstRequestIrqExit,0,event_data->FirstRequestIrqExit->len);
+ }
+
+ if(event_data->FirstRequestIrqEntry->len)
+ {
+ g_array_remove_range (event_data->FirstRequestIrqEntry,0,event_data->FirstRequestIrqEntry->len);
+ }
+
+ if(event_data->SecondRequestIrqEntry->len)
+ {
+ g_array_remove_range (event_data->SecondRequestIrqEntry,0,event_data->SecondRequestIrqEntry->len);
+ }
+
+ if(event_data->SecondRequestIrqExit->len)
+ {
+ g_array_remove_range (event_data->SecondRequestIrqExit,0, event_data->SecondRequestIrqExit->len);
+ }
+
+ if(event_data->SumArray->len)
+ {
+ g_array_remove_range (event_data->SumArray,0, event_data->SumArray->len);
+ }
+
+ return FALSE;
+}
+
+
+/**
+ * This function converts the number of interrupts over a time window to
+ * frequency in HZ
+ */
+static int FrequencyInHZ(gint NumerofInterruptions, TimeWindow time_window)
+{
+ guint64 frequencyHz = 0;
+ double timeSec; // time in second
+ double result;
+ result = ltt_time_to_double(time_window.time_width);
+ timeSec = (result/NANOSECONDS_PER_SECOND); //time in second
+ frequencyHz = NumerofInterruptions / timeSec;
+ return frequencyHz;
+}
+
+/**
+ * This function calculates the duration standard deviation
+ * Duration standard deviation = sqrt(1/N Sum ((xi -Xa)^2))
+ * Where:
+ * sumId.sumOfDurations -> Sum ((xi -Xa)^2)
+ * inner_component -> 1/N Sum ((xi -Xa)^2)
+ * deviation-> sqrt(1/N Sum ((xi -Xa)^2))
+ */
+static int CalculateDurationStandardDeviation(gint id, InterruptEventData *event_data)
+{
+ int i;
+ SumId sumId;
+ double inner_component;
+ int deviation = 0;
+ for(i = 0; i < event_data->SumArray->len; i++)
+ {
+ sumId = g_array_index(event_data->SumArray, SumId, i);
+ if(id == sumId.irqId)
+ {
+ if(sumId.TotalNumberOfInterrupts != 0)
+ inner_component = sumId.sumOfDurations/ sumId.TotalNumberOfInterrupts;
+ else
+ inner_component = 0.0;
+ deviation = sqrt(inner_component);
+ return deviation;
+ }
+ }
+ return deviation;
+}
+
+
+/**
+ * This function calculates the period standard deviation
+ * Period standard deviation = sqrt(1/N Sum ((xi -Xa)^2))
+ * Where:
+ * sumId.sumOfPeriods -> Sum ((xi -Xa)^2)
+ * inner_component -> 1/N Sum ((xi -Xa)^2)
+ * period_standard_deviation-> sqrt(1/N Sum ((xi -Xa)^2))
+
+ *
+ */
+static int CalculatePeriodStandardDeviation(gint id, InterruptEventData *event_data)
+{
+ int i;
+ SumId sumId;
+ guint64 inner_component;
+ guint64 period_standard_deviation = 0;
+
+ for(i = 0; i < event_data->SumArray->len; i++)
+ {
+ sumId = g_array_index(event_data->SumArray, SumId, i);
+ if(id == sumId.irqId)
+ {
+ if(sumId.TotalNumberOfInterrupts != 0)
+ inner_component = sumId.sumOfPeriods / sumId.TotalNumberOfInterrupts;
+ else
+ inner_component = 0;
+
+ period_standard_deviation = sqrt(inner_component);
+ }
+ }
+
+ return period_standard_deviation;